Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 19f89e1

Browse files
authored
Fix #377 (#383)
* Fix #377 For both the Zipkin and Jaeger exporters the http.url tag was not properly getting set because both exporters expected a string. In addition, added default options for Jaeger just like Zipkin.
1 parent dd8dd65 commit 19f89e1

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

opencensus/trace/ext/flask/flask_middleware.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
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'
4346
ZIPKIN_EXPORTER_SERVICE_NAME = 'ZIPKIN_EXPORTER_SERVICE_NAME'
4447
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
4548
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
@@ -136,6 +139,17 @@ def init_app(self, app):
136139
self.exporter = self.exporter(
137140
project_id=_project_id,
138141
transport=transport)
142+
elif self.exporter.__name__ == 'JaegerExporter':
143+
_service_name = self._get_service_name(params)
144+
_jaeger_host_name = params.get(
145+
JAEGER_EXPORTER_HOST_NAME, 'localhost')
146+
_jaeger_port = params.get(
147+
JAEGER_EXPORTER_PORT, 14268)
148+
self.exporter = self.exporter(
149+
service_name=_service_name,
150+
host_name=_jaeger_host_name,
151+
port=_jaeger_port,
152+
transport=transport)
139153
elif self.exporter.__name__ == 'ZipkinExporter':
140154
_service_name = self._get_service_name(params)
141155
_zipkin_host_name = params.get(
@@ -158,11 +172,6 @@ def init_app(self, app):
158172
service_name=_service_name,
159173
endpoint=_endpoint,
160174
transport=transport)
161-
elif self.exporter.__name__ == 'JaegerExporter':
162-
_service_name = self._get_service_name(params)
163-
self.exporter = self.exporter(
164-
service_name=_service_name,
165-
transport=transport)
166175
else:
167176
self.exporter = self.exporter(transport=transport)
168177

@@ -204,7 +213,8 @@ def _before_request(self):
204213
flask.request.url)
205214
tracer.add_attribute_to_current_span(
206215
HTTP_METHOD, flask.request.method)
207-
tracer.add_attribute_to_current_span(HTTP_URL, flask.request.url)
216+
tracer.add_attribute_to_current_span(
217+
HTTP_URL, str(flask.request.url))
208218
execution_context.set_opencensus_attr(
209219
'blacklist_hostnames',
210220
self.blacklist_hostnames)

0 commit comments

Comments
 (0)