[OTel] Remove authority attribute from server metrics (#34189)

Based on updates at https://github.com/grpc/proposal/pull/380
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
pull/34192/head
Yash Tibrewal 1 year ago committed by GitHub
parent af73b6061c
commit 2da74beb96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/cpp/ext/otel/otel_plugin.cc
  2. 1
      src/cpp/ext/otel/otel_plugin.h
  3. 6
      src/cpp/ext/otel/otel_server_call_tracer.cc
  4. 24
      test/cpp/ext/otel/otel_plugin_test.cc

@ -57,8 +57,6 @@ absl::string_view OTelStatusKey() { return "grpc.status"; }
absl::string_view OTelTargetKey() { return "grpc.target"; }
absl::string_view OTelAuthorityKey() { return "grpc.authority"; }
absl::string_view OTelClientAttemptStartedInstrumentName() {
return "grpc.client.attempt.started";
}

@ -66,7 +66,6 @@ const struct OTelPluginState& OTelPluginState();
absl::string_view OTelMethodKey();
absl::string_view OTelStatusKey();
absl::string_view OTelTargetKey();
absl::string_view OTelAuthorityKey();
// Metrics
absl::string_view OTelClientAttemptStartedInstrumentName();

@ -146,8 +146,7 @@ void OpenTelemetryServerCallTracer::RecordReceivedInitialMetadata(
// TODO(yashykt): Figure out how to get this to work with absl::string_view
if (OTelPluginState().server.call.started != nullptr) {
OTelPluginState().server.call.started->Add(
1, {{std::string(OTelMethodKey()), std::string(method_)},
{std::string(OTelAuthorityKey()), authority_}});
1, {{std::string(OTelMethodKey()), std::string(method_)}});
}
}
@ -164,8 +163,7 @@ void OpenTelemetryServerCallTracer::RecordEnd(
{std::string(OTelMethodKey()), std::string(method_)},
{std::string(OTelStatusKey()),
absl::StatusCodeToString(
static_cast<absl::StatusCode>(final_info->final_status))},
{std::string(OTelAuthorityKey()), authority_}};
static_cast<absl::StatusCode>(final_info->final_status))}};
if (OTelPluginState().server.call.duration != nullptr) {
OTelPluginState().server.call.duration->Record(
absl::ToDoubleSeconds(elapsed_time_), attributes,

@ -303,15 +303,11 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallStarted) {
ASSERT_NE(server_started_value, nullptr);
ASSERT_EQ(*server_started_value, 1);
const auto& attributes = data[kMetricName][0].attributes.GetAttributes();
EXPECT_EQ(attributes.size(), 2);
EXPECT_EQ(attributes.size(), 1);
const auto* method_value =
absl::get_if<std::string>(&attributes.at("grpc.method"));
ASSERT_NE(method_value, nullptr);
EXPECT_EQ(*method_value, kMethodName);
const auto* authority_value =
absl::get_if<std::string>(&attributes.at("grpc.authority"));
ASSERT_NE(authority_value, nullptr);
EXPECT_EQ(*authority_value, server_address_);
}
TEST_F(OTelPluginEnd2EndTest, ServerCallDuration) {
@ -330,15 +326,11 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallDuration) {
ASSERT_NE(point_data, nullptr);
ASSERT_EQ(point_data->count_, 1);
const auto& attributes = data[kMetricName][0].attributes.GetAttributes();
EXPECT_EQ(attributes.size(), 3);
EXPECT_EQ(attributes.size(), 2);
const auto* method_value =
absl::get_if<std::string>(&attributes.at("grpc.method"));
ASSERT_NE(method_value, nullptr);
EXPECT_EQ(*method_value, kMethodName);
const auto* authority_value =
absl::get_if<std::string>(&attributes.at("grpc.authority"));
ASSERT_NE(authority_value, nullptr);
EXPECT_EQ(*authority_value, server_address_);
const auto* status_value =
absl::get_if<std::string>(&attributes.at("grpc.status"));
ASSERT_NE(status_value, nullptr);
@ -363,15 +355,11 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallSentTotalCompressedMessageSize) {
ASSERT_NE(point_data, nullptr);
EXPECT_EQ(point_data->count_, 1);
const auto& attributes = data[kMetricName][0].attributes.GetAttributes();
EXPECT_EQ(attributes.size(), 3);
EXPECT_EQ(attributes.size(), 2);
const auto* method_value =
absl::get_if<std::string>(&attributes.at("grpc.method"));
ASSERT_NE(method_value, nullptr);
EXPECT_EQ(*method_value, kMethodName);
const auto* authority_value =
absl::get_if<std::string>(&attributes.at("grpc.authority"));
ASSERT_NE(authority_value, nullptr);
EXPECT_EQ(*authority_value, server_address_);
const auto* status_value =
absl::get_if<std::string>(&attributes.at("grpc.status"));
ASSERT_NE(status_value, nullptr);
@ -396,15 +384,11 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallRcvdTotalCompressedMessageSize) {
ASSERT_NE(point_data, nullptr);
ASSERT_EQ(point_data->count_, 1);
const auto& attributes = data[kMetricName][0].attributes.GetAttributes();
EXPECT_EQ(attributes.size(), 3);
EXPECT_EQ(attributes.size(), 2);
const auto* method_value =
absl::get_if<std::string>(&attributes.at("grpc.method"));
ASSERT_NE(method_value, nullptr);
EXPECT_EQ(*method_value, kMethodName);
const auto* authority_value =
absl::get_if<std::string>(&attributes.at("grpc.authority"));
ASSERT_NE(authority_value, nullptr);
EXPECT_EQ(*authority_value, server_address_);
const auto* status_value =
absl::get_if<std::string>(&attributes.at("grpc.status"));
ASSERT_NE(status_value, nullptr);

Loading…
Cancel
Save