Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e517ebf
Add initial OpenCensus tracing support.
g-easy Dec 10, 2018
de6b334
tools/check_repositories.sh: make regexes look for word start.
g-easy Dec 21, 2018
0c17e0a
Fix clang_tidy error.
g-easy Dec 21, 2018
461d9b0
Merge remote-tracking branch 'origin/master' into oc
g-easy Jan 18, 2019
0bcaf23
Merge remote-tracking branch 'origin/master' into oc
g-easy Jan 22, 2019
ec0f25d
Fix mismerge.
g-easy Jan 22, 2019
2f0d285
Remove debugging printfs.
g-easy Jan 22, 2019
d96f105
Add explicit break.
g-easy Jan 22, 2019
0e28684
Format fix.
g-easy Jan 22, 2019
e54cadb
Add opencensus:config_test.
g-easy Jan 22, 2019
1081de3
Don't apply empty TraceConfig.
g-easy Jan 22, 2019
471dc28
Add opencensus:tracer_test.
g-easy Jan 22, 2019
e5d3b9a
clang_tidy fixes.
g-easy Jan 29, 2019
c5d46f4
Merge remote-tracking branch 'origin/master' into oc
g-easy Feb 1, 2019
7e444e3
Mark config proto experimental.
g-easy Feb 1, 2019
0902d7d
Use OpenCensus propagation helpers for traceparent, grpc-trace-bin.
g-easy Feb 1, 2019
710a6a4
Don't use glob() in curl.BUILD.
g-easy Feb 1, 2019
886bccb
Merge remote-tracking branch 'origin/master' into oc
g-easy Feb 7, 2019
06e0d1e
Merge remote-tracking branch 'origin/master' into oc
g-easy Feb 22, 2019
bd901c5
Bump date.
g-easy Feb 22, 2019
024611d
Caps.
g-easy Feb 22, 2019
8f0a4ff
Use camelCase, add comments about interplay with exporter thread.
g-easy Feb 22, 2019
916b860
Merge remote-tracking branch 'origin/master' into oc
g-easy Feb 25, 2019
a984a60
Use ENVOY_LOG_MISC for debug string.
g-easy Feb 25, 2019
38a19c6
Variable names.
g-easy Feb 25, 2019
78d3320
Make samplers non-static.
g-easy Feb 25, 2019
16a3e3d
Remove underscore.
g-easy Feb 27, 2019
16d9939
Delete commented out leftover.
g-easy Feb 27, 2019
cdc9b3c
Comment.
g-easy Feb 27, 2019
7bbdce8
Merge remote-tracking branch 'origin/master' into oc
g-easy Feb 27, 2019
b19efcb
Upgrade opencensus-cpp dep.
g-easy Feb 27, 2019
9a1c637
Better example of trace_config.
g-easy Feb 27, 2019
cd0486b
Reset TraceParams back to default.
g-easy Feb 27, 2019
85d4e77
format
g-easy Feb 27, 2019
93846d4
Merge remote-tracking branch 'origin/master' into oc
g-easy Mar 12, 2019
a9e19df
Add log()
g-easy Mar 12, 2019
40f4308
Update opencensus-proto to catch trace_config.proto change.
g-easy Mar 12, 2019
ec14fd5
Update ConstantSampler handling.
g-easy Mar 12, 2019
d65ebb0
Use envoy_cmake_external for curl.
g-easy Mar 12, 2019
e17a406
Update config and tracer test.
g-easy Mar 12, 2019
f7a90b3
Fix compile_time_options: set CMAKE_BUILD_TYPE for curl.
g-easy Mar 12, 2019
8eea063
Optionally accept and propagate an incoming trace context.
g-easy Mar 12, 2019
26853eb
Fix config test.
g-easy Mar 12, 2019
0afc3eb
Fix envoy.api.
g-easy Mar 12, 2019
e5c743e
Merge remote-tracking branch 'origin/master' into oc
g-easy Mar 19, 2019
9efab49
Upgrade and correctly name opencensus_proto.
g-easy Mar 19, 2019
fd739ca
clang-tidy fixup.
g-easy Mar 19, 2019
19dbc58
Fix build:go_build_test
g-easy Apr 11, 2019
1c56a62
Merge remote-tracking branch 'origin/master' into oc
g-easy Apr 11, 2019
c06ae5f
Merge remote-tracking branch 'origin/master' into oc
g-easy Apr 15, 2019
a7f53f2
Test constant_sampler and more of the config.
g-easy Apr 15, 2019
5b78b82
format
g-easy Apr 15, 2019
6a3e7db
Test spawnChild().
g-easy Apr 15, 2019
0b0f6df
Test injectContext().
g-easy Apr 15, 2019
8ab8440
format
g-easy Apr 15, 2019
db9f80f
Merge remote-tracking branch 'origin/master' into oc
g-easy Apr 18, 2019
199a060
Merge remote-tracking branch 'origin/master' into oc
g-easy May 20, 2019
f2ca81e
Upgrade OpenCensus C++ to work around bazel build error.
g-easy May 20, 2019
6ccab02
Need to also upgrade absl to get new flag name.
g-easy May 20, 2019
1fb1b9c
Catch up to new API.
g-easy May 20, 2019
142a386
Fix libcurl linkage.
g-easy May 23, 2019
ee4d4d0
Merge remote-tracking branch 'origin/master' into oc
g-easy Jun 3, 2019
41f7dff
Change of direction: don't upgrade absl.
g-easy Jun 3, 2019
bbaca7f
Patch opencensus to work with current absl.
g-easy Jun 3, 2019
7d07e53
Adapt to commit 8d1ad35aa7
g-easy Jun 3, 2019
a4e7038
Avoid ODR by not using lightstep_vendored_googleapis.
g-easy May 29, 2019
4719582
Switch custom googleapis build to the native cc_proto_library rule.
g-easy Jun 4, 2019
154b58c
Add @googleapis//:tracing_proto for stackdriver trace.
g-easy Jun 4, 2019
88e6a19
curl without libssh2, trying to fix macos build.
g-easy Jun 4, 2019
f587ee8
Review comments.
g-easy Jun 4, 2019
b87a8e1
grpc-trace-bin needs to be base64 encoded/decoded without padding.
g-easy Jun 4, 2019
9ca882f
Finish todo: tests for grpc-trace-bin.
g-easy Jun 4, 2019
c8fc2c9
Spellcheck doesn't like the comment.
g-easy Jun 4, 2019
03df4ad
Add decode_without_padding().
g-easy Jun 4, 2019
2d9e96b
Use decode_without_padding().
g-easy Jun 4, 2019
9d89449
decodeWithoutPadding rename + take string_view
g-easy Jun 5, 2019
4e3245c
Make ALWAYS_ON fallthrough.
g-easy Jun 5, 2019
4122637
Current span context is always valid.
g-easy Jun 5, 2019
3b9ced4
Factor out SamplerTestHelper and increase coverage.
g-easy Jun 5, 2019
7385873
speling
g-easy Jun 5, 2019
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
15 changes: 15 additions & 0 deletions api/bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,26 @@ api_proto_library(
visibility = ["//visibility:public"],
)

