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

Commit d473384

Browse files
geobeauliyanhui1228
authored andcommitted
Enable the configuration of https (#290)
1 parent eface0a commit d473384

9 files changed

Lines changed: 24 additions & 1 deletion

File tree

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ setting in ``settings.py``:
285285
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
286286
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
287287
'ZIPKIN_EXPORTER_PORT': 9411,
288+
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
288289
}
289290
290291

docs/trace/usage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ setting in ``settings.py``:
251251
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
252252
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
253253
'ZIPKIN_EXPORTER_PORT': 9411,
254+
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
254255
}
255256
256257

opencensus/trace/exporters/zipkin_exporter.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
DEFAULT_ENDPOINT = '/api/v2/spans'
2929
DEFAULT_HOST_NAME = 'localhost'
3030
DEFAULT_PORT = 9411
31+
DEFAULT_PROTOCOL = 'http'
3132
ZIPKIN_HEADERS = {'Content-Type': 'application/json'}
3233

3334
ISO_DATETIME_REGEX = '%Y-%m-%dT%H:%M:%S.%fZ'
@@ -59,6 +60,9 @@ class ZipkinExporter(base.Exporter):
5960
:type end_point: str
6061
:param end_point: (Optional) The path for the span exporting endpoint.
6162
63+
:type protocol: str
64+
:param protocol: (Optional) The protocol used for the request.
65+
6266
:type transport: :class:`type`
6367
:param transport: Class for creating new transport objects. It should
6468
extend from the base :class:`.Transport` type and
@@ -73,21 +77,24 @@ def __init__(
7377
host_name=DEFAULT_HOST_NAME,
7478
port=DEFAULT_PORT,
7579
endpoint=DEFAULT_ENDPOINT,
80+
protocol=DEFAULT_PROTOCOL,
7681
transport=sync.SyncTransport,
7782
ipv4=None,
7883
ipv6=None):
7984
self.service_name = service_name
8085
self.host_name = host_name
8186
self.port = port
8287
self.endpoint = endpoint
88+
self.protocol = protocol
8389
self.url = self.get_url
8490
self.transport = transport(self)
8591
self.ipv4 = ipv4
8692
self.ipv6 = ipv6
8793

8894
@property
8995
def get_url(self):
90-
return 'http://{}:{}{}'.format(
96+
return '{}://{}:{}{}'.format(
97+
self.protocol,
9198
self.host_name,
9299
self.port,
93100
self.endpoint)

opencensus/trace/ext/django/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
3535
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
3636
'ZIPKIN_EXPORTER_PORT': 9411,
37+
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
3738
'TRANSPORT': 'opencensus.trace.exporters.transports.sync.SyncTransport',
3839
}
3940

opencensus/trace/ext/django/middleware.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
ZIPKIN_EXPORTER_SERVICE_NAME = 'ZIPKIN_EXPORTER_SERVICE_NAME'
4242
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
4343
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
44+
ZIPKIN_EXPORTER_PROTOCOL = 'ZIPKIN_EXPORTER_PROTOCOL'
4445

4546

4647
log = logging.getLogger(__name__)
@@ -126,10 +127,13 @@ def __init__(self, get_response=None):
126127
ZIPKIN_EXPORTER_HOST_NAME, 'localhost')
127128
_zipkin_port = settings.params.get(
128129
ZIPKIN_EXPORTER_PORT, 9411)
130+
_zipkin_protocol = settings.params.get(
131+
ZIPKIN_EXPORTER_PROTOCOL, 'http')
129132
self.exporter = self._exporter(
130133
service_name=_zipkin_service_name,
131134
host_name=_zipkin_host_name,
132135
port=_zipkin_port,
136+
protocol=_zipkin_protocol,
133137
transport=transport)
134138
else:
135139
self.exporter = self._exporter(transport=transport)

opencensus/trace/ext/flask/flask_middleware.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
ZIPKIN_EXPORTER_SERVICE_NAME = 'ZIPKIN_EXPORTER_SERVICE_NAME'
4343
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
4444
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
45+
ZIPKIN_EXPORTER_PROTOCOL = 'ZIPKIN_EXPORTER_PROTOCOL'
4546

4647
log = logging.getLogger(__name__)
4748

@@ -138,10 +139,13 @@ def init_app(self, app):
138139
ZIPKIN_EXPORTER_HOST_NAME, 'localhost')
139140
_zipkin_port = params.get(
140141
ZIPKIN_EXPORTER_PORT, 9411)
142+
_zipkin_protocol = params.get(
143+
ZIPKIN_EXPORTER_PROTOCOL, 'http')
141144
self.exporter = self.exporter(
142145
service_name=_zipkin_service_name,
143146
host_name=_zipkin_host_name,
144147
port=_zipkin_port,
148+
protocol=_zipkin_protocol,
145149
transport=transport)
146150
else:
147151
self.exporter = self.exporter(transport=transport)

tests/unit/trace/ext/django/test_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def test__set_default_configs(self):
8383
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
8484
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
8585
'ZIPKIN_EXPORTER_PORT': 9411,
86+
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
8687
'TRANSPORT':
8788
'opencensus.trace.exporters.transports.sync.SyncTransport',
8889
}

tests/unit/trace/ext/django/test_middleware.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ def test_constructor_zipkin(self):
9393
service_name = 'test_service'
9494
host_name = 'test_hostname'
9595
port = 2333
96+
protocol = 'http'
9697
params = {
9798
'ZIPKIN_EXPORTER_SERVICE_NAME': service_name,
9899
'ZIPKIN_EXPORTER_HOST_NAME': host_name,
99100
'ZIPKIN_EXPORTER_PORT': port,
101+
'ZIPKIN_EXPORTER_PROTOCOL': protocol,
100102
'TRANSPORT':
101103
'opencensus.trace.exporters.transports.sync.SyncTransport',
102104
}

tests/unit/trace/ext/flask/test_flask_middleware.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def test_init_app_config_stackdriver_exporter(self):
117117
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
118118
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
119119
'ZIPKIN_EXPORTER_PORT': 9411,
120+
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
120121
},
121122
}
122123

@@ -145,6 +146,7 @@ def test_init_app_config_zipkin_exporter(self):
145146
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
146147
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
147148
'ZIPKIN_EXPORTER_PORT': 9411,
149+
'ZIPKIN_EXPORTER_PROTOCOL': 'http',
148150
},
149151
}
150152

0 commit comments

Comments
 (0)