Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ setting in ``settings.py``:
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
'ZIPKIN_EXPORTER_PORT': 9411,
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
}


Expand Down
1 change: 1 addition & 0 deletions docs/trace/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ setting in ``settings.py``:
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
'ZIPKIN_EXPORTER_PORT': 9411,
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
}


Expand Down
9 changes: 8 additions & 1 deletion opencensus/trace/exporters/zipkin_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
DEFAULT_ENDPOINT = '/api/v2/spans'
DEFAULT_HOST_NAME = 'localhost'
DEFAULT_PORT = 9411
DEFAULT_PROTOCOL = 'http'
ZIPKIN_HEADERS = {'Content-Type': 'application/json'}

ISO_DATETIME_REGEX = '%Y-%m-%dT%H:%M:%S.%fZ'
Expand Down Expand Up @@ -59,6 +60,9 @@ class ZipkinExporter(base.Exporter):
:type end_point: str
:param end_point: (Optional) The path for the span exporting endpoint.

:type protocol: str
:param protocol: (Optional) The protocol used for the request.

:type transport: :class:`type`
:param transport: Class for creating new transport objects. It should
extend from the base :class:`.Transport` type and
Expand All @@ -73,21 +77,24 @@ def __init__(
host_name=DEFAULT_HOST_NAME,
port=DEFAULT_PORT,
endpoint=DEFAULT_ENDPOINT,
protocol=DEFAULT_PROTOCOL,
transport=sync.SyncTransport,
ipv4=None,
ipv6=None):
self.service_name = service_name
self.host_name = host_name
self.port = port
self.endpoint = endpoint
self.protocol = protocol
self.url = self.get_url
self.transport = transport(self)
self.ipv4 = ipv4
self.ipv6 = ipv6

@property
def get_url(self):
return 'http://{}:{}{}'.format(
return '{}://{}:{}{}'.format(
self.protocol,
self.host_name,
self.port,
self.endpoint)
Expand Down
1 change: 1 addition & 0 deletions opencensus/trace/ext/django/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
'ZIPKIN_EXPORTER_PORT': 9411,
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
'TRANSPORT': 'opencensus.trace.exporters.transports.sync.SyncTransport',
}

Expand Down
4 changes: 4 additions & 0 deletions opencensus/trace/ext/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
ZIPKIN_EXPORTER_SERVICE_NAME = 'ZIPKIN_EXPORTER_SERVICE_NAME'
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
ZIPKIN_EXPORTER_PROTOCOL = 'ZIPKIN_EXPORTER_PROTOCOL'


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -126,10 +127,13 @@ def __init__(self, get_response=None):
ZIPKIN_EXPORTER_HOST_NAME, 'localhost')
_zipkin_port = settings.params.get(
ZIPKIN_EXPORTER_PORT, 9411)
_zipkin_protocol = settings.params.get(
ZIPKIN_EXPORTER_PROTOCOL, 'http')
self.exporter = self._exporter(
service_name=_zipkin_service_name,
host_name=_zipkin_host_name,
port=_zipkin_port,
protocol=_zipkin_protocol,
transport=transport)
else:
self.exporter = self._exporter(transport=transport)
Expand Down
4 changes: 4 additions & 0 deletions opencensus/trace/ext/flask/flask_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ZIPKIN_EXPORTER_SERVICE_NAME = 'ZIPKIN_EXPORTER_SERVICE_NAME'
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
ZIPKIN_EXPORTER_PROTOCOL = 'ZIPKIN_EXPORTER_PROTOCOL'

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -138,10 +139,13 @@ def init_app(self, app):
ZIPKIN_EXPORTER_HOST_NAME, 'localhost')
_zipkin_port = params.get(
ZIPKIN_EXPORTER_PORT, 9411)
_zipkin_protocol = params.get(
ZIPKIN_EXPORTER_PROTOCOL, 'http')
self.exporter = self.exporter(
service_name=_zipkin_service_name,
host_name=_zipkin_host_name,
port=_zipkin_port,
protocol=_zipkin_protocol,
transport=transport)
else:
self.exporter = self.exporter(transport=transport)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/trace/ext/django/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test__set_default_configs(self):
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
'ZIPKIN_EXPORTER_PORT': 9411,
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
'TRANSPORT':
'opencensus.trace.exporters.transports.sync.SyncTransport',
}
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/trace/ext/django/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ def test_constructor_zipkin(self):
service_name = 'test_service'
host_name = 'test_hostname'
port = 2333
protocol = 'http'
params = {
'ZIPKIN_EXPORTER_SERVICE_NAME': service_name,
'ZIPKIN_EXPORTER_HOST_NAME': host_name,
'ZIPKIN_EXPORTER_PORT': port,
'ZIPKIN_EXPORTER_PROTOCOL': protocol,
'TRANSPORT':
'opencensus.trace.exporters.transports.sync.SyncTransport',
}
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/trace/ext/flask/test_flask_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def test_init_app_config_stackdriver_exporter(self):
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
'ZIPKIN_EXPORTER_PORT': 9411,
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this not require to be set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of them are required, they all have defaults in opencensus/trace/exporters/zipkin_exporter.py and opencensus/trace/ext/flask/flask_middleware.py. I thought it was better to follow what was done with the others.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good then.

},
}

Expand Down Expand Up @@ -145,6 +146,7 @@ def test_init_app_config_zipkin_exporter(self):
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
'ZIPKIN_EXPORTER_PORT': 9411,
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
},
}

Expand Down