opentelemetry-instrumentation: add config_dataclass opt-in to BaseInstrumentor#4766
Open
ocelotl wants to merge 7 commits into
Open
opentelemetry-instrumentation: add config_dataclass opt-in to BaseInstrumentor#4766ocelotl wants to merge 7 commits into
ocelotl wants to merge 7 commits into
Conversation
henry3260
reviewed
Jul 21, 2026
henry3260
left a comment
Contributor
There was a problem hiding this comment.
overall LGTM, just one nit
ocelotl
force-pushed
the
issue_4765
branch
2 times, most recently
from
July 22, 2026 04:42
c9159d4 to
dd7dbaf
Compare
…trumentor Instrumentors can set config_dataclass to a dataclass type describing their accepted configuration options. The SDK declarative config pipeline uses this to validate and coerce raw YAML options through _dict_to_dataclass before calling instrument(), applying the same type-coercion used for SDK component configuration. The default is None, so all existing instrumentors are unaffected.
…dataclass Expose config_dataclass on URLLib3Instrumentor so that the SDK declarative configuration pipeline can validate and coerce raw YAML options before calling instrument(). The dataclass covers the four YAML-representable options: excluded_urls, captured_request_headers, captured_response_headers, and sensitive_headers. Callable and SDK provider options are intentionally excluded.
Covers BaseInstrumentor.configuration defaulting to None and being overridable on subclasses, and URLLib3Instrumentor's wiring of URLLib3InstrumentorConfig as its configuration dataclass.
pylint's disallowed-name check rejected the field name "bar" in test_configuration_can_be_overridden. Also adds the missing .changelog/4766.added fragment required by the changelog check.
…rument() Add a functional test that builds URLLib3InstrumentorConfig and calls instrument(**dataclasses.asdict(config)), asserting excluded_urls, captured_request_headers, captured_response_headers and sensitive_headers each take effect. Guards the contract that every config field name matches the corresponding instrument() keyword argument, which is otherwise read via kwargs.get() and would be silently ignored on mismatch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4765
Summary
configuration: type | None = NonetoBaseInstrumentor; defaultNoneleaves all existing instrumentors unaffectedURLLib3InstrumentorConfigas the reference implementation — a typed dataclass covering the four YAML-representable options (excluded_urls,captured_request_headers,captured_response_headers,sensitive_headers); callable and SDK provider options are intentionally excludedconfiguration = URLLib3InstrumentorConfigonURLLib3InstrumentorThe SDK side that reads
configurationand runs options through_dict_to_dataclassis in open-telemetry/opentelemetry-python#5372.Test plan
BaseInstrumentor.configurationdefaulting toNone/being overridable, andURLLib3Instrumentor.configurationwiringURLLib3InstrumentorConfigdocker compose up; verify spans appear inoutput/traces.jsonlwith captured headers and that/healthzrequests are excluded