GcpObservabilityConfig: cloud_trace.sampling_rate (#30904)

pull/30909/head
Yash Tibrewal 2 years ago committed by GitHub
parent ba6e5af377
commit a644d8c9b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/cpp/ext/gcp/observability_config.h
  2. 4
      test/cpp/ext/gcp/observability_config_test.cc

@ -54,12 +54,14 @@ struct GcpObservabilityConfig {
struct CloudTrace {
bool enabled = false;
float sampling_rate = 0;
static const grpc_core::JsonLoaderInterface* JsonLoader(
const grpc_core::JsonArgs&) {
static const auto* loader =
grpc_core::JsonObjectLoader<CloudTrace>()
.OptionalField("enabled", &CloudTrace::enabled)
.OptionalField("sampling_rate", &CloudTrace::sampling_rate)
.Finish();
return loader;
}

@ -34,7 +34,8 @@ TEST(GcpObservabilityConfigJsonParsingTest, Basic) {
"enabled": true
},
"cloud_trace": {
"enabled": true
"enabled": true,
"sampling_rate": 0.05
},
"project_id": "project"
})json";
@ -47,6 +48,7 @@ TEST(GcpObservabilityConfigJsonParsingTest, Basic) {
EXPECT_TRUE(config.cloud_logging.enabled);
EXPECT_TRUE(config.cloud_monitoring.enabled);
EXPECT_TRUE(config.cloud_trace.enabled);
EXPECT_FLOAT_EQ(config.cloud_trace.sampling_rate, 0.05);
EXPECT_EQ(config.project_id, "project");
}

Loading…
Cancel
Save