Replace metric name functions with just string constants

pull/35348/head
Yash Tibrewal 11 months ago
parent e4324a712e
commit e32328825e
  1. 33
      include/grpcpp/ext/otel_plugin.h
  2. 181
      src/cpp/ext/otel/otel_plugin.cc
  3. 16
      test/cpp/ext/csm/metadata_exchange_test.cc
  4. 70
      test/cpp/ext/otel/otel_plugin_test.cc

@ -37,20 +37,6 @@ class OpenTelemetryPluginBuilderImpl;
} // namespace internal
namespace experimental {
// Metrics
absl::string_view OpenTelemetryClientAttemptStartedInstrumentName();
absl::string_view OpenTelemetryClientAttemptStartedInstrumentName();
absl::string_view OpenTelemetryClientAttemptDurationInstrumentName();
absl::string_view
OpenTelemetryClientAttemptSentTotalCompressedMessageSizeInstrumentName();
absl::string_view
OpenTelemetryClientAttemptRcvdTotalCompressedMessageSizeInstrumentName();
absl::string_view OpenTelemetryServerCallStartedInstrumentName();
absl::string_view OpenTelemetryServerCallDurationInstrumentName();
absl::string_view
OpenTelemetryServerCallSentTotalCompressedMessageSizeInstrumentName();
absl::string_view
OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName();
/// The most common way to use this API is -
///
@ -67,8 +53,27 @@ OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName();
/// grpc.server.call.rcvd_total_compressed_message_size
class OpenTelemetryPluginBuilder {
public:
/// Metrics
static constexpr absl::string_view kClientAttemptStartedInstrumentName =
"grpc.client.attempt.started";
static constexpr absl::string_view kClientAttemptDurationInstrumentName =
"grpc.client.attempt.duration";
static constexpr absl::string_view
kClientAttemptSentTotalCompressedMessageSizeInstrumentName =
"grpc.client.attempt.sent_total_compressed_message_size";
static constexpr absl::string_view
kClientAttemptRcvdTotalCompressedMessageSizeInstrumentName =
"grpc.client.attempt.rcvd_total_compressed_message_size";
static constexpr absl::string_view kServerCallStartedInstrumentName =
"grpc.server.call.started";
static constexpr absl::string_view kServerCallDurationInstrumentName =
"grpc.server.call.duration";
static constexpr absl::string_view
kServerCallSentTotalCompressedMessageSizeInstrumentName =
"grpc.server.call.sent_total_compressed_message_size";
static constexpr absl::string_view
kServerCallRcvdTotalCompressedMessageSizeInstrumentName =
"grpc.server.call.rcvd_total_compressed_message_size";
OpenTelemetryPluginBuilder();
/// If `SetMeterProvider()` is not called, no metrics are collected.

@ -61,26 +61,24 @@ absl::string_view OpenTelemetryTargetKey() { return "grpc.target"; }
namespace {
absl::flat_hash_set<std::string> BaseMetrics() {
return absl::flat_hash_set<std::string>{
std::string(grpc::experimental::
OpenTelemetryClientAttemptStartedInstrumentName()),
std::string(grpc::experimental::
OpenTelemetryClientAttemptDurationInstrumentName()),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptDurationInstrumentName),
std::string(
grpc::experimental::
OpenTelemetryClientAttemptSentTotalCompressedMessageSizeInstrumentName()),
grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptSentTotalCompressedMessageSizeInstrumentName),
std::string(
grpc::experimental::
OpenTelemetryClientAttemptRcvdTotalCompressedMessageSizeInstrumentName()),
std::string(
grpc::experimental::OpenTelemetryServerCallStartedInstrumentName()),
std::string(
grpc::experimental::OpenTelemetryServerCallDurationInstrumentName()),
std::string(
grpc::experimental::
OpenTelemetryServerCallSentTotalCompressedMessageSizeInstrumentName()),
std::string(
grpc::experimental::
OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName())};
grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptRcvdTotalCompressedMessageSizeInstrumentName),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallStartedInstrumentName),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallSentTotalCompressedMessageSizeInstrumentName),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallRcvdTotalCompressedMessageSizeInstrumentName)};
}
} // namespace
@ -164,78 +162,76 @@ void OpenTelemetryPluginBuilderImpl::BuildAndRegisterGlobal() {
return;
}
auto meter = meter_provider->GetMeter("grpc-c++", GRPC_CPP_VERSION_STRING);
if (metrics_.contains(
grpc::experimental::
OpenTelemetryClientAttemptStartedInstrumentName())) {
if (metrics_.contains(grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName)) {
g_otel_plugin_state_->client.attempt.started = meter->CreateUInt64Counter(
std::string(grpc::experimental::
OpenTelemetryClientAttemptStartedInstrumentName()),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName),
"Number of client call attempts started", "{attempt}");
}
if (metrics_.contains(
grpc::experimental::
OpenTelemetryClientAttemptDurationInstrumentName())) {
if (metrics_.contains(grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptDurationInstrumentName)) {
g_otel_plugin_state_->client.attempt.duration =
meter->CreateDoubleHistogram(
std::string(grpc::experimental::
OpenTelemetryClientAttemptDurationInstrumentName()),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptDurationInstrumentName),
"End-to-end time taken to complete a client call attempt", "s");
}
if (metrics_.contains(
grpc::experimental::
OpenTelemetryClientAttemptSentTotalCompressedMessageSizeInstrumentName())) {
g_otel_plugin_state_->client.attempt
.sent_total_compressed_message_size = meter->CreateUInt64Histogram(
std::string(
grpc::experimental::
OpenTelemetryClientAttemptSentTotalCompressedMessageSizeInstrumentName()),
"Compressed message bytes sent per client call attempt", "By");
grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptSentTotalCompressedMessageSizeInstrumentName)) {
g_otel_plugin_state_->client.attempt.sent_total_compressed_message_size =
meter->CreateUInt64Histogram(
std::string(
grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptSentTotalCompressedMessageSizeInstrumentName),
"Compressed message bytes sent per client call attempt", "By");
}
if (metrics_.contains(
grpc::experimental::
OpenTelemetryClientAttemptRcvdTotalCompressedMessageSizeInstrumentName())) {
g_otel_plugin_state_->client.attempt
.rcvd_total_compressed_message_size = meter->CreateUInt64Histogram(
std::string(
grpc::experimental::
OpenTelemetryClientAttemptRcvdTotalCompressedMessageSizeInstrumentName()),
"Compressed message bytes received per call attempt", "By");
grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptRcvdTotalCompressedMessageSizeInstrumentName)) {
g_otel_plugin_state_->client.attempt.rcvd_total_compressed_message_size =
meter->CreateUInt64Histogram(
std::string(
grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptRcvdTotalCompressedMessageSizeInstrumentName),
"Compressed message bytes received per call attempt", "By");
}
if (metrics_.contains(
grpc::experimental::OpenTelemetryServerCallStartedInstrumentName())) {
if (metrics_.contains(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallStartedInstrumentName)) {
g_otel_plugin_state_->server.call.started = meter->CreateUInt64Counter(
std::string(
grpc::experimental::OpenTelemetryServerCallStartedInstrumentName()),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallStartedInstrumentName),
"Number of server calls started", "{call}");
}
if (metrics_.contains(grpc::experimental::
OpenTelemetryServerCallDurationInstrumentName())) {
if (metrics_.contains(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName)) {
g_otel_plugin_state_->server.call.duration = meter->CreateDoubleHistogram(
std::string(grpc::experimental::
OpenTelemetryServerCallDurationInstrumentName()),
std::string(grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName),
"End-to-end time taken to complete a call from server transport's "
"perspective",
"s");
}
if (metrics_.contains(
grpc::experimental::
OpenTelemetryServerCallSentTotalCompressedMessageSizeInstrumentName())) {
g_otel_plugin_state_->server.call
.sent_total_compressed_message_size = meter->CreateUInt64Histogram(
std::string(
grpc::experimental::
OpenTelemetryServerCallSentTotalCompressedMessageSizeInstrumentName()),
"Compressed message bytes sent per server call", "By");
grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallSentTotalCompressedMessageSizeInstrumentName)) {
g_otel_plugin_state_->server.call.sent_total_compressed_message_size =
meter->CreateUInt64Histogram(
std::string(
grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallSentTotalCompressedMessageSizeInstrumentName),
"Compressed message bytes sent per server call", "By");
}
if (metrics_.contains(
grpc::experimental::
OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName())) {
g_otel_plugin_state_->server.call
.rcvd_total_compressed_message_size = meter->CreateUInt64Histogram(
std::string(
grpc::experimental::
OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName()),
"Compressed message bytes received per server call", "By");
grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallRcvdTotalCompressedMessageSizeInstrumentName)) {
g_otel_plugin_state_->server.call.rcvd_total_compressed_message_size =
meter->CreateUInt64Histogram(
std::string(
grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallRcvdTotalCompressedMessageSizeInstrumentName),
"Compressed message bytes received per server call", "By");
}
g_otel_plugin_state_->labels_injector = std::move(labels_injector_);
g_otel_plugin_state_->target_attribute_filter =
@ -269,41 +265,20 @@ namespace experimental {
constexpr absl::string_view
OpenTelemetryPluginBuilder::kClientAttemptStartedInstrumentName;
absl::string_view OpenTelemetryClientAttemptStartedInstrumentName() {
return "grpc.client.attempt.started";
}
absl::string_view OpenTelemetryClientAttemptDurationInstrumentName() {
return "grpc.client.attempt.duration";
}
absl::string_view
OpenTelemetryClientAttemptSentTotalCompressedMessageSizeInstrumentName() {
return "grpc.client.attempt.sent_total_compressed_message_size";
}
absl::string_view
OpenTelemetryClientAttemptRcvdTotalCompressedMessageSizeInstrumentName() {
return "grpc.client.attempt.rcvd_total_compressed_message_size";
}
absl::string_view OpenTelemetryServerCallStartedInstrumentName() {
return "grpc.server.call.started";
}
absl::string_view OpenTelemetryServerCallDurationInstrumentName() {
return "grpc.server.call.duration";
}
absl::string_view
OpenTelemetryServerCallSentTotalCompressedMessageSizeInstrumentName() {
return "grpc.server.call.sent_total_compressed_message_size";
}
absl::string_view
OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName() {
return "grpc.server.call.rcvd_total_compressed_message_size";
}
constexpr absl::string_view
OpenTelemetryPluginBuilder::kClientAttemptDurationInstrumentName;
constexpr absl::string_view OpenTelemetryPluginBuilder::
kClientAttemptSentTotalCompressedMessageSizeInstrumentName;
constexpr absl::string_view OpenTelemetryPluginBuilder::
kClientAttemptRcvdTotalCompressedMessageSizeInstrumentName;
constexpr absl::string_view
OpenTelemetryPluginBuilder::kServerCallStartedInstrumentName;
constexpr absl::string_view
OpenTelemetryPluginBuilder::kServerCallDurationInstrumentName;
constexpr absl::string_view OpenTelemetryPluginBuilder::
kServerCallSentTotalCompressedMessageSizeInstrumentName;
constexpr absl::string_view OpenTelemetryPluginBuilder::
kServerCallRcvdTotalCompressedMessageSizeInstrumentName;
//
// OpenTelemetryPluginBuilder

@ -230,8 +230,8 @@ TEST_P(MetadataExchangeTest, ClientAttemptStarted) {
}
TEST_P(MetadataExchangeTest, ClientAttemptDuration) {
Init(/*metric_names=*/{
grpc::experimental::OpenTelemetryClientAttemptDurationInstrumentName()});
Init(/*metric_names=*/{grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptDurationInstrumentName});
SendRPC();
const char* kMetricName = "grpc.client.attempt.duration";
auto data = ReadCurrentMetricsData(
@ -256,8 +256,8 @@ TEST_P(MetadataExchangeTest, ClientAttemptDuration) {
// Verify that grpc.server.call.started does not get service mesh attributes
TEST_P(MetadataExchangeTest, ServerCallStarted) {
Init(
/*metric_names=*/{
grpc::experimental::OpenTelemetryServerCallStartedInstrumentName()});
/*metric_names=*/{grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallStartedInstrumentName});
SendRPC();
const char* kMetricName = "grpc.server.call.started";
auto data = ReadCurrentMetricsData(
@ -277,8 +277,8 @@ TEST_P(MetadataExchangeTest, ServerCallStarted) {
TEST_P(MetadataExchangeTest, ServerCallDuration) {
Init(
/*metric_names=*/{
grpc::experimental::OpenTelemetryServerCallDurationInstrumentName()});
/*metric_names=*/{grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName});
SendRPC();
const char* kMetricName = "grpc.server.call.duration";
auto data = ReadCurrentMetricsData(
@ -301,8 +301,8 @@ TEST_P(MetadataExchangeTest, ServerCallDuration) {
// Test that the server records unknown when the client does not send metadata
TEST_P(MetadataExchangeTest, ClientDoesNotSendMetadata) {
Init(
/*metric_names=*/{grpc::experimental::
OpenTelemetryServerCallDurationInstrumentName()},
/*metric_names=*/{grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName},
/*enable_client_side_injector=*/false);
SendRPC();
const char* kMetricName = "grpc.server.call.duration";

@ -51,7 +51,8 @@ TEST(OpenTelemetryPluginBuildTest, Basic) {
}
TEST_F(OpenTelemetryPluginEnd2EndTest, ClientAttemptStarted) {
Init({grpc::experimental::OpenTelemetryClientAttemptStartedInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName});
SendRPC();
const char* kMetricName = "grpc.client.attempt.started";
auto data = ReadCurrentMetricsData(
@ -79,8 +80,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, ClientAttemptStarted) {
}
TEST_F(OpenTelemetryPluginEnd2EndTest, ClientAttemptDuration) {
Init(
{grpc::experimental::OpenTelemetryClientAttemptDurationInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptDurationInstrumentName});
SendRPC();
const char* kMetricName = "grpc.client.attempt.duration";
auto data = ReadCurrentMetricsData(
@ -112,9 +113,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, ClientAttemptDuration) {
TEST_F(OpenTelemetryPluginEnd2EndTest,
ClientAttemptSentTotalCompressedMessageSize) {
Init(
{grpc::experimental::
OpenTelemetryClientAttemptSentTotalCompressedMessageSizeInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptSentTotalCompressedMessageSizeInstrumentName});
SendRPC();
const char* kMetricName =
"grpc.client.attempt.sent_total_compressed_message_size";
@ -148,9 +148,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest,
TEST_F(OpenTelemetryPluginEnd2EndTest,
ClientAttemptRcvdTotalCompressedMessageSize) {
Init(
{grpc::experimental::
OpenTelemetryClientAttemptRcvdTotalCompressedMessageSizeInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptRcvdTotalCompressedMessageSizeInstrumentName});
SendRPC();
const char* kMetricName =
"grpc.client.attempt.rcvd_total_compressed_message_size";
@ -183,7 +182,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest,
}
TEST_F(OpenTelemetryPluginEnd2EndTest, ServerCallStarted) {
Init({grpc::experimental::OpenTelemetryServerCallStartedInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallStartedInstrumentName});
SendRPC();
const char* kMetricName = "grpc.server.call.started";
auto data = ReadCurrentMetricsData(
@ -207,7 +207,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, ServerCallStarted) {
}
TEST_F(OpenTelemetryPluginEnd2EndTest, ServerCallDuration) {
Init({grpc::experimental::OpenTelemetryServerCallDurationInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName});
SendRPC();
const char* kMetricName = "grpc.server.call.duration";
auto data = ReadCurrentMetricsData(
@ -235,9 +236,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, ServerCallDuration) {
TEST_F(OpenTelemetryPluginEnd2EndTest,
ServerCallSentTotalCompressedMessageSize) {
Init(
{grpc::experimental::
OpenTelemetryServerCallSentTotalCompressedMessageSizeInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallSentTotalCompressedMessageSizeInstrumentName});
SendRPC();
const char* kMetricName =
"grpc.server.call.sent_total_compressed_message_size";
@ -267,9 +267,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest,
TEST_F(OpenTelemetryPluginEnd2EndTest,
ServerCallRcvdTotalCompressedMessageSize) {
Init(
{grpc::experimental::
OpenTelemetryServerCallRcvdTotalCompressedMessageSizeInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallRcvdTotalCompressedMessageSizeInstrumentName});
SendRPC();
const char* kMetricName =
"grpc.server.call.rcvd_total_compressed_message_size";
@ -299,7 +298,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest,
// Make sure that no meter provider results in normal operations.
TEST_F(OpenTelemetryPluginEnd2EndTest, NoMeterProviderRegistered) {
Init({grpc::experimental::OpenTelemetryClientAttemptStartedInstrumentName()},
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName},
/*resource=*/opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/true);
@ -308,8 +308,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, NoMeterProviderRegistered) {
// Test that a channel selector returning true records metrics on the channel.
TEST_F(OpenTelemetryPluginEnd2EndTest, TargetSelectorReturnsTrue) {
Init({grpc::experimental::
OpenTelemetryClientAttemptStartedInstrumentName()}, /*resource=*/
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName}, /*resource=*/
opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,
@ -344,8 +344,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, TargetSelectorReturnsTrue) {
// Test that a target selector returning false does not record metrics on the
// channel.
TEST_F(OpenTelemetryPluginEnd2EndTest, TargetSelectorReturnsFalse) {
Init({grpc::experimental::
OpenTelemetryClientAttemptStartedInstrumentName()}, /*resource=*/
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName}, /*resource=*/
opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,
@ -363,8 +363,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, TargetSelectorReturnsFalse) {
// Test that a target attribute filter returning true records metrics with the
// target as is on the channel.
TEST_F(OpenTelemetryPluginEnd2EndTest, TargetAttributeFilterReturnsTrue) {
Init({grpc::experimental::
OpenTelemetryClientAttemptStartedInstrumentName()}, /*resource=*/
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName}, /*resource=*/
opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,
@ -401,8 +401,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, TargetAttributeFilterReturnsTrue) {
// Test that a target attribute filter returning false records metrics with the
// target as "other".
TEST_F(OpenTelemetryPluginEnd2EndTest, TargetAttributeFilterReturnsFalse) {
Init({grpc::experimental::
OpenTelemetryClientAttemptStartedInstrumentName()}, /*resource=*/
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName}, /*resource=*/
opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,
@ -438,7 +438,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, TargetAttributeFilterReturnsFalse) {
// Test that generic method names are scrubbed properly on the client side.
TEST_F(OpenTelemetryPluginEnd2EndTest, GenericClientRpc) {
Init({grpc::experimental::OpenTelemetryClientAttemptStartedInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName});
SendGenericRPC();
const char* kMetricName = "grpc.client.attempt.started";
auto data = ReadCurrentMetricsData(
@ -469,7 +470,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, GenericClientRpc) {
// the method attribute filter is set and it returns false.
TEST_F(OpenTelemetryPluginEnd2EndTest,
GenericClientRpcWithMethodAttributeFilterReturningFalse) {
Init({grpc::experimental::OpenTelemetryClientAttemptStartedInstrumentName()},
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName},
/*resource=*/opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,
@ -508,7 +510,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest,
// the method attribute filter is set and it returns true.
TEST_F(OpenTelemetryPluginEnd2EndTest,
GenericClientRpcWithMethodAttributeFilterReturningTrue) {
Init({grpc::experimental::OpenTelemetryClientAttemptStartedInstrumentName()},
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kClientAttemptStartedInstrumentName},
/*resource=*/opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,
@ -545,7 +548,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest,
// Test that generic method names are scrubbed properly on the server side.
TEST_F(OpenTelemetryPluginEnd2EndTest, GenericServerRpc) {
Init({grpc::experimental::OpenTelemetryServerCallDurationInstrumentName()});
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName});
SendGenericRPC();
const char* kMetricName = "grpc.server.call.duration";
auto data = ReadCurrentMetricsData(
@ -575,7 +579,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest, GenericServerRpc) {
// the method attribute filter is set and it returns false.
TEST_F(OpenTelemetryPluginEnd2EndTest,
GenericServerRpcWithMethodAttributeFilterReturningFalse) {
Init({grpc::experimental::OpenTelemetryServerCallDurationInstrumentName()},
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName},
/*resource=*/opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,
@ -613,7 +618,8 @@ TEST_F(OpenTelemetryPluginEnd2EndTest,
// the method attribute filter is set and it returns true.
TEST_F(OpenTelemetryPluginEnd2EndTest,
GenericServerRpcWithMethodAttributeFilterReturningTrue) {
Init({grpc::experimental::OpenTelemetryServerCallDurationInstrumentName()},
Init({grpc::experimental::OpenTelemetryPluginBuilder::
kServerCallDurationInstrumentName},
/*resource=*/opentelemetry::sdk::resource::Resource::Create({}),
/*labels_injector=*/nullptr,
/*test_no_meter_provider=*/false,

Loading…
Cancel
Save