Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make opencensus Stackdriver exporter respects initial_metadata option #11831

Merged
merged 8 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,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",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ Driver::Driver(const envoy::config::trace::v3::OpenCensusConfig& oc_config,
}
auto channel = Envoy::Grpc::GoogleGrpcUtils::createChannel(stackdriver_service, api);
opts.trace_service_stub = ::google::devtools::cloudtrace::v2::TraceService::NewStub(channel);
const auto& initial_metadata = oc_config.stackdriver_grpc_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.");
Expand Down
3 changes: 3 additions & 0 deletions test/extensions/tracers/opencensus/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerStackdriverGrpc) {
google_grpc:
target_uri: 127.0.0.1:55678
stat_prefix: test
initial_metadata:
- key: foo
value: bar
bianpengyuan marked this conversation as resolved.
Show resolved Hide resolved
)EOF";

envoy::config::trace::v3::Tracing configuration;
Expand Down