Skip to content

Commit 1ee77a8

Browse files
committed
Store ints as ints in the configuration object
Fixes open-telemetry#1118
1 parent 751e813 commit 1ee77a8

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Diff for: opentelemetry-api/CHANGELOG.md

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

33
## Unreleased
44

5+
- Store `int`s as `int`s in the global Configuration object
6+
([#1118](https://github.com/open-telemetry/opentelemetry-python/pull/1118))
57
- Refactor `SpanContext.is_valid` from a method to a data attribute
68
([#1005](https://github.com/open-telemetry/opentelemetry-python/pull/1005))
79
- Moved samplers from API to SDK

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,10 @@ def __new__(cls) -> "Configuration":
128128
try:
129129
value = int(value_str)
130130
except ValueError:
131-
pass
132-
try:
133-
value = float(value_str)
134-
except ValueError:
135-
pass
131+
try:
132+
value = float(value_str)
133+
except ValueError:
134+
pass
136135

137136
instance._config_map[key] = value
138137

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,18 @@ def test_boolean(self) -> None:
119119
},
120120
)
121121
def test_integer(self) -> None:
122+
# pylint: disable=no-member
123+
self.assertTrue(isinstance(Configuration().POSITIVE_INTEGER, int))
122124
self.assertEqual(
123125
Configuration().POSITIVE_INTEGER, 123
124-
) # pylint: disable=no-member
126+
)
127+
self.assertTrue(isinstance(Configuration().NEGATIVE_INTEGER, int))
125128
self.assertEqual(
126129
Configuration().NEGATIVE_INTEGER, -123
127-
) # pylint: disable=no-member
130+
)
128131
self.assertEqual(
129132
Configuration().NON_INTEGER, "-12z3"
130-
) # pylint: disable=no-member
133+
)
131134

132135
@patch.dict(
133136
"os.environ", # type: ignore

0 commit comments

Comments
 (0)