Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51cfe76

Browse files
ext/jaeger: fix exporting to collector (open-telemetry#508)
The exporting of traces to the collector is broken, it replies with the "Unable to process request body: Required field Process is not set" error. The current implementation is based on OpenCensus [1], what appears to be broken too, it's not totally clear at this time what's wrong with that. This commit changes the exporting logic to be similar to the opentelemetry-go [2] one that is working. The main change is to perform the request directly without using the client provided by the generated files. [1] https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-jaeger [2] https://github.com/open-telemetry/opentelemetry-go/blob/master/exporters/trace/jaeger/jaeger.go
1 parent 490f2cf commit 51cfe76

File tree

1 file changed

+14
-27
lines changed
  • ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger

1 file changed

+14
-27
lines changed

ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/__init__.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -388,23 +388,15 @@ class Collector:
388388
Args:
389389
thrift_url: URL of the Jaeger HTTP Thrift.
390390
auth: Auth tuple that contains username and password for Basic Auth.
391-
client: Class for creating a Jaeger collector client.
392-
http_transport: Class for creating new client for Thrift HTTP server.
393391
"""
394392

395-
def __init__(
396-
self,
397-
thrift_url="",
398-
auth=None,
399-
client=jaeger.Client,
400-
http_transport=THttpClient.THttpClient,
401-
):
393+
def __init__(self, thrift_url="", auth=None):
402394
self.thrift_url = thrift_url
403395
self.auth = auth
404-
self.http_transport = http_transport(uri_or_host=thrift_url)
405-
self.client = client(
406-
iprot=TBinaryProtocol.TBinaryProtocol(trans=self.http_transport)
396+
self.http_transport = THttpClient.THttpClient(
397+
uri_or_host=self.thrift_url
407398
)
399+
self.protocol = TBinaryProtocol.TBinaryProtocol(self.http_transport)
408400

409401
# set basic auth header
410402
if auth is not None:
@@ -419,18 +411,13 @@ def submit(self, batch: jaeger.Batch):
419411
Args:
420412
batch: Object to emit Jaeger spans.
421413
"""
422-
try:
423-
self.client.submitBatches([batch])
424-
# it will call http_transport.flush() and
425-
# status code and message will be updated
426-
code = self.http_transport.code
427-
msg = self.http_transport.message
428-
if code >= 300 or code < 200:
429-
logger.error(
430-
"Traces cannot be uploaded; HTTP status code: %s, message %s",
431-
code,
432-
msg,
433-
)
434-
finally:
435-
if self.http_transport.isOpen():
436-
self.http_transport.close()
414+
batch.write(self.protocol)
415+
self.http_transport.flush()
416+
code = self.http_transport.code
417+
msg = self.http_transport.message
418+
if code >= 300 or code < 200:
419+
logger.error(
420+
"Traces cannot be uploaded; HTTP status code: %s, message: %s",
421+
code,
422+
msg,
423+
)

0 commit comments

Comments
 (0)