Skip to content

Commit

Permalink
ext/jaeger: fix exporting to collector (#508)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mauriciovasquezbernal authored Mar 28, 2020
1 parent 490f2cf commit 51cfe76
Showing 1 changed file with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,23 +388,15 @@ class Collector:
Args:
thrift_url: URL of the Jaeger HTTP Thrift.
auth: Auth tuple that contains username and password for Basic Auth.
client: Class for creating a Jaeger collector client.
http_transport: Class for creating new client for Thrift HTTP server.
"""

def __init__(
self,
thrift_url="",
auth=None,
client=jaeger.Client,
http_transport=THttpClient.THttpClient,
):
def __init__(self, thrift_url="", auth=None):
self.thrift_url = thrift_url
self.auth = auth
self.http_transport = http_transport(uri_or_host=thrift_url)
self.client = client(
iprot=TBinaryProtocol.TBinaryProtocol(trans=self.http_transport)
self.http_transport = THttpClient.THttpClient(
uri_or_host=self.thrift_url
)
self.protocol = TBinaryProtocol.TBinaryProtocol(self.http_transport)

# set basic auth header
if auth is not None:
Expand All @@ -419,18 +411,13 @@ def submit(self, batch: jaeger.Batch):
Args:
batch: Object to emit Jaeger spans.
"""
try:
self.client.submitBatches([batch])
# it will call http_transport.flush() and
# status code and message will be updated
code = self.http_transport.code
msg = self.http_transport.message
if code >= 300 or code < 200:
logger.error(
"Traces cannot be uploaded; HTTP status code: %s, message %s",
code,
msg,
)
finally:
if self.http_transport.isOpen():
self.http_transport.close()
batch.write(self.protocol)
self.http_transport.flush()
code = self.http_transport.code
msg = self.http_transport.message
if code >= 300 or code < 200:
logger.error(
"Traces cannot be uploaded; HTTP status code: %s, message: %s",
code,
msg,
)

0 comments on commit 51cfe76

Please sign in to comment.