Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support collecting gRPC core metrics #625

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
pull_request:
push:
branches:
branches:
- master
- v0.*
schedule:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
matrix:
include:
- host: ubuntu-latest
profile:
profile:
suffix:
name: Linux-Stable${{ matrix.suffix }}
runs-on: ${{ matrix.host }}
Expand All @@ -57,7 +57,7 @@ jobs:
matrix:
include:
- host: ubuntu-latest
profile:
profile:
suffix:
name: Linux-Stable-openssl${{ matrix.suffix }}
runs-on: ${{ matrix.host }}
Expand Down Expand Up @@ -124,12 +124,12 @@ jobs:
- uses: actions/checkout@v2
- run: choco install -y llvm
- run: Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
- run: go version ; cargo version ; cmake --version
- run: go version ; cargo version ; cmake --version
- run: cargo xtask submodule
- run: cargo build
- run: cargo test --all
- run: cargo test --features "nightly"

Pre-Release:
name: Pre-Release
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ boringssl = ["grpcio-sys/boringssl", "_secure"]
openssl = ["_secure", "grpcio-sys/openssl"]
openssl-vendored = ["_secure", "grpcio-sys/openssl-vendored"]
no-omit-frame-pointer = ["grpcio-sys/no-omit-frame-pointer"]
internals = ["grpcio-sys/internals"]

[badges]
travis-ci = { repository = "tikv/grpc-rs" }
Expand Down
3 changes: 2 additions & 1 deletion grpc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ openssl = ["_secure"]
openssl-vendored = ["openssl", "openssl-sys"]
no-omit-frame-pointer = []
# A hidden feature that is used to force regenerating bindings.
_gen-bindings = ["bindgen"]
_gen-bindings = ["bindgen", "internals"]
_list-package = []
internals = []

[target.'cfg(not(all(any(target_os = "linux", target_os = "macos"), any(target_arch = "x86_64", target_arch = "aarch64"))))'.build-dependencies]
bindgen = "0.59.0"
Expand Down
78 changes: 78 additions & 0 deletions grpc-sys/bindings/binding_internals.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct grpcwrap_stats {
_unused: [u8; 0],
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum grpcwrap_stats_counter {
ClientCallsCreated = 0,
ServerCallsCreated = 1,
ClientChannelsCreated = 2,
ClientSubchannelsCreated = 3,
ServerChannelsCreated = 4,
InsecureConnectionsCreated = 5,
SyscallWrite = 6,
SyscallRead = 7,
TcpReadAlloc8k = 8,
TcpReadAlloc64k = 9,
Http2SettingsWrites = 10,
Http2PingsSent = 11,
Http2WritesBegun = 12,
Http2TransportStalls = 13,
Http2StreamStalls = 14,
CqPluckCreates = 15,
CqNextCreates = 16,
CqCallbackCreates = 17,
COUNTER_COUNT = 18,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum grpcwrap_stats_histogram {
CallInitialSize = 0,
TcpWriteSize = 1,
TcpWriteIovSize = 2,
TcpReadSize = 3,
TcpReadOffer = 4,
TcpReadOfferIovSize = 5,
Http2SendMessageSize = 6,
Http2MetadataSize = 7,
HISTOGRAM_COUNT = 8,
}
extern "C" {
pub fn grpcwrap_stats_collect() -> *mut grpcwrap_stats;
}
extern "C" {
pub fn grpcwrap_stats_free(stats: *mut grpcwrap_stats);
}
extern "C" {
pub fn grpcwrap_stats_get_counter(
stats: *const grpcwrap_stats,
which: grpcwrap_stats_counter,
) -> u64;
}
extern "C" {
pub fn grpcwrap_stats_counter_name(which: grpcwrap_stats_counter) -> grpc_slice;
}
extern "C" {
pub fn grpcwrap_stats_counter_doc(which: grpcwrap_stats_counter) -> grpc_slice;
}
extern "C" {
pub fn grpcwrap_stats_get_histogram_percentile(
stats: *const grpcwrap_stats,
which: grpcwrap_stats_histogram,
percentile: f64,
) -> f64;
}
extern "C" {
pub fn grpcwrap_stats_get_histogram_count(
stats: *const grpcwrap_stats,
which: grpcwrap_stats_histogram,
) -> f64;
}
extern "C" {
pub fn grpcwrap_stats_histogram_name(which: grpcwrap_stats_histogram) -> grpc_slice;
}
extern "C" {
pub fn grpcwrap_stats_histogram_doc(which: grpcwrap_stats_histogram) -> grpc_slice;
}
Loading
Loading