Skip to content

Commit

Permalink
Add protobuf via gRPC exporting support for Jaeger (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Jan 4, 2021
1 parent 8ebd6c8 commit bd8db6e
Show file tree
Hide file tree
Showing 26 changed files with 5,308 additions and 328 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v0.16b1...HEAD)

- Add protobuf via gRPC exporting support for Jaeger
([#1471](https://github.com/open-telemetry/opentelemetry-python/pull/1471))

- Add support for Python 3.9
([#1441](https://github.com/open-telemetry/opentelemetry-python/pull/1441))

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"aiohttp": ("https://aiohttp.readthedocs.io/en/stable/", None),
"wrapt": ("https://wrapt.readthedocs.io/en/latest/", None),
"pymongo": ("https://pymongo.readthedocs.io/en/stable/", None),
"grpc": ("https://grpc.github.io/grpc/python/", None),
}

# http://www.sphinx-doc.org/en/master/config.html#confval-nitpicky
Expand Down
10 changes: 10 additions & 0 deletions docs/exporter/jaeger/jaeger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ Submodules
:members:
:undoc-members:
:show-inheritance:

.. automodule:: opentelemetry.exporter.jaeger.send.thrift
:members:
:undoc-members:
:show-inheritance:

.. automodule:: opentelemetry.exporter.jaeger.gen.collector_pb2_grpc
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
# password=xxxx, # optional
)

# Create a JaegerSpanExporter to send spans with gRPC
# If there is no encryption or authentication set `insecure` to True
# If server has authentication with SSL/TLS you can set the
# parameter credentials=ChannelCredentials(...) or the environment variable
# `EXPORTER_JAEGER_CERTIFICATE` with file containing creds.

# jaeger_exporter = jaeger.JaegerSpanExporter(
# service_name="my-helloworld-service",
# collector_endpoint="localhost:14250",
# insecure=True,
# transport_format="protobuf",
# )

# create a BatchExportSpanProcessor and add the exporter to it
span_processor = BatchExportSpanProcessor(jaeger_exporter)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (c) 2019 The Jaeger Authors.
// Copyright (c) 2018 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax="proto3";

package jaeger.api_v2;

import "model.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "protoc-gen-swagger/options/annotations.proto";

option go_package = "api_v2";
option java_package = "io.jaegertracing.api_v2";

// Enable gogoprotobuf extensions (https://github.com/gogo/protobuf/blob/master/extensions.md).
// Enable custom Marshal method.
option (gogoproto.marshaler_all) = true;
// Enable custom Unmarshal method.
option (gogoproto.unmarshaler_all) = true;
// Enable custom Size method (Required by Marshal and Unmarshal).
option (gogoproto.sizer_all) = true;
// Enable registration with golang/protobuf for the grpc-gateway.
option (gogoproto.goproto_registration) = true;

option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
info: {
version: "1.0";
};
external_docs: {
url: "https://github.com/jaegertracing/jaeger";
description: "Jaeger API";
}
schemes: HTTP;
schemes: HTTPS;
};

message PostSpansRequest {
Batch batch = 1 [
(gogoproto.nullable) = false
];
}

message PostSpansResponse {
}

service CollectorService {
rpc PostSpans(PostSpansRequest) returns (PostSpansResponse) {
option (google.api.http) = {
post: "/api/v2/spans"
body: "*"
};
}
}
166 changes: 166 additions & 0 deletions exporter/opentelemetry-exporter-jaeger/proto/api_v2/model.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// Copyright (c) 2018 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax="proto3";

package jaeger.api_v2;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";

// TODO: document all types and fields

// TODO: once this moves to jaeger-idl repo, we may want to change Go pkg to api_v2
// and rewrite it to model only in this repo. That should make it easier to generate
// classes in other languages.
option go_package = "model";
option java_package = "io.jaegertracing.api_v2";

// Enable gogoprotobuf extensions (https://github.com/gogo/protobuf/blob/master/extensions.md).
// Enable custom Marshal method.
option (gogoproto.marshaler_all) = true;
// Enable custom Unmarshal method.
option (gogoproto.unmarshaler_all) = true;
// Enable custom Size method (Required by Marshal and Unmarshal).
option (gogoproto.sizer_all) = true;
// Enable registration with golang/protobuf for the grpc-gateway.
option (gogoproto.goproto_registration) = true;

enum ValueType {
STRING = 0;
BOOL = 1;
INT64 = 2;
FLOAT64 = 3;
BINARY = 4;
};

message KeyValue {
option (gogoproto.equal) = true;
option (gogoproto.compare) = true;

string key = 1;
ValueType v_type = 2;
string v_str = 3;
bool v_bool = 4;
int64 v_int64 = 5;
double v_float64 = 6;
bytes v_binary = 7;
}

message Log {
google.protobuf.Timestamp timestamp = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
repeated KeyValue fields = 2 [
(gogoproto.nullable) = false
];
}

enum SpanRefType {
CHILD_OF = 0;
FOLLOWS_FROM = 1;
};

message SpanRef {
bytes trace_id = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "TraceID",
(gogoproto.customname) = "TraceID"
];
bytes span_id = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "SpanID",
(gogoproto.customname) = "SpanID"
];
SpanRefType ref_type = 3;
}

message Process {
string service_name = 1;
repeated KeyValue tags = 2 [
(gogoproto.nullable) = false
];
}

message Span {
bytes trace_id = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "TraceID",
(gogoproto.customname) = "TraceID"
];
bytes span_id = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "SpanID",
(gogoproto.customname) = "SpanID"
];
string operation_name = 3;
repeated SpanRef references = 4 [
(gogoproto.nullable) = false
];
uint32 flags = 5 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "Flags"
];
google.protobuf.Timestamp start_time = 6 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
google.protobuf.Duration duration = 7 [
(gogoproto.stdduration) = true,
(gogoproto.nullable) = false
];
repeated KeyValue tags = 8 [
(gogoproto.nullable) = false
];
repeated Log logs = 9 [
(gogoproto.nullable) = false
];
Process process = 10;
string process_id = 11 [
(gogoproto.customname) = "ProcessID"
];
repeated string warnings = 12;
}

message Trace {
message ProcessMapping {
string process_id = 1 [
(gogoproto.customname) = "ProcessID"
];
Process process = 2 [
(gogoproto.nullable) = false
];
}
repeated Span spans = 1;
repeated ProcessMapping process_map = 2 [
(gogoproto.nullable) = false
];
repeated string warnings = 3;
}

message Batch {
repeated Span spans = 1;
Process process = 2 [
(gogoproto.nullable) = true
];
}

message DependencyLink {
string parent = 1;
string child = 2;
uint64 call_count = 3;
string source = 4;
}
2 changes: 2 additions & 0 deletions exporter/opentelemetry-exporter-jaeger/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ package_dir=
=src
packages=find_namespace:
install_requires =
grpcio >= 1.0.0, < 2.0.0
googleapis-common-protos ~= 1.52.0
thrift >= 0.10.0
opentelemetry-api == 0.17.dev0
opentelemetry-sdk == 0.17.dev0
Expand Down
Loading

0 comments on commit bd8db6e

Please sign in to comment.