Skip to content

Commit 8c4fca5

Browse files
authored
Update environment variable names (#904)
1 parent fc58032 commit 8c4fca5

File tree

17 files changed

+63
-61
lines changed

17 files changed

+63
-61
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: 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(

Diff for: opentelemetry-api/tests/configuration/test_configuration.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def test_singleton(self) -> None:
3232
@patch.dict(
3333
"os.environ", # type: ignore
3434
{
35-
"OPENTELEMETRY_PYTHON_METER_PROVIDER": "meter_provider",
36-
"OPENTELEMETRY_PYTHON_TRACER_PROVIDER": "tracer_provider",
37-
"OPENTELEMETRY_PYTHON_OThER": "other",
38-
"OPENTELEMETRY_PYTHON_OTHER_7": "other_7",
35+
"OTEL_PYTHON_METER_PROVIDER": "meter_provider",
36+
"OTEL_PYTHON_TRACER_PROVIDER": "tracer_provider",
37+
"OTEL_OThER": "other",
38+
"OTEL_OTHER_7": "other_7",
3939
"OPENTELEMETRY_PTHON_TRACEX_PROVIDER": "tracex_provider",
4040
},
4141
)
@@ -56,7 +56,7 @@ def test_environment_variables(self) -> None:
5656

5757
@patch.dict(
5858
"os.environ", # type: ignore
59-
{"OPENTELEMETRY_PYTHON_TRACER_PROVIDER": "tracer_provider"},
59+
{"OTEL_PYTHON_TRACER_PROVIDER": "tracer_provider"},
6060
)
6161
def test_property(self) -> None:
6262
with self.assertRaises(AttributeError):
@@ -79,8 +79,7 @@ def test_getattr(self) -> None:
7979

8080
def test_reset(self) -> None:
8181
environ_patcher = patch.dict(
82-
"os.environ",
83-
{"OPENTELEMETRY_PYTHON_TRACER_PROVIDER": "tracer_provider"},
82+
"os.environ", {"OTEL_PYTHON_TRACER_PROVIDER": "tracer_provider"},
8483
)
8584

8685
environ_patcher.start()
@@ -99,10 +98,7 @@ def test_reset(self) -> None:
9998

10099
@patch.dict(
101100
"os.environ", # type: ignore
102-
{
103-
"OPENTELEMETRY_PYTHON_TRUE": "True",
104-
"OPENTELEMETRY_PYTHON_FALSE": "False",
105-
},
101+
{"OTEL_TRUE": "True", "OTEL_FALSE": "False"},
106102
)
107103
def test_boolean(self) -> None:
108104
self.assertIsInstance(
@@ -117,9 +113,9 @@ def test_boolean(self) -> None:
117113
@patch.dict(
118114
"os.environ", # type: ignore
119115
{
120-
"OPENTELEMETRY_PYTHON_POSITIVE_INTEGER": "123",
121-
"OPENTELEMETRY_PYTHON_NEGATIVE_INTEGER": "-123",
122-
"OPENTELEMETRY_PYTHON_NON_INTEGER": "-12z3",
116+
"OTEL_POSITIVE_INTEGER": "123",
117+
"OTEL_NEGATIVE_INTEGER": "-123",
118+
"OTEL_NON_INTEGER": "-12z3",
123119
},
124120
)
125121
def test_integer(self) -> None:
@@ -136,9 +132,9 @@ def test_integer(self) -> None:
136132
@patch.dict(
137133
"os.environ", # type: ignore
138134
{
139-
"OPENTELEMETRY_PYTHON_POSITIVE_FLOAT": "123.123",
140-
"OPENTELEMETRY_PYTHON_NEGATIVE_FLOAT": "-123.123",
141-
"OPENTELEMETRY_PYTHON_NON_FLOAT": "-12z3.123",
135+
"OTEL_POSITIVE_FLOAT": "123.123",
136+
"OTEL_NEGATIVE_FLOAT": "-123.123",
137+
"OTEL_NON_FLOAT": "-12z3.123",
142138
},
143139
)
144140
def test_float(self) -> None:

Diff for: opentelemetry-sdk/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
- Add support for resources and resource detector
1011
([#853](https://github.com/open-telemetry/opentelemetry-python/pull/853))

Diff for: opentelemetry-sdk/tests/conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def pytest_sessionstart(session):
2020
# pylint: disable=unused-argument
2121
if version_info < (3, 5):
2222
# contextvars are not supported in 3.4, use thread-local storage
23-
environ["OPENTELEMETRY_CONTEXT"] = "threadlocal_context"
23+
environ["OTEL_CONTEXT"] = "threadlocal_context"
2424
else:
25-
environ["OPENTELEMETRY_CONTEXT"] = "contextvars_context"
25+
environ["OTEL_CONTEXT"] = "contextvars_context"
2626

2727

2828
def pytest_sessionfinish(session):
2929
# pylint: disable=unused-argument
30-
environ.pop("OPENTELEMETRY_CONTEXT")
30+
environ.pop("OTEL_CONTEXT")

0 commit comments

Comments
 (0)