Skip to content

Commit

Permalink
tracing: add OpenCensus agent exporter support to OpenCensus driver.
Browse files Browse the repository at this point in the history
Signed-off-by: Emil Mikulic <g-easy@users.noreply.github.com>
  • Loading branch information
g-easy committed Aug 23, 2019
1 parent faad477 commit 58f322f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/envoy/config/trace/v2/trace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ message OpenCensusConfig {
// The URL to Zipkin, e.g. "http://127.0.0.1:9411/api/v2/spans"
string zipkin_url = 6;

// Enables the OpenCensus Agent exporter if set to true. The address must also
// be set.
bool ocagent_exporter_enabled = 11;

// The address of the OpenCensus Agent, if its exporter is enabled.
string ocagent_address = 12;

reserved 7; // Formerly zipkin_service_name.

enum TraceContext {
Expand Down
4 changes: 4 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ def _io_opencensus_cpp():
name = "opencensus_trace_trace_context",
actual = "@io_opencensus_cpp//opencensus/trace:trace_context",
)
native.bind(
name = "opencensus_exporter_ocagent",
actual = "@io_opencensus_cpp//opencensus/exporters/trace/ocagent:ocagent_exporter",
)
native.bind(
name = "opencensus_exporter_stdout",
actual = "@io_opencensus_cpp//opencensus/exporters/trace/stdout:stdout_exporter",
Expand Down
1 change: 1 addition & 0 deletions source/extensions/tracers/opencensus/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ envoy_cc_library(
"opencensus_trace_cloud_trace_context",
"opencensus_trace_grpc_trace_bin",
"opencensus_trace_trace_context",
"opencensus_exporter_ocagent",
"opencensus_exporter_stdout",
"opencensus_exporter_stackdriver",
"opencensus_exporter_zipkin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "absl/strings/str_cat.h"
#include "google/devtools/cloudtrace/v2/tracing.grpc.pb.h"
#include "opencensus/exporters/trace/ocagent/ocagent_exporter.h"
#include "opencensus/exporters/trace/stackdriver/stackdriver_exporter.h"
#include "opencensus/exporters/trace/stdout/stdout_exporter.h"
#include "opencensus/exporters/trace/zipkin/zipkin_exporter.h"
Expand Down Expand Up @@ -257,6 +258,11 @@ Driver::Driver(const envoy::config::trace::v2::OpenCensusConfig& oc_config,
opts.service_name = local_info_.clusterName();
::opencensus::exporters::trace::ZipkinExporter::Register(opts);
}
if (oc_config.ocagent_exporter_enabled()) {
::opencensus::exporters::trace::OcAgentOptions opts;
opts.address = oc_config.ocagent_address();
::opencensus::exporters::trace::OcAgentExporter::Register(std::move(opts));
}
}

void Driver::applyTraceConfig(const opencensus::proto::trace::v1::TraceConfig& config) {
Expand Down
2 changes: 2 additions & 0 deletions test/extensions/tracers/opencensus/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerWithTypedConfig) {
stackdriver_project_id: test_project_id
zipkin_exporter_enabled: true
zipkin_url: http://127.0.0.1:9411/api/v2/spans
ocagent_exporter_enabled: true
ocagent_address: 127.0.0.1:55678
incoming_trace_context: b3
incoming_trace_context: trace_context
incoming_trace_context: grpc_trace_bin
Expand Down

0 comments on commit 58f322f

Please sign in to comment.