Skip to content

Commit 4bfc36e

Browse files
tpyoreyang
authored andcommitted
Add Jaeger host/port settings (census-instrumentation#462)
* Add Jaeger host/port settings * Restore transport param * Add Jaeger agent/host settings to Flask middleware * Fix settings params * Add Jaeger host settings to README
1 parent 9a94bec commit 4bfc36e

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ setting in ``settings.py``:
307307
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
308308
'ZIPKIN_EXPORTER_PORT': 9411,
309309
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
310+
'JAEGER_EXPORTER_HOST_NAME': None,
311+
'JAEGER_EXPORTER_PORT': None,
312+
'JAEGER_EXPORTER_AGENT_HOST_NAME': 'localhost',
313+
'JAEGER_EXPORTER_AGENT_PORT': 6831
310314
}
311315
312316

opencensus/trace/ext/django/middleware.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
4545
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
4646
ZIPKIN_EXPORTER_PROTOCOL = 'ZIPKIN_EXPORTER_PROTOCOL'
47+
JAEGER_EXPORTER_HOST_NAME = 'JAEGER_EXPORTER_HOST_NAME'
48+
JAEGER_EXPORTER_PORT = 'JAEGER_EXPORTER_PORT'
49+
JAEGER_EXPORTER_AGENT_HOST_NAME = 'JAEGER_EXPORTER_AGENT_HOST_NAME'
50+
JAEGER_EXPORTER_AGENT_PORT = 'JAEGER_EXPORTER_AGENT_PORT'
51+
JAEGER_EXPORTER_SERVICE_NAME = 'JAEGER_EXPORTER_SERVICE_NAME'
4752
OCAGENT_TRACE_EXPORTER_ENDPOINT = 'OCAGENT_TRACE_EXPORTER_ENDPOINT'
4853
BLACKLIST_HOSTNAMES = 'BLACKLIST_HOSTNAMES'
4954

@@ -155,9 +160,23 @@ def __init__(self, get_response=None):
155160
endpoint=_endpoint,
156161
transport=transport)
157162
elif self._exporter.__name__ == 'JaegerExporter':
158-
_service_name = self._get_service_name(settings.params)
163+
_service_name = settings.params.get(
164+
JAEGER_EXPORTER_SERVICE_NAME,
165+
self._get_service_name(settings.params))
166+
_jaeger_host_name = settings.params.get(
167+
JAEGER_EXPORTER_HOST_NAME, None)
168+
_jaeger_port = settings.params.get(
169+
JAEGER_EXPORTER_PORT, None)
170+
_jaeger_agent_host_name = settings.params.get(
171+
JAEGER_EXPORTER_AGENT_HOST_NAME, 'localhost')
172+
_jaeger_agent_port = settings.params.get(
173+
JAEGER_EXPORTER_AGENT_PORT, 6831)
159174
self.exporter = self._exporter(
160175
service_name=_service_name,
176+
host_name=_jaeger_host_name,
177+
port=_jaeger_port,
178+
agent_host_name=_jaeger_agent_host_name,
179+
agent_port=_jaeger_agent_port,
161180
transport=transport)
162181
else:
163182
self.exporter = self._exporter(transport=transport)

opencensus/trace/ext/flask/flask_middleware.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@
4040
SAMPLING_RATE = 'SAMPLING_RATE'
4141
TRANSPORT = 'TRANSPORT'
4242
SERVICE_NAME = 'SERVICE_NAME'
43-
JAEGER_EXPORTER_SERVICE_NAME = 'JAEGER_EXPORTER_SERVICE_NAME'
44-
JAEGER_EXPORTER_HOST_NAME = 'JAEGER_EXPORTER_HOST_NAME'
45-
JAEGER_EXPORTER_PORT = 'JAEGER_EXPORTER_PORT'
4643
ZIPKIN_EXPORTER_SERVICE_NAME = 'ZIPKIN_EXPORTER_SERVICE_NAME'
4744
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
4845
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
4946
ZIPKIN_EXPORTER_PROTOCOL = 'ZIPKIN_EXPORTER_PROTOCOL'
47+
JAEGER_EXPORTER_HOST_NAME = 'JAEGER_EXPORTER_HOST_NAME'
48+
JAEGER_EXPORTER_PORT = 'JAEGER_EXPORTER_PORT'
49+
JAEGER_EXPORTER_AGENT_HOST_NAME = 'JAEGER_EXPORTER_AGENT_HOST_NAME'
50+
JAEGER_EXPORTER_AGENT_PORT = 'JAEGER_EXPORTER_AGENT_PORT'
51+
JAEGER_EXPORTER_SERVICE_NAME = 'JAEGER_EXPORTER_SERVICE_NAME'
5052
OCAGENT_TRACE_EXPORTER_ENDPOINT = 'OCAGENT_TRACE_EXPORTER_ENDPOINT'
5153
BLACKLIST_HOSTNAMES = 'BLACKLIST_HOSTNAMES'
5254

@@ -140,15 +142,23 @@ def init_app(self, app):
140142
project_id=_project_id,
141143
transport=transport)
142144
elif self.exporter.__name__ == 'JaegerExporter':
143-
_service_name = self._get_service_name(params)
145+
_service_name = params.get(
146+
JAEGER_EXPORTER_SERVICE_NAME,
147+
self._get_service_name(params))
144148
_jaeger_host_name = params.get(
145-
JAEGER_EXPORTER_HOST_NAME, 'localhost')
149+
JAEGER_EXPORTER_HOST_NAME, None)
146150
_jaeger_port = params.get(
147-
JAEGER_EXPORTER_PORT, 14268)
151+
JAEGER_EXPORTER_PORT, None)
152+
_jaeger_agent_host_name = params.get(
153+
JAEGER_EXPORTER_AGENT_HOST_NAME, 'localhost')
154+
_jaeger_agent_port = params.get(
155+
JAEGER_EXPORTER_AGENT_PORT, 6831)
148156
self.exporter = self.exporter(
149157
service_name=_service_name,
150158
host_name=_jaeger_host_name,
151159
port=_jaeger_port,
160+
agent_host_name=_jaeger_agent_host_name,
161+
agent_port=_jaeger_agent_port,
152162
transport=transport)
153163
elif self.exporter.__name__ == 'ZipkinExporter':
154164
_service_name = self._get_service_name(params)

0 commit comments

Comments
 (0)