Skip to content

Commit bd8db6e

Browse files
authored
Add protobuf via gRPC exporting support for Jaeger (open-telemetry#1471)
1 parent 8ebd6c8 commit bd8db6e

File tree

26 files changed

+5308
-328
lines changed

26 files changed

+5308
-328
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

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

9+
- Add protobuf via gRPC exporting support for Jaeger
10+
([#1471](https://github.com/open-telemetry/opentelemetry-python/pull/1471))
11+
912
- Add support for Python 3.9
1013
([#1441](https://github.com/open-telemetry/opentelemetry-python/pull/1441))
1114

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"aiohttp": ("https://aiohttp.readthedocs.io/en/stable/", None),
8787
"wrapt": ("https://wrapt.readthedocs.io/en/latest/", None),
8888
"pymongo": ("https://pymongo.readthedocs.io/en/stable/", None),
89+
"grpc": ("https://grpc.github.io/grpc/python/", None),
8990
}
9091

9192
# http://www.sphinx-doc.org/en/master/config.html#confval-nitpicky

docs/exporter/jaeger/jaeger.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ Submodules
1414
:members:
1515
:undoc-members:
1616
:show-inheritance:
17+
18+
.. automodule:: opentelemetry.exporter.jaeger.send.thrift
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
.. automodule:: opentelemetry.exporter.jaeger.gen.collector_pb2_grpc
24+
:members:
25+
:undoc-members:
26+
:show-inheritance:

exporter/opentelemetry-exporter-jaeger/examples/jaeger_exporter_example.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222
# password=xxxx, # optional
2323
)
2424

25+
# Create a JaegerSpanExporter to send spans with gRPC
26+
# If there is no encryption or authentication set `insecure` to True
27+
# If server has authentication with SSL/TLS you can set the
28+
# parameter credentials=ChannelCredentials(...) or the environment variable
29+
# `EXPORTER_JAEGER_CERTIFICATE` with file containing creds.
30+
31+
# jaeger_exporter = jaeger.JaegerSpanExporter(
32+
# service_name="my-helloworld-service",
33+
# collector_endpoint="localhost:14250",
34+
# insecure=True,
35+
# transport_format="protobuf",
36+
# )
37+
2538
# create a BatchExportSpanProcessor and add the exporter to it
2639
span_processor = BatchExportSpanProcessor(jaeger_exporter)
2740

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) 2019 The Jaeger Authors.
2+
// Copyright (c) 2018 Uber Technologies, Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
syntax="proto3";
17+
18+
package jaeger.api_v2;
19+
20+
import "model.proto";
21+
import "gogoproto/gogo.proto";
22+
import "google/api/annotations.proto";
23+
import "protoc-gen-swagger/options/annotations.proto";
24+
25+
option go_package = "api_v2";
26+
option java_package = "io.jaegertracing.api_v2";
27+
28+
// Enable gogoprotobuf extensions (https://github.com/gogo/protobuf/blob/master/extensions.md).
29+
// Enable custom Marshal method.
30+
option (gogoproto.marshaler_all) = true;
31+
// Enable custom Unmarshal method.
32+
option (gogoproto.unmarshaler_all) = true;
33+
// Enable custom Size method (Required by Marshal and Unmarshal).
34+
option (gogoproto.sizer_all) = true;
35+
// Enable registration with golang/protobuf for the grpc-gateway.
36+
option (gogoproto.goproto_registration) = true;
37+
38+
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
39+
info: {
40+
version: "1.0";
41+
};
42+
external_docs: {
43+
url: "https://github.com/jaegertracing/jaeger";
44+
description: "Jaeger API";
45+
}
46+
schemes: HTTP;
47+
schemes: HTTPS;
48+
};
49+
50+
message PostSpansRequest {
51+
Batch batch = 1 [
52+
(gogoproto.nullable) = false
53+
];
54+
}
55+
56+
message PostSpansResponse {
57+
}
58+
59+
service CollectorService {
60+
rpc PostSpans(PostSpansRequest) returns (PostSpansResponse) {
61+
option (google.api.http) = {
62+
post: "/api/v2/spans"
63+
body: "*"
64+
};
65+
}
66+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
// Copyright (c) 2018 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax="proto3";
16+
17+
package jaeger.api_v2;
18+
19+
import "gogoproto/gogo.proto";
20+
import "google/protobuf/timestamp.proto";
21+
import "google/protobuf/duration.proto";
22+
23+
// TODO: document all types and fields
24+
25+
// TODO: once this moves to jaeger-idl repo, we may want to change Go pkg to api_v2
26+
// and rewrite it to model only in this repo. That should make it easier to generate
27+
// classes in other languages.
28+
option go_package = "model";
29+
option java_package = "io.jaegertracing.api_v2";
30+
31+
// Enable gogoprotobuf extensions (https://github.com/gogo/protobuf/blob/master/extensions.md).
32+
// Enable custom Marshal method.
33+
option (gogoproto.marshaler_all) = true;
34+
// Enable custom Unmarshal method.
35+
option (gogoproto.unmarshaler_all) = true;
36+
// Enable custom Size method (Required by Marshal and Unmarshal).
37+
option (gogoproto.sizer_all) = true;
38+
// Enable registration with golang/protobuf for the grpc-gateway.
39+
option (gogoproto.goproto_registration) = true;
40+
41+
enum ValueType {
42+
STRING = 0;
43+
BOOL = 1;
44+
INT64 = 2;
45+
FLOAT64 = 3;
46+
BINARY = 4;
47+
};
48+
49+
message KeyValue {
50+
option (gogoproto.equal) = true;
51+
option (gogoproto.compare) = true;
52+
53+
string key = 1;
54+
ValueType v_type = 2;
55+
string v_str = 3;
56+
bool v_bool = 4;
57+
int64 v_int64 = 5;
58+
double v_float64 = 6;
59+
bytes v_binary = 7;
60+
}
61+
62+
message Log {
63+
google.protobuf.Timestamp timestamp = 1 [
64+
(gogoproto.stdtime) = true,
65+
(gogoproto.nullable) = false
66+
];
67+
repeated KeyValue fields = 2 [
68+
(gogoproto.nullable) = false
69+
];
70+
}
71+
72+
enum SpanRefType {
73+
CHILD_OF = 0;
74+
FOLLOWS_FROM = 1;
75+
};
76+
77+
message SpanRef {
78+
bytes trace_id = 1 [
79+
(gogoproto.nullable) = false,
80+
(gogoproto.customtype) = "TraceID",
81+
(gogoproto.customname) = "TraceID"
82+
];
83+
bytes span_id = 2 [
84+
(gogoproto.nullable) = false,
85+
(gogoproto.customtype) = "SpanID",
86+
(gogoproto.customname) = "SpanID"
87+
];
88+
SpanRefType ref_type = 3;
89+
}
90+
91+
message Process {
92+
string service_name = 1;
93+
repeated KeyValue tags = 2 [
94+
(gogoproto.nullable) = false
95+
];
96+
}
97+
98+
message Span {
99+
bytes trace_id = 1 [
100+
(gogoproto.nullable) = false,
101+
(gogoproto.customtype) = "TraceID",
102+
(gogoproto.customname) = "TraceID"
103+
];
104+
bytes span_id = 2 [
105+
(gogoproto.nullable) = false,
106+
(gogoproto.customtype) = "SpanID",
107+
(gogoproto.customname) = "SpanID"
108+
];
109+
string operation_name = 3;
110+
repeated SpanRef references = 4 [
111+
(gogoproto.nullable) = false
112+
];
113+
uint32 flags = 5 [
114+
(gogoproto.nullable) = false,
115+
(gogoproto.customtype) = "Flags"
116+
];
117+
google.protobuf.Timestamp start_time = 6 [
118+
(gogoproto.stdtime) = true,
119+
(gogoproto.nullable) = false
120+
];
121+
google.protobuf.Duration duration = 7 [
122+
(gogoproto.stdduration) = true,
123+
(gogoproto.nullable) = false
124+
];
125+
repeated KeyValue tags = 8 [
126+
(gogoproto.nullable) = false
127+
];
128+
repeated Log logs = 9 [
129+
(gogoproto.nullable) = false
130+
];
131+
Process process = 10;
132+
string process_id = 11 [
133+
(gogoproto.customname) = "ProcessID"
134+
];
135+
repeated string warnings = 12;
136+
}
137+
138+
message Trace {
139+
message ProcessMapping {
140+
string process_id = 1 [
141+
(gogoproto.customname) = "ProcessID"
142+
];
143+
Process process = 2 [
144+
(gogoproto.nullable) = false
145+
];
146+
}
147+
repeated Span spans = 1;
148+
repeated ProcessMapping process_map = 2 [
149+
(gogoproto.nullable) = false
150+
];
151+
repeated string warnings = 3;
152+
}
153+
154+
message Batch {
155+
repeated Span spans = 1;
156+
Process process = 2 [
157+
(gogoproto.nullable) = true
158+
];
159+
}
160+
161+
message DependencyLink {
162+
string parent = 1;
163+
string child = 2;
164+
uint64 call_count = 3;
165+
string source = 4;
166+
}

exporter/opentelemetry-exporter-jaeger/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ package_dir=
3939
=src
4040
packages=find_namespace:
4141
install_requires =
42+
grpcio >= 1.0.0, < 2.0.0
43+
googleapis-common-protos ~= 1.52.0
4244
thrift >= 0.10.0
4345
opentelemetry-api == 0.17.dev0
4446
opentelemetry-sdk == 0.17.dev0

0 commit comments

Comments
 (0)