Add protocol as an argument to the Jaeger exporter constructor (#978)

This commit is contained in:
bitspradp 2020-08-13 18:30:18 +01:00 committed by alrex
parent 90af26d8ed
commit a10220b368
3 changed files with 18 additions and 4 deletions

View File

@ -5,6 +5,9 @@
- Change package name to opentelemetry-exporter-jaeger - Change package name to opentelemetry-exporter-jaeger
([#953](https://github.com/open-telemetry/opentelemetry-python/pull/953)) ([#953](https://github.com/open-telemetry/opentelemetry-python/pull/953))
- Thrift URL for Jaeger exporter doesn't allow HTTPS (hardcoded to HTTP)
([#978] (https://github.com/open-telemetry/opentelemetry-python/pull/978))
## 0.8b0 ## 0.8b0
Released 2020-05-27 Released 2020-05-27

View File

@ -42,6 +42,7 @@ Usage
# collector_host_name='localhost', # collector_host_name='localhost',
# collector_port=14268, # collector_port=14268,
# collector_endpoint='/api/traces?format=jaeger.thrift', # collector_endpoint='/api/traces?format=jaeger.thrift',
# collector_protocol='http',
# username=xxxx, # optional # username=xxxx, # optional
# password=xxxx, # optional # password=xxxx, # optional
) )
@ -77,6 +78,7 @@ from opentelemetry.trace.status import StatusCanonicalCode
DEFAULT_AGENT_HOST_NAME = "localhost" DEFAULT_AGENT_HOST_NAME = "localhost"
DEFAULT_AGENT_PORT = 6831 DEFAULT_AGENT_PORT = 6831
DEFAULT_COLLECTOR_ENDPOINT = "/api/traces?format=jaeger.thrift" DEFAULT_COLLECTOR_ENDPOINT = "/api/traces?format=jaeger.thrift"
DEFAULT_COLLECTOR_PROTOCOL = "http"
UDP_PACKET_MAX_LENGTH = 65000 UDP_PACKET_MAX_LENGTH = 65000
@ -91,10 +93,11 @@ class JaegerSpanExporter(SpanExporter):
when query for spans. when query for spans.
agent_host_name: The host name of the Jaeger-Agent. agent_host_name: The host name of the Jaeger-Agent.
agent_port: The port of the Jaeger-Agent. agent_port: The port of the Jaeger-Agent.
collector_host_name: The host name of the Jaeger-Collector HTTP collector_host_name: The host name of the Jaeger-Collector HTTP/HTTPS
Thrift. Thrift.
collector_port: The port of the Jaeger-Collector HTTP Thrift. collector_port: The port of the Jaeger-Collector HTTP/HTTPS Thrift.
collector_endpoint: The endpoint of the Jaeger-Collector HTTP Thrift. collector_endpoint: The endpoint of the Jaeger-Collector HTTP/HTTPS Thrift.
collector_protocol: The transfer protocol for the Jaeger-Collector(HTTP or HTTPS).
username: The user name of the Basic Auth if authentication is username: The user name of the Basic Auth if authentication is
required. required.
password: The password of the Basic Auth if authentication is password: The password of the Basic Auth if authentication is
@ -109,6 +112,7 @@ class JaegerSpanExporter(SpanExporter):
collector_host_name=None, collector_host_name=None,
collector_port=None, collector_port=None,
collector_endpoint=DEFAULT_COLLECTOR_ENDPOINT, collector_endpoint=DEFAULT_COLLECTOR_ENDPOINT,
collector_protocol=DEFAULT_COLLECTOR_PROTOCOL,
username=None, username=None,
password=None, password=None,
): ):
@ -119,6 +123,7 @@ class JaegerSpanExporter(SpanExporter):
self.collector_host_name = collector_host_name self.collector_host_name = collector_host_name
self.collector_port = collector_port self.collector_port = collector_port
self.collector_endpoint = collector_endpoint self.collector_endpoint = collector_endpoint
self.collector_protocol = collector_protocol
self.username = username self.username = username
self.password = password self.password = password
self._collector = None self._collector = None
@ -139,7 +144,8 @@ class JaegerSpanExporter(SpanExporter):
if self.collector_host_name is None or self.collector_port is None: if self.collector_host_name is None or self.collector_port is None:
return None return None
thrift_url = "http://{}:{}{}".format( thrift_url = "{}://{}:{}{}".format(
self.collector_protocol,
self.collector_host_name, self.collector_host_name,
self.collector_port, self.collector_port,
self.collector_endpoint, self.collector_endpoint,

View File

@ -46,6 +46,7 @@ class TestJaegerSpanExporter(unittest.TestCase):
thrift_port = None thrift_port = None
agent_port = 6831 agent_port = 6831
collector_endpoint = "/api/traces?format=jaeger.thrift" collector_endpoint = "/api/traces?format=jaeger.thrift"
collector_protocol = "http"
exporter = jaeger_exporter.JaegerSpanExporter(service_name) exporter = jaeger_exporter.JaegerSpanExporter(service_name)
self.assertEqual(exporter.service_name, service_name) self.assertEqual(exporter.service_name, service_name)
@ -53,6 +54,7 @@ class TestJaegerSpanExporter(unittest.TestCase):
self.assertEqual(exporter.agent_host_name, host_name) self.assertEqual(exporter.agent_host_name, host_name)
self.assertEqual(exporter.agent_port, agent_port) self.assertEqual(exporter.agent_port, agent_port)
self.assertEqual(exporter.collector_port, thrift_port) self.assertEqual(exporter.collector_port, thrift_port)
self.assertEqual(exporter.collector_protocol, collector_protocol)
self.assertEqual(exporter.collector_endpoint, collector_endpoint) self.assertEqual(exporter.collector_endpoint, collector_endpoint)
self.assertEqual(exporter.username, None) self.assertEqual(exporter.username, None)
self.assertEqual(exporter.password, None) self.assertEqual(exporter.password, None)
@ -65,6 +67,7 @@ class TestJaegerSpanExporter(unittest.TestCase):
collector_host_name = "opentelemetry.io" collector_host_name = "opentelemetry.io"
collector_port = 15875 collector_port = 15875
collector_endpoint = "/myapi/traces?format=jaeger.thrift" collector_endpoint = "/myapi/traces?format=jaeger.thrift"
collector_protocol = "https"
agent_port = 14268 agent_port = 14268
agent_host_name = "opentelemetry.io" agent_host_name = "opentelemetry.io"
@ -78,6 +81,7 @@ class TestJaegerSpanExporter(unittest.TestCase):
collector_host_name=collector_host_name, collector_host_name=collector_host_name,
collector_port=collector_port, collector_port=collector_port,
collector_endpoint=collector_endpoint, collector_endpoint=collector_endpoint,
collector_protocol="https",
agent_host_name=agent_host_name, agent_host_name=agent_host_name,
agent_port=agent_port, agent_port=agent_port,
username=username, username=username,
@ -88,6 +92,7 @@ class TestJaegerSpanExporter(unittest.TestCase):
self.assertEqual(exporter.agent_port, agent_port) self.assertEqual(exporter.agent_port, agent_port)
self.assertEqual(exporter.collector_host_name, collector_host_name) self.assertEqual(exporter.collector_host_name, collector_host_name)
self.assertEqual(exporter.collector_port, collector_port) self.assertEqual(exporter.collector_port, collector_port)
self.assertEqual(exporter.collector_protocol, collector_protocol)
self.assertTrue(exporter.collector is not None) self.assertTrue(exporter.collector is not None)
self.assertEqual(exporter.collector.auth, auth) self.assertEqual(exporter.collector.auth, auth)
# property should not construct new object # property should not construct new object