Skip to content

Commit

Permalink
tracing: Add support for sending data in Zipkin v2 format (#6985)
Browse files Browse the repository at this point in the history
Description: This patch supports sending a list of spans as JSON v2 and protobuf message over HTTP to Zipkin collector. [Sending protobuf](https://github.com/openzipkin/zipkin-api/blob/0.2.1/zipkin.proto) is considered to be more efficient than JSON, even compared to the v2's JSON (openzipkin/zipkin#2589 (comment)). This is an effort to rework envoyproxy/envoy#6798.

The approach is by serializing the v1 model to both v2 JSON and protobuf.

Risk Level: Low, since the default is still HTTP-JSON v1 based on https://github.com/openzipkin/zipkin-api/blob/0.2.2/zipkin-api.yaml.
Testing: Unit testing, manual integration test with real Zipkin collector server.
Docs Changes: Added
Release Notes: Added
Fixes: #4839

Signed-off-by: Dhi Aurrahman <dio@tetrate.io>
Signed-off-by: José Carlos Chávez <jcchavezs@gmail.com>

Mirrored from https://github.com/envoyproxy/envoy @ 6c6e18e5881936405cba72e936ecd6a5b3fe0852
  • Loading branch information
data-plane-api(CircleCI) committed Aug 30, 2019
1 parent 5ed543e commit 4d1ee75
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
25 changes: 25 additions & 0 deletions bazel/repositories.bzl
Expand Up @@ -38,6 +38,11 @@ def api_dependencies():
locations = REPOSITORY_LOCATIONS,
build_file_content = KAFKASOURCE_BUILD_CONTENT,
)
envoy_http_archive(
name = "com_github_openzipkin_zipkinapi",
locations = REPOSITORY_LOCATIONS,
build_file_content = ZIPKINAPI_BUILD_CONTENT,
)

GOGOPROTO_BUILD_CONTENT = """
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")
Expand Down Expand Up @@ -153,3 +158,23 @@ filegroup(
)
"""

ZIPKINAPI_BUILD_CONTENT = """
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library", "api_go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
api_proto_library(
name = "zipkin",
srcs = [
"zipkin-jsonv2.proto",
"zipkin.proto",
],
visibility = ["//visibility:public"],
)
api_go_proto_library(
name = "zipkin",
proto = ":zipkin",
)
"""
8 changes: 8 additions & 0 deletions bazel/repository_locations.bzl
Expand Up @@ -21,6 +21,9 @@ KAFKA_SOURCE_SHA = "ae7a1696c0a0302b43c5b21e515c37e6ecd365941f68a510a7e442eebddf
UDPA_GIT_SHA = "4cbdcb9931ca743a915a7c5fda51b2ee793ed157" # Aug 22, 2019
UDPA_SHA256 = "6291d0c0e3a4d5f08057ea7a00ed0b0ec3dd4e5a3b1cf20f803774680b5a806f"

ZIPKINAPI_RELEASE = "0.2.2" # Aug 23, 2019
ZIPKINAPI_SHA256 = "688c4fe170821dd589f36ec45aaadc03a618a40283bc1f97da8fa11686fc816b"

REPOSITORY_LOCATIONS = dict(
bazel_skylib = dict(
sha256 = BAZEL_SKYLIB_SHA256,
Expand Down Expand Up @@ -62,4 +65,9 @@ REPOSITORY_LOCATIONS = dict(
strip_prefix = "kafka-2.2.0-rc2/clients/src/main/resources/common/message",
urls = ["https://github.com/apache/kafka/archive/2.2.0-rc2.zip"],
),
com_github_openzipkin_zipkinapi = dict(
sha256 = ZIPKINAPI_SHA256,
strip_prefix = "zipkin-api-" + ZIPKINAPI_RELEASE,
urls = ["https://github.com/openzipkin/zipkin-api/archive/" + ZIPKINAPI_RELEASE + ".tar.gz"],
),
)
28 changes: 27 additions & 1 deletion envoy/config/trace/v2/trace.proto
Expand Up @@ -65,6 +65,7 @@ message LightstepConfig {
string access_token_file = 2 [(validate.rules).string.min_bytes = 1];
}

// Configuration for the Zipkin tracer.
message ZipkinConfig {
// The cluster manager cluster that hosts the Zipkin collectors. Note that the
// Zipkin cluster must be defined in the :ref:`Bootstrap static cluster
Expand All @@ -80,9 +81,34 @@ message ZipkinConfig {
// trace instance. The default value is false, which will result in a 64 bit trace id being used.
bool trace_id_128bit = 3;

// Determines whether client and server spans will shared the same span id.
// Determines whether client and server spans will share the same span context.
// The default value is true.
google.protobuf.BoolValue shared_span_context = 4;

// Available Zipkin collector endpoint versions.
enum CollectorEndpointVersion {
// Zipkin API v1, JSON over HTTP.
// [#comment: The default implementation of Zipkin client before this field is added was only v1
// and the way user configure this was by not explicitly specifying the version. Consequently,
// before this is added, the corresponding Zipkin collector expected to receive v1 payload.
// Hence the motivation of adding HTTP_JSON_V1 as the default is to avoid a breaking change when
// user upgrading Envoy with this change. Furthermore, we also immediately deprecate this field,
// since in Zipkin realm this v1 version is considered to be not preferable anymore.]
HTTP_JSON_V1 = 0 [deprecated = true];

// Zipkin API v2, JSON over HTTP.
HTTP_JSON = 1;

// Zipkin API v2, protobuf over HTTP.
HTTP_PROTO = 2;

// [#not-implemented-hide:]
GRPC = 3;
}

// Determines the selected collector endpoint version. By default, the ``HTTP_JSON_V1`` will be
// used.
CollectorEndpointVersion collector_endpoint_version = 5;
}

// DynamicOtConfig is used to dynamically load a tracer from a shared library
Expand Down

0 comments on commit 4d1ee75

Please sign in to comment.