Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticator interface can't be used with OtlpHttpSpanExporter #5389

Closed
GerardPaligot opened this issue Apr 17, 2023 · 2 comments
Closed

Authenticator interface can't be used with OtlpHttpSpanExporter #5389

GerardPaligot opened this issue Apr 17, 2023 · 2 comments
Labels
Bug Something isn't working

Comments

@GerardPaligot
Copy link

Describe the bug
We can't use the Authenticator interface to configure http client used by OtlpHttpSpanExporter. You can only use Authenticator interface with OkHttpExporterBuilder which is used internally by the span exporter.

Steps to reproduce

val exporter: OtlpHttpSpanExporter =
    OtlpHttpSpanExporter.builder()
        .setEndpoint("http://localhost:4318/v1/traces")
        .build()
Authenticator.setAuthenticatorOnDelegate(exporter, Authenticator {
    return@Authenticator mapOf(
        "Authorization" to "Bearer <token>"
    )
})
Caused by: java.lang.IllegalArgumentException: Delegate field is not type DefaultGrpcExporterBuilder or OkHttpGrpcExporterBuilder.
    at io.opentelemetry.exporter.internal.auth.Authenticator.setAuthenticatorOnDelegate(Authenticator.java:48)

What did you expect to see?
It should be possible to configure an authentication interceptor / delegate to generate a valid token when it is necessary

What version and what artifacts are you using?
Artifacts: opentelemetry-api, opentelemetry-sdk, opentelemetry-exporter-otlp, opentelemetry-exporter-common
Version: 1.25.0

Environment
Compiler: zulu JDK 17
OS: macOS 13.3.1

@jack-berg
Copy link
Member

I've verified authenticator and Authenticator.setAuthenticatorOnDelegate are working as expected. Added an additional test case in #5391 to be sure.

I see in your repro you are trying to set the authenticator on the exporter instead of on the exporter builder. Try this instead:

val exporterBuilder: OtlpHttpSpanExporterBuilder =
    OtlpHttpSpanExporter.builder()
        .setEndpoint("http://localhost:4318/v1/traces")
Authenticator.setAuthenticatorOnDelegate(exporterBuilder, Authenticator {
    return@Authenticator mapOf(
        "Authorization" to "Bearer <token>"
    )
})

@jack-berg
Copy link
Member

Closing as #5391 indicates that the API is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants