Skip to content

Commit

Permalink
GCP Observability: Add payload metrics (grpc#31899)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashykt authored Dec 15, 2022
1 parent a0f00f0 commit 5100b33
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/grpcpp/opencensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ extern const absl::string_view kRpcServerStartedRpcsMeasureName;
// Canonical gRPC view definitions.
const ::opencensus::stats::ViewDescriptor& ClientStartedRpcs();
const ::opencensus::stats::ViewDescriptor& ClientCompletedRpcs();
const ::opencensus::stats::ViewDescriptor&
ClientSentCompressedMessageBytesPerRpc();
const ::opencensus::stats::ViewDescriptor&
ClientReceivedCompressedMessageBytesPerRpc();

const ::opencensus::stats::ViewDescriptor& ServerStartedRpcs();
const ::opencensus::stats::ViewDescriptor& ServerCompletedRpcs();
const ::opencensus::stats::ViewDescriptor&
ServerSentCompressedMessageBytesPerRpc();
const ::opencensus::stats::ViewDescriptor&
ServerReceivedCompressedMessageBytesPerRpc();

const ::opencensus::stats::ViewDescriptor& ClientSentMessagesPerRpcCumulative();
const ::opencensus::stats::ViewDescriptor& ClientSentBytesPerRpcCumulative();
Expand Down
44 changes: 44 additions & 0 deletions src/cpp/ext/filters/census/views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,28 @@ const ViewDescriptor& ClientCompletedRpcs() {
return descriptor;
}

const ViewDescriptor& ClientSentCompressedMessageBytesPerRpc() {
const static ViewDescriptor descriptor =
ViewDescriptor()
.set_name("grpc.io/client/sent_compressed_message_bytes_per_rpc")
.set_measure(kRpcClientSentBytesPerRpcMeasureName)
.set_aggregation(BytesDistributionAggregation())
.add_column(ClientMethodTagKey())
.add_column(ClientStatusTagKey());
return descriptor;
}

const ViewDescriptor& ClientReceivedCompressedMessageBytesPerRpc() {
const static ViewDescriptor descriptor =
ViewDescriptor()
.set_name("grpc.io/client/received_compressed_message_bytes_per_rpc")
.set_measure(kRpcClientReceivedBytesPerRpcMeasureName)
.set_aggregation(BytesDistributionAggregation())
.add_column(ClientMethodTagKey())
.add_column(ClientStatusTagKey());
return descriptor;
}

// server
const ViewDescriptor& ServerStartedRpcs() {
const static ViewDescriptor descriptor =
Expand All @@ -132,6 +154,28 @@ const ViewDescriptor& ServerCompletedRpcs() {
return descriptor;
}

const ViewDescriptor& ServerSentCompressedMessageBytesPerRpc() {
const static ViewDescriptor descriptor =
ViewDescriptor()
.set_name("grpc.io/server/sent_compressed_message_bytes_per_rpc")
.set_measure(kRpcServerSentBytesPerRpcMeasureName)
.set_aggregation(BytesDistributionAggregation())
.add_column(ServerMethodTagKey())
.add_column(ServerStatusTagKey());
return descriptor;
}

const ViewDescriptor& ServerReceivedCompressedMessageBytesPerRpc() {
const static ViewDescriptor descriptor =
ViewDescriptor()
.set_name("grpc.io/server/received_compressed_message_bytes_per_rpc")
.set_measure(kRpcServerReceivedBytesPerRpcMeasureName)
.set_aggregation(BytesDistributionAggregation())
.add_column(ServerMethodTagKey())
.add_column(ServerStatusTagKey());
return descriptor;
}

// client cumulative
const ViewDescriptor& ClientSentBytesPerRpcCumulative() {
const static ViewDescriptor descriptor =
Expand Down
4 changes: 4 additions & 0 deletions src/cpp/ext/gcp/observability.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ void RegisterOpenCensusViewsForGcpObservability() {
// Register client default views for GCP observability
ClientStartedRpcs().RegisterForExport();
ClientCompletedRpcs().RegisterForExport();
ClientSentCompressedMessageBytesPerRpc().RegisterForExport();
ClientReceivedCompressedMessageBytesPerRpc().RegisterForExport();
// Register server default views for GCP observability
ServerStartedRpcs().RegisterForExport();
ServerCompletedRpcs().RegisterForExport();
ServerSentCompressedMessageBytesPerRpc().RegisterForExport();
ServerReceivedCompressedMessageBytesPerRpc().RegisterForExport();
}

} // namespace
Expand Down

0 comments on commit 5100b33

Please sign in to comment.