Skip to content

[Feature]: Allow async interceptors for OTLP GRPC exporter #2881

Open
@valkum

Description

@valkum

Related Problems?

Google just released their tracing OTLP endpoint. This endpoint needs authorization metadata.
Tonic provides interceptors to inject auth metadata and those are exposed via WithTonicConfig::with_interceptor. In contrast to tonic, this interceptor is maintained outside of tonic and just allows returning metadata that is then set in the export functions.
Getting a valid bearer token normally requires an async operation, and interceptors are currently non-async only.
Currently, you would need to duplicate a lot of code to have blocking counterparts.

Describe the solution you'd like:

To support this kind of auth, opentelemetry-otlp should support adding async interceptors via WithTonicConfig.

The tonic native way would be using tower layers to add async interceptor functionality. There currently isn't a helper to do so. There is a standalone crate tonic-async-interceptor, but this also needs a tower layer.

With the current integration of interceptors in TonicTracesClient, the least invasive solution would provide an async interceptor variant that is just awaited in the returned future in export and would add the metadata to the request similarly to the current interceptor.

Considered Alternatives

No response

Additional Context

One common way would be to use gcp_auth which provides bearer tokens for use in an async manner.

Related: open-telemetry/opentelemetry-specification#4390 open-telemetry/opentelemetry-specification#1344

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