Skip to content

Audit otelhttp API #8107

@dmathieu

Description

@dmathieu

We're starting to look into stabilizing the go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp package.

For that, we need to audit the public API of the package, not for missing things (as those could be added later) but for things that should be changed before we can't do breaking changes anymore.

For reference, this is the API as it is with the latest release:

func ContextWithLabeler(parent context.Context, l *Labeler) context.Context
func ContextWithStartTime(parent context.Context, start time.Time) context.Context
func Get(ctx context.Context, targetURL string) (resp *http.Response, err error)
func Head(ctx context.Context, targetURL string) (resp *http.Response, err error)
func NewHandler(handler http.Handler, operation string, opts ...Option) http.Handler
func NewMiddleware(operation string, opts ...Option) func(http.Handler) http.Handler
func Post(ctx context.Context, targetURL, contentType string, body io.Reader) (resp *http.Response, err error)
func PostForm(ctx context.Context, targetURL string, data url.Values) (resp *http.Response, err error)
func StartTimeFromContext(ctx context.Context) time.Time
func Version() string
func WithRouteTag(route string, h http.Handler) http.Handler
type Filter
type Labeler
    func LabelerFromContext(ctx context.Context) (*Labeler, bool)
    func (l *Labeler) Add(ls ...attribute.KeyValue)
    func (l *Labeler) Get() []attribute.KeyValue

type Option
    func WithClientTrace(f func(context.Context) *httptrace.ClientTrace) Option
    func WithFilter(f Filter) Option
    func WithMessageEvents(events ...event) Option
    func WithMeterProvider(provider metric.MeterProvider) Option
    func WithMetricAttributesFn(metricAttributesFn func(r *http.Request) []attribute.KeyValue) Option
    func WithPropagators(ps propagation.TextMapPropagator) Option
    func WithPublicEndpoint() Option
    func WithPublicEndpointFn(fn func(*http.Request) bool) Option
    func WithServerName(server string) Option
    func WithSpanNameFormatter(f func(operation string, r *http.Request) string) Option
    func WithSpanOptions(opts ...trace.SpanStartOption) Option
    func WithTracerProvider(provider trace.TracerProvider) Option

type Transport
    func NewTransport(base http.RoundTripper, opts ...Option) *Transport
    func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error)

This issue is open for any comment opinions before that stabilization.

Critical Issues (Must Fix Before Stabilization)

Important Issues (Should Fix)

Nice to Have

Context Notes

  • Issue Should we have expert, or generalist handlers? #2782 about generalist vs specific instrumentation is not resolved by this stabilization effort - any changes would introduce breaking changes and the issue hasn't generated momentum. Can be considered for a future v2.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions