Skip to content

pkg/ottl: add request context #39157

@axw

Description

@axw

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

There are cases where it is useful to operate on request metadata, e.g. to use metadata (headers) for routing, as proposed in #38888 and as already supported in routingprocessor.

This would also solve the need in #37616.

Describe the solution you'd like

I would like to add a standard "request" context to OTTL. This would be a level above "resource", and would provide the following paths based on https://github.com/open-telemetry/opentelemetry-collector/blob/main/client/client.go:

  • request.addr: the client address
  • request.auth.attributes: the full map of client auth data
  • request.auth.attributes[""]: a specific key in the client auth data, supporting multiple keys for nested data
  • request.metadata: the full map of client metadata
  • request.metadata[""]: a specific key in the client metadata; if 2 keys are provided, the second one will index into the slice of values

Describe alternatives you've considered

Instead of creating a generic "request" context, we could create receiver-specific contexts, e.g. http, or kafka. This may provide a cleaner solution to #35231 (comment)

I'm not sure how practical this is at the moment. My understanding is that each subsequently more narrowly-scoped context (e.g. resource -> scope -> log) knows about and implements access to the more general scope. I don't think we would want a kafka context inside pkg/ottl, so we would probably want instead to somehow inject that through context.Context.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions