Skip to content

Commit

Permalink
Store ints as ints in the configuration object (#1119)
Browse files Browse the repository at this point in the history
Fixes #1118

Co-authored-by: alrex <aboten@lightstep.com>
  • Loading branch information
ocelotl and alrex authored Sep 21, 2020
1 parent 7f01f05 commit 99e8971
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
3 changes: 3 additions & 0 deletions opentelemetry-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- Store `int`s as `int`s in the global Configuration object
([#1118](https://github.com/open-telemetry/opentelemetry-python/pull/1118))

## Version 0.13b0

Released 2020-09-17
Expand Down
9 changes: 4 additions & 5 deletions opentelemetry-api/src/opentelemetry/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,10 @@ def __new__(cls) -> "Configuration":
try:
value = int(value_str)
except ValueError:
pass
try:
value = float(value_str)
except ValueError:
pass
try:
value = float(value_str)
except ValueError:
pass

instance._config_map[key] = value

Expand Down
15 changes: 6 additions & 9 deletions opentelemetry-api/tests/configuration/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,12 @@ def test_boolean(self) -> None:
},
)
def test_integer(self) -> None:
self.assertEqual(
Configuration().POSITIVE_INTEGER, 123
) # pylint: disable=no-member
self.assertEqual(
Configuration().NEGATIVE_INTEGER, -123
) # pylint: disable=no-member
self.assertEqual(
Configuration().NON_INTEGER, "-12z3"
) # pylint: disable=no-member
# pylint: disable=no-member
self.assertIsInstance(Configuration().POSITIVE_INTEGER, int)
self.assertEqual(Configuration().POSITIVE_INTEGER, 123)
self.assertIsInstance(Configuration().NEGATIVE_INTEGER, int)
self.assertEqual(Configuration().NEGATIVE_INTEGER, -123)
self.assertEqual(Configuration().NON_INTEGER, "-12z3")

@patch.dict(
"os.environ", # type: ignore
Expand Down

0 comments on commit 99e8971

Please sign in to comment.