diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index eee90bc45c46..5c098ce04975 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -385,10 +385,10 @@ DEPENDENCY_REPOSITORIES = dict( use_category = ["other"], ), io_opencensus_cpp = dict( - sha256 = "193ffb4e13bd7886757fd22b61b7f7a400634412ad8e7e1071e73f57bedd7fc6", - strip_prefix = "opencensus-cpp-04ed0211931f12b03c1a76b3907248ca4db7bc90", - # 2020-03-24 - urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/04ed0211931f12b03c1a76b3907248ca4db7bc90.tar.gz"], + sha256 = "12ff300fa804f97bd07e2ff071d969e09d5f3d7bbffeac438c725fa52a51a212", + strip_prefix = "opencensus-cpp-7877337633466358ed680f9b26967da5b310d7aa", + # 2020-06-01 + urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/7877337633466358ed680f9b26967da5b310d7aa.tar.gz"], use_category = ["observability"], cpe = "N/A", ), diff --git a/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc b/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc index 53e82591350f..c836bcc49ba6 100644 --- a/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc +++ b/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc @@ -281,7 +281,17 @@ Driver::Driver(const envoy::config::trace::v3::OpenCensusConfig& oc_config, stackdriver_service.mutable_google_grpc()->set_target_uri(GoogleStackdriverTraceAddress); } auto channel = Envoy::Grpc::GoogleGrpcUtils::createChannel(stackdriver_service, api); + // TODO(bianpengyuan): add tests for trace_service_stub and initial_metadata options with mock + // stubs. opts.trace_service_stub = ::google::devtools::cloudtrace::v2::TraceService::NewStub(channel); + const auto& initial_metadata = stackdriver_service.initial_metadata(); + if (!initial_metadata.empty()) { + opts.prepare_client_context = [initial_metadata](grpc::ClientContext* ctx) { + for (const auto& metadata : initial_metadata) { + ctx->AddMetadata(metadata.key(), metadata.value()); + } + }; + } #else throw EnvoyException("Opencensus tracer: cannot handle stackdriver google grpc service, " "google grpc is not built in."); diff --git a/test/extensions/tracers/opencensus/config_test.cc b/test/extensions/tracers/opencensus/config_test.cc index c27186c9b675..227ed0d353c8 100644 --- a/test/extensions/tracers/opencensus/config_test.cc +++ b/test/extensions/tracers/opencensus/config_test.cc @@ -323,6 +323,9 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerStackdriverGrpc) { google_grpc: target_uri: 127.0.0.1:55678 stat_prefix: test + initial_metadata: + - key: foo + value: bar )EOF"; envoy::config::trace::v3::Tracing configuration; diff --git a/test/per_file_coverage.sh b/test/per_file_coverage.sh index e06bf489cb07..b71a45f126df 100755 --- a/test/per_file_coverage.sh +++ b/test/per_file_coverage.sh @@ -43,8 +43,8 @@ declare -a KNOWN_LOW_COVERAGE=( "source/extensions/retry:95.5" "source/extensions/retry/host:85.7" "source/extensions/stat_sinks/statsd:85.2" -"source/extensions/tracers:96.5" -"source/extensions/tracers/opencensus:92.4" +"source/extensions/tracers:96.3" +"source/extensions/tracers/opencensus:91.2" "source/extensions/tracers/xray:95.3" "source/extensions/transport_sockets:94.9" "source/extensions/transport_sockets/tap:95.6"