Component
Instrumentation: otelhttp
Problem Statement
Addressing the v1.0 stabilization audit #8107.
Currently, NewHandler and NewTransport share the same Option type and internal config struct. This allows users to accidentally pass Transport-specific options (like WithClientTrace) into a server Handler without compiler errors, leading to silent runtime failures and weakened API boundaries.
Proposed Solution
- Split internal state: Divide the shared config into handlerConfig and transportConfig.
- Define specific interfaces: Introduce HandlerOption and TransportOption with their respective apply methods.
- Define a shared interface: type Option interface { HandlerOption; TransportOption } for common options (e.g., WithPropagators).
- Update constructors: * func NewHandler(..., opts ...HandlerOption)
- func NewTransport(..., opts ...TransportOption)
- Options will be updated to return their most restrictive interface.
Alternatives
No response
Prior Art
No response
Additional Context
Breaking Change: Changing the constructor signatures is a breaking API change for users mixing option types, but it is necessary to achieve type safety before the v1.0 freeze.
Component
Instrumentation: otelhttp
Problem Statement
Addressing the v1.0 stabilization audit #8107.
Currently, NewHandler and NewTransport share the same Option type and internal config struct. This allows users to accidentally pass Transport-specific options (like WithClientTrace) into a server Handler without compiler errors, leading to silent runtime failures and weakened API boundaries.
Proposed Solution
Alternatives
No response
Prior Art
No response
Additional Context
Breaking Change: Changing the constructor signatures is a breaking API change for users mixing option types, but it is necessary to achieve type safety before the v1.0 freeze.