Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto instrumentation parameters #3864

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

jeremydvoss
Copy link
Contributor

@jeremydvoss jeremydvoss commented Apr 18, 2024

Description

Currently, the only way for custom Configurators to configure is through setting or defaulting environment variables. While it makes sense for customers to configure autoinstrumentation with env vars, there is no reason Configurators should not be able to directly configure start up (exporters, samplers...etc). Exposing autoinstrumentation configuration of otel via env var defaults is invasive, confusing, and easy for users to mess up. For instance, even a blank env var or a left-over setting from previous run could interfere with a distro starting up.

In this approach, configurators can pass kwargs to _initialize_components to easily configure autoinstrumentation which currently only considers env vars.

Precedence of params over env vars

Params would be preferred over (or merged with) env vars. This follows the approach towards env vars elsewhere in OTel Python. And doing so would be necessary for custom distros to guarantee certain behavior.

In this approach, exporters given by params would be ADDED to those from env vars. Resource attributes would be merged with those from env vars and resource detectors. Since there's only 1 sampler, param would take precedence. Same for logging_enabled.

@jeremydvoss jeremydvoss requested a review from a team as a code owner April 18, 2024 23:17
@jeremydvoss jeremydvoss changed the title Auto instrumentation parameter proposal DO NOT MERGE: Auto instrumentation parameter proposal Apr 18, 2024
@jeremydvoss jeremydvoss changed the title DO NOT MERGE: Auto instrumentation parameter proposal Auto instrumentation parameter proposal May 23, 2024
@jeremydvoss jeremydvoss changed the title Auto instrumentation parameter proposal Auto instrumentation parameters May 23, 2024
@@ -38,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3823] (https://github.com/open-telemetry/opentelemetry-python/pull/3823))
- Add span flags to OTLP spans and links
([#3881](https://github.com/open-telemetry/opentelemetry-python/pull/3881))
- Add parameters for Distros and configurators to configure autoinstrumentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this approach, exporters given by params would be ADDED to those from env vars. Resource attributes would be merged with those from env vars and resource detectors. Since there's only 1 sampler, param would take precedence. Same for logging_enabled.

It would be great to have this part of the description posted somewhere, though I'm not sure where. Changelog might be too concise, so just an idea:

Suggested change
- Add parameters for Distros and configurators to configure autoinstrumentation
- Add parameters for Distros and configurators to configure autoinstrumentation with environment variable merging

Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, posted one idea. Thanks for presenting this at multiple sig meetings.

@@ -1,4 +1,4 @@
[codespell]
# skipping auto generated folders
skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions
ignore-words-list = ans,ue,ot,hist,ro
ignore-words-list = ans,assertIn,ue,ot,hist,ro,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need this anymore after #3930

if log_exporter_names is None:
log_exporter_names = []
span_exporters, metric_exporters, log_exporters = _import_exporters(
span_exporter_names + _get_exporter_names("traces"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be additive or should we have the in-code configuration take priority and replace entrypoints similar to how we override env var? Would users be surprised by the "default" behavior?

_get_exporter_names("logs"),
def _initialize_components(
auto_instrumentation_version: Optional[str] = None,
span_exporter_names: Optional[List[str]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we stick with trace_exporter_names instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants