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
…8023)

Signed-off-by: Emil Mikulic <[email protected]>
  • Loading branch information
g-easy authored and htuch committed Aug 27, 2019
1 parent 8bdebbf commit 816d6f1
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
8 changes: 4 additions & 4 deletions api/bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ BAZEL_SKYLIB_SHA256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc70
GOGOPROTO_RELEASE = "1.2.1"
GOGOPROTO_SHA256 = "99e423905ba8921e86817607a5294ffeedb66fdd4a85efce5eb2848f715fdb3a"

OPENCENSUS_PROTO_RELEASE = "0.2.1"
OPENCENSUS_PROTO_SHA256 = "bfcefa6093fc2ecdf5c9effea86e6982d0d6f9a5178b17fcf73a62e0f3fb43d0"
OPENCENSUS_PROTO_GIT_SHA = "5cec5ea58c3efa81fa808f2bd38ce182da9ee731" # Jul 25, 2019
OPENCENSUS_PROTO_SHA256 = "faeb93f293ff715b0cb530d273901c0e2e99277b9ed1c0a0326bca9ec5774ad2"

PGV_GIT_SHA = "2feaabb13a5d697b80fcb938c0ce37b24c9381ee" # Jul 26, 2018
PGV_SHA256 = "ddefe3dcbb25d68a2e5dfea67d19c060959c2aecc782802bd4c1a5811d44dd45"
Expand Down Expand Up @@ -54,8 +54,8 @@ REPOSITORY_LOCATIONS = dict(
),
opencensus_proto = dict(
sha256 = OPENCENSUS_PROTO_SHA256,
strip_prefix = "opencensus-proto-" + OPENCENSUS_PROTO_RELEASE + "/src",
urls = ["https://github.com/census-instrumentation/opencensus-proto/archive/v" + OPENCENSUS_PROTO_RELEASE + ".tar.gz"],
strip_prefix = "opencensus-proto-" + OPENCENSUS_PROTO_GIT_SHA + "/src",
urls = ["https://github.com/census-instrumentation/opencensus-proto/archive/" + OPENCENSUS_PROTO_GIT_SHA + ".tar.gz"],
),
kafka_source = dict(
sha256 = KAFKA_SOURCE_SHA,
Expand Down
8 changes: 8 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,14 @@ 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, in gRPC
// format: https://github.com/grpc/grpc/blob/master/doc/naming.md
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
8 changes: 4 additions & 4 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"],
),
io_opencensus_cpp = dict(
sha256 = "8d6016e47c2e19e7acbadb6f905b8c422748c64299d71101ac8f28151677e195",
strip_prefix = "opencensus-cpp-cad0d03ff3474cf14389fc249e16847ab7b6895f",
# 2019-07-31
urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/cad0d03ff3474cf14389fc249e16847ab7b6895f.tar.gz"],
sha256 = "b5fcc36a994a4ecb6e53c901e33579ed1ac238cff9975807db760918a15f43ff",
strip_prefix = "opencensus-cpp-8058a1b8efe6a63bd18673abc51223917d12d45d",
# 2019-08-22
urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/8058a1b8efe6a63bd18673abc51223917d12d45d.tar.gz"],
),
com_github_curl = dict(
sha256 = "4376ac72b95572fb6c4fbffefb97c7ea0dd083e1974c0e44cd7e49396f454839",
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 816d6f1

Please sign in to comment.