api_proto_library(
name = "trace_config",
srcs = [
"trace_config.proto",
],
visibility = ["//visibility:public"],
)

go_proto_library(
name = "trace_model_go_proto",
importpath = "trace_model",
proto = ":trace_model",
visibility = ["//visibility:public"],
)

go_proto_library(
name = "trace_config_go_proto",
importpath = "trace_config",
proto = ":trace_config",
visibility = ["//visibility:public"],
)
""",
)
2 changes: 2 additions & 0 deletions api/envoy/config/trace/v2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ api_proto_library_internal(
],
deps = [
"//envoy/api/v2/core:grpc_service",
"@io_opencensus_trace//:trace_config",
],
)

Expand All @@ -18,5 +19,6 @@ api_go_proto_library(
proto = ":trace",
deps = [
"//envoy/api/v2/core:grpc_service_go_proto",
"@io_opencensus_trace//:trace_config_go_proto",
],
)
40 changes: 40 additions & 0 deletions api/envoy/config/trace/v2/trace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package envoy.config.trace.v2;
option go_package = "v2";

import "envoy/api/v2/core/grpc_service.proto";
import "trace_config.proto";

import "google/protobuf/any.proto";
import "google/protobuf/struct.proto";
Expand All @@ -29,6 +30,7 @@ message Tracing {
// - *envoy.zipkin*
// - *envoy.dynamic.ot*
// - *envoy.tracers.datadog*
// - *envoy.tracers.opencensus*
string name = 1 [(validate.rules).string.min_bytes = 1];

// Trace driver specific configuration which depends on the driver being instantiated.
Expand All @@ -38,6 +40,7 @@ message Tracing {
// - :ref:`ZipkinConfig <envoy_api_msg_config.trace.v2.ZipkinConfig>`
// - :ref:`DynamicOtConfig <envoy_api_msg_config.trace.v2.DynamicOtConfig>`
// - :ref:`DatadogConfig <envoy_api_msg_config.trace.v2.DatadogConfig>`
// - :ref:`OpenCensusConfig <envoy_api_msg_config.trace.v2.OpenCensusConfig>`
oneof config_type {
google.protobuf.Struct config = 2;

Expand Down Expand Up @@ -100,6 +103,43 @@ message DatadogConfig {
string service_name = 2 [(validate.rules).string.min_bytes = 1];
}

// Configuration for the OpenCensus tracer.
message OpenCensusConfig {
// Configures tracing, e.g. the sampler, max number of annotations, etc.
opencensus.proto.trace.v1.TraceConfig trace_config = 1;

// Enables the stdout exporter if set to true. This is intended for debugging
// purposes.
bool stdout_exporter_enabled = 2;

// Enables the Stackdriver exporter if set to true. The project_id must also
// be set.
bool stackdriver_exporter_enabled = 3;

// The Cloud project_id to use for Stackdriver tracing.
string stackdriver_project_id = 4;

// Enables the Zipkin exporter if set to true. The url and service name must
// also be set.
bool zipkin_exporter_enabled = 5;

// The URL to Zipkin, e.g. "http://127.0.0.1:9411/api/v2/spans"
string zipkin_url = 6;
Comment thread
htuch marked this conversation as resolved.

// The Zipkin service name.
string zipkin_service_name = 7;
Comment thread
g-easy marked this conversation as resolved.

// Enables propagating trace context using the X-Cloud-Trace-Context header.
bool propagate_cloud_trace_context = 8;

// Enables propagating trace context using the traceparent header with the
// W3C Trace-Context format.
bool propagate_trace_context = 9;

// Enables propagating trace context using the binary grpc-trace-bin header.
bool propagate_grpc_trace_bin = 10;
}

// Configuration structure.
message TraceServiceConfig {
// The upstream gRPC cluster that hosts the metrics service.
Expand Down
35 changes: 35 additions & 0 deletions bazel/external/curl.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
load("@io_opencensus_cpp//opencensus:curl.bzl", "CURL_COPTS")

package(features = ["no_copts_tokenization"])

config_setting(
name = "windows",
values = {"cpu": "x64_windows"},
visibility = ["//visibility:private"],
)

config_setting(
name = "osx",
values = {"cpu": "darwin"},
visibility = ["//visibility:private"],
)
Comment thread
g-easy marked this conversation as resolved.
Outdated

cc_library(
Comment thread
g-easy marked this conversation as resolved.
Outdated
name = "curl",
srcs = glob([
"lib/**/*.c",
]),
hdrs = glob([
"include/curl/*.h",
"lib/**/*.h",
]),
copts = CURL_COPTS + [
"-DOS=\"os\"",
"-DCURL_EXTERN_SYMBOL=__attribute__((__visibility__(\"default\")))",
],
includes = [
"include/",
"lib/",
],
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions bazel/external/rapidjson.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ cc_library(
name = "rapidjson",
hdrs = glob(["include/rapidjson/**/*.h"]),
includes = ["include"],
defines = ["RAPIDJSON_HAS_STDSTRING=1"],
visibility = ["//visibility:public"],
)
32 changes: 32 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []):
_com_github_tencent_rapidjson()
_com_google_googletest()
_com_google_protobuf()
_io_opencensus_cpp()
_com_github_curl()

# Used for bundling gcovr into a relocatable .par file.
_repository_impl("subpar")
Expand Down Expand Up @@ -527,6 +529,36 @@ def _com_google_protobuf():
actual = "@com_google_protobuf//util/python:python_headers",
)

def _io_opencensus_cpp():
_repository_impl("io_opencensus_cpp")
native.bind(
name = "opencensus_trace",
actual = "@io_opencensus_cpp//opencensus/trace",
)
native.bind(
name = "opencensus_trace_cloud_trace_context",
actual = "@io_opencensus_cpp//opencensus/trace:cloud_trace_context",
)
native.bind(
name = "opencensus_exporter_stdout",
actual = "@io_opencensus_cpp//opencensus/exporters/trace/stdout:stdout_exporter",
)
native.bind(
name = "opencensus_exporter_stackdriver",
actual = "@io_opencensus_cpp//opencensus/exporters/trace/stackdriver:stackdriver_exporter",
)
native.bind(
name = "opencensus_exporter_zipkin",
actual = "@io_opencensus_cpp//opencensus/exporters/trace/zipkin:zipkin_exporter",
)

def _com_github_curl():
# Curl library - used by OpenCensus Zipkin exporter.
_repository_impl(
"com_github_curl",
build_file = "@envoy//bazel/external:curl.BUILD",
)

def _com_github_grpc_grpc():
_repository_impl("com_github_grpc_grpc")

Expand Down
16 changes: 13 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://github.com/google/boringssl/archive/77e47de9e16ec8865d1bc6d614dd918141f094d2.tar.gz"],
),
com_google_absl = dict(
sha256 = "e35082e88b9da04f4d68094c05ba112502a5063712f3021adfa465306d238c76",
strip_prefix = "abseil-cpp-cc8dcd307b76a575d2e3e0958a4fe4c7193c2f68",
sha256 = "3ad76de484192b2d5afd49d90492b5ed0bc59eb1a4e8e0deecc7a2a077a90251",
strip_prefix = "abseil-cpp-f197d7c72a54064cfde5a2058f1513a4a0ee36fb",
# 2018-10-31
urls = ["https://github.com/abseil/abseil-cpp/archive/cc8dcd307b76a575d2e3e0958a4fe4c7193c2f68.tar.gz"],
urls = ["https://github.com/abseil/abseil-cpp/archive/f197d7c72a54064cfde5a2058f1513a4a0ee36fb.tar.gz"],
Comment thread
g-easy marked this conversation as resolved.
Outdated
),
com_github_apache_thrift = dict(
sha256 = "7d59ac4fdcb2c58037ebd4a9da5f9a49e3e034bf75b3f26d9fe48ba3d8806e6b",
Expand Down Expand Up @@ -190,4 +190,14 @@ REPOSITORY_LOCATIONS = dict(
strip_prefix = "subpar-1.3.0",
urls = ["https://github.com/google/subpar/archive/1.3.0.tar.gz"],
),
io_opencensus_cpp = dict(
sha256 = "b967e22fd6be41e2e78bb2fee2d7027ed48cc6b9e0ce2620c2f3db3a8913ff9c",
strip_prefix = "opencensus-cpp-e9d986ebeb413acb4f8ec1bdff33485866a794b7",
urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/e9d986ebeb413acb4f8ec1bdff33485866a794b7.tar.gz"],
),
com_github_curl = dict(
sha256 = "d483b89062832e211c887d7cf1b65c902d591b48c11fe7d174af781681580b41",
strip_prefix = "curl-7.63.0",
urls = ["https://github.com/curl/curl/releases/download/curl-7_63_0/curl-7.63.0.tar.gz"],
),
)
1 change: 1 addition & 0 deletions source/extensions/extensions_build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ EXTENSIONS = {
"envoy.tracers.lightstep": "//source/extensions/tracers/lightstep:config",
"envoy.tracers.datadog": "//source/extensions/tracers/datadog:config",
"envoy.tracers.zipkin": "//source/extensions/tracers/zipkin:config",
"envoy.tracers.opencensus": "//source/extensions/tracers/opencensus:config",

#
# Transport sockets
Expand Down
39 changes: 39 additions & 0 deletions source/extensions/tracers/opencensus/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
licenses(["notice"]) # Apache 2

# Trace driver for OpenCensus: https://opencensus.io/

load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_package",
)

envoy_package()

envoy_cc_library(
name = "config",
srcs = ["config.cc"],
hdrs = ["config.h"],
deps = [
":opencensus_tracer_impl",
"//source/extensions/tracers:well_known_names",
"//source/extensions/tracers/common:factory_base_lib",
],
)

envoy_cc_library(
name = "opencensus_tracer_impl",
srcs = ["opencensus_tracer_impl.cc"],
hdrs = ["opencensus_tracer_impl.h"],
external_deps = [
"opencensus_trace",
"opencensus_trace_cloud_trace_context",
"opencensus_exporter_stdout",
"opencensus_exporter_stackdriver",
"opencensus_exporter_zipkin",
],
deps = [
"//source/common/config:utility_lib",
"//source/common/tracing:http_tracer_lib",
],
)
37 changes: 37 additions & 0 deletions source/extensions/tracers/opencensus/config.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "extensions/tracers/opencensus/config.h"

#include <iostream>

#include "envoy/registry/registry.h"

#include "common/tracing/http_tracer_impl.h"

#include "extensions/tracers/opencensus/opencensus_tracer_impl.h"
#include "extensions/tracers/well_known_names.h"

namespace Envoy {
namespace Extensions {
namespace Tracers {
namespace OpenCensus {

OpenCensusTracerFactory::OpenCensusTracerFactory() : FactoryBase(TracerNames::get().OpenCensus) {
std::cerr << "OpenCensusTracerFactory()\n";
Comment thread
g-easy marked this conversation as resolved.
Outdated
}

Tracing::HttpTracerPtr OpenCensusTracerFactory::createHttpTracerTyped(
const envoy::config::trace::v2::OpenCensusConfig& proto_config, Server::Instance& server) {
std::cerr << "OpenCensusTracerFactory::createHttpTracerTyped()\n";
Tracing::DriverPtr driver = std::make_unique<Driver>(proto_config);
return std::make_unique<Tracing::HttpTracerImpl>(std::move(driver), server.localInfo());
}

/**
* Static registration for the OpenCensus tracer. @see RegisterFactory.
*/
static Registry::RegisterFactory<OpenCensusTracerFactory, Server::Configuration::TracerFactory>
Comment thread
g-easy marked this conversation as resolved.
Outdated
register_;

} // namespace OpenCensus
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
32 changes: 32 additions & 0 deletions source/extensions/tracers/opencensus/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <string>

#include "envoy/config/trace/v2/trace.pb.validate.h"

#include "extensions/tracers/common/factory_base.h"

namespace Envoy {
namespace Extensions {
namespace Tracers {
namespace OpenCensus {

/**
* Config registration for the OpenCensus tracer. @see TracerFactory.
*/
class OpenCensusTracerFactory
: public Common::FactoryBase<envoy::config::trace::v2::OpenCensusConfig> {
public:
OpenCensusTracerFactory();

private:
// FactoryBase
Tracing::HttpTracerPtr
createHttpTracerTyped(const envoy::config::trace::v2::OpenCensusConfig& proto_config,
Server::Instance& server) override;
};

} // namespace OpenCensus
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
Loading