Skip to content

Commit e7c2042

Browse files
fix merge conflicts
2 parents 685787b + 1112792 commit e7c2042

File tree

20 files changed

+137
-65
lines changed

20 files changed

+137
-65
lines changed

Diff for: docs/examples/django/README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Execution of the Django app
3636

3737
Set these environment variables first:
3838

39-
#. ``export OPENTELEMETRY_PYTHON_DJANGO_INSTRUMENT=True``
39+
#. ``export OTEL_PYTHON_DJANGO_INSTRUMENT=True``
4040
#. ``export DJANGO_SETTINGS_MODULE=instrumentation_example.settings``
4141

4242
The way to achieve OpenTelemetry instrumentation for your Django app is to use

Diff for: exporter/opentelemetry-exporter-zipkin/CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Change package name to opentelemetry-exporter-zipkin
66
([#953](https://github.com/open-telemetry/opentelemetry-python/pull/953))
7+
- Add proper length zero padding to hex strings of traceId, spanId, parentId sent on the wire, for compatibility with jaeger-collector
8+
([#908](https://github.com/open-telemetry/opentelemetry-python/pull/908))
79

810
## 0.8b0
911

@@ -23,4 +25,4 @@ Released 2020-05-12
2325

2426
Released 2020-02-21
2527

26-
- Initial release
28+
- Initial release

Diff for: exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ def _translate_to_zipkin(self, spans: Sequence[Span]):
168168
duration_mus = _nsec_to_usec_round(span.end_time - span.start_time)
169169

170170
zipkin_span = {
171-
"traceId": format(trace_id, "x"),
172-
"id": format(span_id, "x"),
171+
# Ensure left-zero-padding of traceId, spanId, parentId
172+
"traceId": format(trace_id, "032x"),
173+
"id": format(span_id, "016x"),
173174
"name": span.name,
174175
"timestamp": start_timestamp_mus,
175176
"duration": duration_mus,
@@ -184,10 +185,10 @@ def _translate_to_zipkin(self, spans: Sequence[Span]):
184185

185186
if isinstance(span.parent, Span):
186187
zipkin_span["parentId"] = format(
187-
span.parent.get_context().span_id, "x"
188+
span.parent.get_context().span_id, "016x"
188189
)
189190
elif isinstance(span.parent, SpanContext):
190-
zipkin_span["parentId"] = format(span.parent.span_id, "x")
191+
zipkin_span["parentId"] = format(span.parent.span_id, "016x")
191192

192193
zipkin_spans.append(zipkin_span)
193194
return zipkin_spans

Diff for: exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py

+66
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,72 @@ def test_export(self):
264264
headers={"Content-Type": "application/json"},
265265
)
266266

267+
# pylint: disable=too-many-locals
268+
def test_zero_padding(self):
269+
"""test that hex ids starting with 0
270+
are properly padded to 16 or 32 hex chars
271+
when exported
272+
"""
273+
274+
span_names = "testZeroes"
275+
trace_id = 0x0E0C63257DE34C926F9EFCD03927272E
276+
span_id = 0x04BF92DEEFC58C92
277+
parent_id = 0x0AAAAAAAAAAAAAAA
278+
279+
start_time = 683647322 * 10 ** 9 # in ns
280+
duration = 50 * 10 ** 6
281+
end_time = start_time + duration
282+
283+
span_context = trace_api.SpanContext(
284+
trace_id,
285+
span_id,
286+
is_remote=False,
287+
trace_flags=TraceFlags(TraceFlags.SAMPLED),
288+
)
289+
parent_context = trace_api.SpanContext(
290+
trace_id, parent_id, is_remote=False
291+
)
292+
293+
otel_span = trace.Span(
294+
name=span_names[0], context=span_context, parent=parent_context,
295+
)
296+
297+
otel_span.start(start_time=start_time)
298+
otel_span.end(end_time=end_time)
299+
300+
service_name = "test-service"
301+
local_endpoint = {"serviceName": service_name, "port": 9411}
302+
303+
exporter = ZipkinSpanExporter(service_name)
304+
# Check traceId are properly lowercase 16 or 32 hex
305+
expected = [
306+
{
307+
"traceId": "0e0c63257de34c926f9efcd03927272e",
308+
"id": "04bf92deefc58c92",
309+
"name": span_names[0],
310+
"timestamp": start_time // 10 ** 3,
311+
"duration": duration // 10 ** 3,
312+
"localEndpoint": local_endpoint,
313+
"kind": None,
314+
"tags": {},
315+
"annotations": None,
316+
"debug": True,
317+
"parentId": "0aaaaaaaaaaaaaaa",
318+
}
319+
]
320+
321+
mock_post = MagicMock()
322+
with patch("requests.post", mock_post):
323+
mock_post.return_value = MockResponse(200)
324+
status = exporter.export([otel_span])
325+
self.assertEqual(SpanExportResult.SUCCESS, status)
326+
327+
mock_post.assert_called_with(
328+
url="http://localhost:9411/api/v2/spans",
329+
data=json.dumps(expected),
330+
headers={"Content-Type": "application/json"},
331+
)
332+
267333
@patch("requests.post")
268334
def test_invalid_response(self, mock_post):
269335
mock_post.return_value = MockResponse(404)

Diff for: ext/opentelemetry-ext-django/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Update environment variable names, prefix changed from `OPENTELEMETRY` to `OTEL` ([#904](https://github.com/open-telemetry/opentelemetry-python/pull/904))
6+
57
## Version 0.11b0
68

79
Released 2020-07-28

Diff for: ext/opentelemetry-ext-django/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Configuration
2020

2121
Exclude lists
2222
*************
23-
To exclude certain URLs from being tracked, set the environment variable ``OPENTELEMETRY_PYTHON_DJANGO_EXCLUDED_URLS`` with comma delimited regexes representing which URLs to exclude.
23+
To exclude certain URLs from being tracked, set the environment variable ``OTEL_PYTHON_DJANGO_EXCLUDED_URLS`` with comma delimited regexes representing which URLs to exclude.
2424

2525
For example,
2626

2727
::
2828

29-
export OPENTELEMETRY_PYTHON_DJANGO_EXCLUDED_URLS="client/.*/info,healthcheck"
29+
export OTEL_PYTHON_DJANGO_EXCLUDED_URLS="client/.*/info,healthcheck"
3030

3131
will exclude requests such as ``https://site/client/123/info`` and ``https://site/xyz/healthcheck``.
3232

Diff for: ext/opentelemetry-ext-django/tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717

1818
def pytest_sessionstart(session): # pylint: disable=unused-argument
19-
environ.setdefault("OPENTELEMETRY_PYTHON_DJANGO_INSTRUMENT", "True")
19+
environ.setdefault("OTEL_PYTHON_DJANGO_INSTRUMENT", "True")

Diff for: ext/opentelemetry-ext-elasticsearch/CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## Unreleased
44

5+
- Update environment variable names, prefix changed from `OPENTELEMETRY` to `OTEL` ([#904](https://github.com/open-telemetry/opentelemetry-python/pull/904))
6+
57
## Version 0.10b0
68

79
Released 2020-06-23
810

9-
- Initial release
11+
- Initial release

Diff for: ext/opentelemetry-ext-elasticsearch/src/opentelemetry/ext/elasticsearch/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
---
4141
4242
Elasticsearch instrumentation prefixes operation names with the string "Elasticsearch". This
43-
can be changed to a different string by either setting the `OPENTELEMETRY_PYTHON_ELASTICSEARCH_NAME_PREFIX`
43+
can be changed to a different string by either setting the `OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX`
4444
environment variable or by passing the prefix as an argument to the instrumentor. For example,
4545
4646
@@ -88,8 +88,7 @@ class ElasticsearchInstrumentor(BaseInstrumentor):
8888
def __init__(self, span_name_prefix=None):
8989
if not span_name_prefix:
9090
span_name_prefix = environ.get(
91-
"OPENTELEMETRY_PYTHON_ELASTICSEARCH_NAME_PREFIX",
92-
"Elasticsearch",
91+
"OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX", "Elasticsearch",
9392
)
9493
self._span_name_prefix = span_name_prefix.strip()
9594
super().__init__()

Diff for: ext/opentelemetry-ext-elasticsearch/tests/test_elasticsearch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_prefix_arg(self, request_mock):
9595

9696
def test_prefix_env(self, request_mock):
9797
prefix = "prefix-from-args"
98-
env_var = "OPENTELEMETRY_PYTHON_ELASTICSEARCH_NAME_PREFIX"
98+
env_var = "OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX"
9999
os.environ[env_var] = prefix
100100
ElasticsearchInstrumentor().uninstrument()
101101
ElasticsearchInstrumentor().instrument()

Diff for: ext/opentelemetry-ext-flask/CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Unreleased
44

5-
## Version 0.11b0
5+
- Update environment variable names, prefix changed from `OPENTELEMETRY` to `OTEL` ([#904](https://github.com/open-telemetry/opentelemetry-python/pull/904))
66

7-
Released 2020-07-28
7+
## Version 0.11b0
88

99
- Use one general exclude list instead of two ([#872](https://github.com/open-telemetry/opentelemetry-python/pull/872))
1010

Diff for: ext/opentelemetry-ext-flask/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Configuration
2121

2222
Exclude lists
2323
*************
24-
To exclude certain URLs from being tracked, set the environment variable ``OPENTELEMETRY_PYTHON_FLASK_EXCLUDED_URLS`` with comma delimited regexes representing which URLs to exclude.
24+
To exclude certain URLs from being tracked, set the environment variable ``OTEL_PYTHON_FLASK_EXCLUDED_URLS`` with comma delimited regexes representing which URLs to exclude.
2525

2626
For example,
2727

2828
::
2929

30-
export OPENTELEMETRY_PYTHON_FLASK_EXCLUDED_URLS="client/.*/info,healthcheck"
30+
export OTEL_PYTHON_FLASK_EXCLUDED_URLS="client/.*/info,healthcheck"
3131

3232
will exclude requests such as ``https://site/client/123/info`` and ``https://site/xyz/healthcheck``.
3333

Diff for: ext/opentelemetry-ext-pyramid/CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
## Unreleased
44

5-
## Version 0.11b0
5+
- Update environment variable names, prefix changed from `OPENTELEMETRY` to `OTEL` ([#904](https://github.com/open-telemetry/opentelemetry-python/pull/904))
66

7-
Released 2020-07-28
7+
## Version 0.11b0
88

99
- Use one general exclude list instead of two ([#872](https://github.com/open-telemetry/opentelemetry-python/pull/872))
1010

1111
## 0.9b0
1212

1313
Released 2020-06-10
1414

15-
- Initial release
15+
- Initial release

Diff for: ext/opentelemetry-ext-pyramid/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Installation
1515

1616
Exclude lists
1717
*************
18-
To exclude certain URLs from being tracked, set the environment variable ``OPENTELEMETRY_PYTHON_PYRAMID_EXCLUDED_URLS`` with comma delimited regexes representing which URLs to exclude.
18+
To exclude certain URLs from being tracked, set the environment variable ``OTEL_PYTHON_PYRAMID_EXCLUDED_URLS`` with comma delimited regexes representing which URLs to exclude.
1919

2020
For example,
2121

2222
::
2323

24-
export OPENTELEMETRY_PYTHON_PYRAMID_EXCLUDED_URLS="client/.*/info,healthcheck"
24+
export OTEL_PYTHON_PYRAMID_EXCLUDED_URLS="client/.*/info,healthcheck"
2525

2626
will exclude requests such as ``https://site/client/123/info`` and ``https://site/xyz/healthcheck``.
2727

Diff for: opentelemetry-api/CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## Unreleased
44

5-
## Version 0.11b0
5+
- Update environment variable names, prefix changed from `OPENTELEMETRY` to `OTEL`
6+
([#904](https://github.com/open-telemetry/opentelemetry-python/pull/904))
67

7-
Released 2020-07-28
8+
## Version 0.11b0
89

910
- Return INVALID_SPAN if no TracerProvider set for get_current_span
1011
([#751](https://github.com/open-telemetry/opentelemetry-python/pull/751))

Diff for: opentelemetry-api/src/opentelemetry/configuration/__init__.py

+19-18
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,33 @@
1616
Simple configuration manager
1717
1818
This is a configuration manager for OpenTelemetry. It reads configuration
19-
values from environment variables prefixed with ``OPENTELEMETRY_PYTHON_`` whose
20-
characters are only alphanumeric characters and unserscores, except for the
21-
first character after ``OPENTELEMETRY_PYTHON_`` which must not be a number.
19+
values from environment variables prefixed with ``OTEL_`` (for environment
20+
variables that apply to any OpenTelemetry implementation) or with
21+
``OTEL_PYTHON_`` (for environment variables that are specific to the Python
22+
implementation of OpenTelemetry) whose characters are only alphanumeric
23+
characters and unserscores, except for the first character after ``OTEL_`` or
24+
``OTEL_PYTHON_`` which must not be a number.
2225
2326
For example, these environment variables will be read:
2427
25-
1. ``OPENTELEMETRY_PYTHON_SOMETHING``
26-
2. ``OPENTELEMETRY_PYTHON_SOMETHING_ELSE_``
27-
3. ``OPENTELEMETRY_PYTHON_SOMETHING_ELSE_AND__ELSE``
28-
4. ``OPENTELEMETRY_PYTHON_SOMETHING_ELSE_AND_else``
29-
5. ``OPENTELEMETRY_PYTHON_SOMETHING_ELSE_AND_else2``
28+
1. ``OTEL_SOMETHING``
29+
2. ``OTEL_SOMETHING_ELSE_``
30+
3. ``OTEL_SOMETHING_ELSE_AND__ELSE``
31+
4. ``OTEL_SOMETHING_ELSE_AND_else``
32+
5. ``OTEL_SOMETHING_ELSE_AND_else2``
3033
3134
These won't:
3235
3336
1. ``OPENTELEMETRY_PYTH_SOMETHING``
34-
2. ``OPENTELEMETRY_PYTHON_2_SOMETHING_AND__ELSE``
35-
3. ``OPENTELEMETRY_PYTHON_SOMETHING_%_ELSE``
37+
2. ``OTEL_2_SOMETHING_AND__ELSE``
38+
3. ``OTEL_SOMETHING_%_ELSE``
3639
3740
The values stored in the environment variables can be found in an instance of
3841
``opentelemetry.configuration.Configuration``. This class can be instantiated
3942
freely because instantiating it returns always the same object.
4043
4144
For example, if the environment variable
42-
``OPENTELEMETRY_PYTHON_METER_PROVIDER`` value is ``my_meter_provider``, then
45+
``OTEL_PYTHON_METER_PROVIDER`` value is ``my_meter_provider``, then
4346
``Configuration().meter_provider == "my_meter_provider"`` would be ``True``.
4447
4548
Non defined attributes will always return ``None``. This is intended to make it
@@ -49,8 +52,8 @@
4952
Environment variables used by OpenTelemetry
5053
-------------------------------------------
5154
52-
1. OPENTELEMETRY_PYTHON_METER_PROVIDER
53-
2. OPENTELEMETRY_PYTHON_TRACER_PROVIDER
55+
1. OTEL_PYTHON_METER_PROVIDER
56+
2. OTEL_PYTHON_TRACER_PROVIDER
5457
5558
The value of these environment variables should be the name of the entry point
5659
that points to the class that implements either provider. This OpenTelemetry
@@ -70,7 +73,7 @@
7073
}
7174
7275
To use the meter provider above, then the
73-
``OPENTELEMETRY_PYTHON_METER_PROVIDER`` should be set to
76+
``OTEL_PYTHON_METER_PROVIDER`` should be set to
7477
``"default_meter_provider"`` (this is not actually necessary since the
7578
OpenTelemetry API provided providers are the default ones used if no
7679
configuration is found in the environment variables).
@@ -110,13 +113,11 @@ def __new__(cls) -> "Configuration":
110113
instance = super().__new__(cls)
111114
for key, value_str in environ.items():
112115

113-
match = fullmatch(
114-
r"OPENTELEMETRY_PYTHON_([A-Za-z_][\w_]*)", key
115-
)
116+
match = fullmatch(r"OTEL_(PYTHON_)?([A-Za-z_][\w_]*)", key)
116117

117118
if match is not None:
118119

119-
key = match.group(1)
120+
key = match.group(2)
120121
value = value_str # type: ConfigValue
121122

122123
if value_str == "True":

Diff for: opentelemetry-api/src/opentelemetry/context/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def wrapper(
5555
default_context = "contextvars_context"
5656

5757
configured_context = environ.get(
58-
"OPENTELEMETRY_CONTEXT", default_context
58+
"OTEL_CONTEXT", default_context
5959
) # type: str
6060
try:
6161
_RUNTIME_CONTEXT = next(

0 commit comments

Comments
 (0)