Testing out static constexpr absl::string_view in header

pull/35348/head
Yash Tibrewal 11 months ago
parent 9a1321eeb5
commit e4324a712e
  1. 4
      include/grpcpp/ext/otel_plugin.h
  2. 4
      src/cpp/ext/otel/otel_plugin.cc
  3. 4
      test/cpp/ext/csm/metadata_exchange_test.cc

@ -39,6 +39,7 @@ class OpenTelemetryPluginBuilderImpl;
namespace experimental {
// Metrics
absl::string_view OpenTelemetryClientAttemptStartedInstrumentName();
absl::string_view OpenTelemetryClientAttemptStartedInstrumentName();
absl::string_view OpenTelemetryClientAttemptDurationInstrumentName();
absl::string_view
OpenTelemetryClientAttemptSentTotalCompressedMessageSizeInstrumentName();
@ -66,6 +67,9 @@ OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName();
/// grpc.server.call.rcvd_total_compressed_message_size
class OpenTelemetryPluginBuilder {
public:
static constexpr absl::string_view kClientAttemptStartedInstrumentName =
"grpc.client.attempt.started";
OpenTelemetryPluginBuilder();
/// If `SetMeterProvider()` is not called, no metrics are collected.
OpenTelemetryPluginBuilder& SetMeterProvider(

@ -266,6 +266,10 @@ void OpenTelemetryPluginBuilderImpl::BuildAndRegisterGlobal() {
} // namespace internal
namespace experimental {
constexpr absl::string_view
OpenTelemetryPluginBuilder::kClientAttemptStartedInstrumentName;
absl::string_view OpenTelemetryClientAttemptStartedInstrumentName() {
return "grpc.client.attempt.started";
}

@ -206,8 +206,8 @@ class MetadataExchangeTest
// Verify that grpc.client.attempt.started does not get service mesh attributes
TEST_P(MetadataExchangeTest, ClientAttemptStarted) {
Init(/*metric_names=*/{
grpc::experimental::OpenTelemetryClientAttemptStartedInstrumentName()});
Init(/*metric_names=*/{grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName});
SendRPC();
const char* kMetricName = "grpc.client.attempt.started";
auto data = ReadCurrentMetricsData(

Loading…
Cancel
Save