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

tracing: add OpenCensus agent exporter support to OpenCensus driver. #8023

Merged
merged 9 commits into from
Aug 27, 2019
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 = "26aa36c099c2041b432cf3cc8a26c5fb858d218b" # Jul 23, 2019
OPENCENSUS_PROTO_SHA256 = "a63bcc8655140b6273cabf91dd84c8e3d8ea98ab2727555e7cf1c13cae5367db"

PGV_GIT_SHA = "2feaabb13a5d697b80fcb938c0ce37b24c9381ee" # Jul 26, 2018
PGV_SHA256 = "ddefe3dcbb25d68a2e5dfea67d19c060959c2aecc782802bd4c1a5811d44dd45"
Expand Down Expand Up @@ -46,8 +46,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
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;
g-easy marked this conversation as resolved.
Show resolved Hide resolved

reserved 7; // Formerly zipkin_service_name.

enum TraceContext {
Expand Down
13 changes: 13 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def envoy_dependencies(skip_targets = []):
_com_google_googletest()
_com_google_protobuf()
_io_opencensus_cpp()
_grpc_java()
_com_github_curl()
_com_github_envoyproxy_sqlparser()
_com_googlesource_quiche()
Expand Down Expand Up @@ -549,6 +550,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 All @@ -562,6 +567,14 @@ def _io_opencensus_cpp():
actual = "@io_opencensus_cpp//opencensus/exporters/trace/zipkin:zipkin_exporter",
)

def _grpc_java():
g-easy marked this conversation as resolved.
Show resolved Hide resolved
# Used by @io_opencensus_proto.
location = REPOSITORY_LOCATIONS["grpc_java"]
http_archive(
name = "grpc_java",
**location
)

def _com_github_curl():
# Used by OpenCensus Zipkin exporter.
location = REPOSITORY_LOCATIONS["com_github_curl"]
Expand Down
13 changes: 9 additions & 4 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,15 @@ 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"],
),
grpc_java = dict(
sha256 = "9618a6f4ec0f2bdb77d9b6e01865af9796f370e63e1352210798bacfc99ccdac",
strip_prefix = "grpc-java-1.23.0",
urls = ["https://github.com/grpc/grpc-java/archive/v1.23.0.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