Make the configuration object universal#563
Make the configuration object universal#563toumorokoshi merged 11 commits intoopen-telemetry:masterfrom
Conversation
toumorokoshi
left a comment
There was a problem hiding this comment.
Looks good! I think there's still some rough edges around using environment variables exclusively to drive providers, but maybe we can talk through it more another time?
Also I might look at pydantic: 3.6+ support only, but it does the env variable -> config conversion you have written by hand: https://pydantic-docs.helpmanual.io/usage/settings/
lzchen
left a comment
There was a problem hiding this comment.
This looks great! I was looking for a way to configure something like blacklisted host names for flask applications and seems like this would be the way to go.
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
Generally speaking looks good to me.
I'm wondering if we should relax the restrictions on the names, I think a variable called OPENTELEMETRY_PTYHON_MY_VALUE_2 should be valid.
| Configuration().xyz = "xyz" # pylint: disable=assigning-non-slot | ||
|
|
||
| def test_getattr(self): | ||
| Configuration().xyz is None |
There was a problem hiding this comment.
Is it missing the assertion?
| This is a configuration manager for OpenTelemetry. It reads configuration | ||
| values from environment variables prefixed with | ||
| ``OPENTELEMETRY_PYTHON_`` whose characters are only all caps and underscores. | ||
| The first character after ``OPENTELEMETRY_PYTHON_`` must be an uppercase |
There was a problem hiding this comment.
I think this sentence is not needed as the sentence before already implies it.
|
|
||
| 1. ``OPENTELEMETRY_PYTH_SOMETHING`` | ||
| 2. ``OPENTELEMETRY_PYTHON_something`` | ||
| 3. ``OPENTELEMETRY_PYTHON_SOMETHING_2_AND__ELSE`` |
There was a problem hiding this comment.
Is there any specific reason to not support this one?
There was a problem hiding this comment.
Fixed, any valid variable name is supported now.
|
|
||
| def tearDown(self): | ||
| Configuration._instance = None # pylint: disable=protected-access | ||
| from opentelemetry.configuration import Configuration # type: ignore |
There was a problem hiding this comment.
How is this supposed to work?
| "os.environ", # type: ignore | ||
| { | ||
| "OPENTELEMETRY_PYTHON_METER_PROVIDER": "meter_provider", | ||
| "OPENTELEMETRY_PYTHON_TRACER_PROVIDER": "tracer_provider", |
There was a problem hiding this comment.
It'd be nice to have other env variables here to show that it's generic.
* feat: implement createMeasure * fix: linting * fix: disable broken tests * fix: labelSet log statement * fix: absolute always set to true * fix: linting * fix: add jsdoc, adjust optionals * fix: failing tests * fix: linting * refactor: rename test handle var Co-authored-by: Mayur Kale <mayurkale@google.com>
The configuration object used to provide only configuration for the meter and tracer providers. Now it can be used to load any configuration value stored in an environment variable that starts with
OPENTELEMETRY_PYTHON_whose characters match with[A-Z_]. All this is explained with greater detail in the documentation. The documentation also includes a section that gathers and explains all the current environment variables that are meaningful for OpenTelemetry Python. In this way, the end user can have them all listed in one single place. If in the future, more environment variables are used, then they should be added there and documented accordingly.Fixes #515