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

Implement jaeger exporter provider #5002

Merged
merged 1 commit into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exporters/jaeger/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {

implementation(project(":exporters:common"))
implementation(project(":semconv"))
implementation(project(":sdk-extensions:autoconfigure-spi"))

compileOnly("io.grpc:grpc-stub")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.exporter.jaeger.internal;

import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.time.Duration;

/**
* {@link SpanExporter} SPI implementation for {@link JaegerGrpcSpanExporter}.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class JaegerGrpcSpanExporterProvider implements ConfigurableSpanExporterProvider {
@Override
public String getName() {
return "jaeger";
}

@Override
public SpanExporter createExporter(ConfigProperties config) {
JaegerGrpcSpanExporterBuilder builder = JaegerGrpcSpanExporter.builder();

String endpoint = config.getString("otel.exporter.jaeger.endpoint");
if (endpoint != null) {
builder.setEndpoint(endpoint);
}

Duration timeout = config.getDuration("otel.exporter.jaeger.timeout");
if (timeout != null) {
builder.setTimeout(timeout);
}

return builder.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.opentelemetry.exporter.jaeger.internal.JaegerGrpcSpanExporterProvider
1 change: 0 additions & 1 deletion sdk-extensions/autoconfigure/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies {
implementation(project(":semconv"))
implementation(project(":exporters:common"))

compileOnly(project(":exporters:jaeger"))
compileOnly(project(":exporters:otlp:all"))
compileOnly(project(":exporters:otlp:logs"))
compileOnly(project(":exporters:otlp:common"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.exporter.internal.retry.RetryUtil;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
Expand All @@ -22,7 +20,6 @@
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -37,6 +34,7 @@ final class SpanExporterConfiguration {

static {
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
EXPORTER_ARTIFACT_ID_BY_NAME.put("jaeger", "opentelemetry-exporter-jaeger");
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
EXPORTER_ARTIFACT_ID_BY_NAME.put("zipkin", "opentelemetry-exporter-zipkin");
Expand Down Expand Up @@ -100,8 +98,6 @@ static SpanExporter configureExporter(
switch (name) {
case "otlp":
return configureOtlp(config, meterProvider);
case "jaeger":
return configureJaeger(config, meterProvider);
default:
SpanExporter spiExporter = spiExportersManager.getByName(name);
if (spiExporter == null) {
Expand Down Expand Up @@ -170,28 +166,5 @@ static SpanExporter configureOtlp(ConfigProperties config, MeterProvider meterPr
}
}

private static SpanExporter configureJaeger(
ConfigProperties config, MeterProvider meterProvider) {
ClasspathUtil.checkClassExists(
"io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter",
"Jaeger gRPC Exporter",
"opentelemetry-exporter-jaeger");
JaegerGrpcSpanExporterBuilder builder = JaegerGrpcSpanExporter.builder();

String endpoint = config.getString("otel.exporter.jaeger.endpoint");
if (endpoint != null) {
builder.setEndpoint(endpoint);
}

Duration timeout = config.getDuration("otel.exporter.jaeger.timeout");
if (timeout != null) {
builder.setTimeout(timeout);
}

builder.setMeterProvider(meterProvider);

return builder.build();
}

private SpanExporterConfiguration() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ void jaeger() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
"jaeger", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
"jaeger",
EMPTY,
SpanExporterConfiguration.spanExporterSpiManager(
EMPTY, NotOnClasspathTest.class.getClassLoader()),
MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"Jaeger gRPC Exporter enabled but opentelemetry-exporter-jaeger not found on "
+ "classpath");
"otel.traces.exporter set to \"jaeger\" but opentelemetry-exporter-jaeger not found on classpath."
+ " Make sure to add it as a dependency.");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ void configureOtlpTimeout() {
// Timeout difficult to test using real exports so just check implementation detail here.
@Test
void configureJaegerTimeout() {
ConfigProperties config =
DefaultConfigProperties.createForTest(
Collections.singletonMap("otel.exporter.jaeger.timeout", "10"));
SpanExporter exporter =
SpanExporterConfiguration.configureExporter(
"jaeger",
DefaultConfigProperties.createForTest(
Collections.singletonMap("otel.exporter.jaeger.timeout", "10")),
NamedSpiManager.createEmpty(),
config,
SpanExporterConfiguration.spanExporterSpiManager(
config, SpanExporterConfigurationTest.class.getClassLoader()),
MeterProvider.noop());
try {
assertThat(exporter)
Expand Down