-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
312 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...metry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/ClassUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.opentelemetry.runtime; | ||
|
||
public final class ClassUtil { | ||
private ClassUtil() { | ||
} | ||
|
||
public static void checkAwsSdkExtension(String config) { | ||
ClassUtil.checkClassExists("io.opentelemetry.sdk.extension.aws.resource.BeanstalkResource", | ||
config, | ||
"opentelemetry-sdk-extension-aws"); | ||
} | ||
|
||
public static void checkAwsExtension(String config) { | ||
ClassUtil.checkClassExists("io.opentelemetry.extension.aws.AwsXrayPropagator", | ||
config, | ||
"opentelemetry-extension-aws"); | ||
} | ||
|
||
public static void checkPropagatorsExtension(String config) { | ||
ClassUtil.checkClassExists( | ||
"io.opentelemetry.extension.trace.propagation.B3Propagator", | ||
config, | ||
"opentelemetry-extension-trace-propagators"); | ||
} | ||
|
||
public static void checkResourcesExtension(String configName) { | ||
ClassUtil.checkClassExists("io.opentelemetry.sdk.extension.resources.HostResource", | ||
configName, | ||
"opentelemetry-sdk-extension-resources"); | ||
} | ||
|
||
public static void checkClassExists(String className, String configName, String requiredLibrary) { | ||
try { | ||
Class.forName(className, true, Thread.currentThread().getContextClassLoader()); | ||
} catch (ClassNotFoundException unused) { | ||
throw new IllegalArgumentException( | ||
configName | ||
+ " enabled but " | ||
+ requiredLibrary | ||
+ " not found on classpath. " | ||
+ "Make sure to add it as a dependency to enable this config."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...entelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.quarkus.opentelemetry.runtime; | ||
|
||
import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.Propagator.BAGGAGE; | ||
import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.Propagator.TRACE_CONTEXT; | ||
import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.Propagator.XRAY; | ||
|
||
import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator; | ||
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; | ||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.extension.aws.AwsXrayPropagator; | ||
import io.opentelemetry.extension.trace.propagation.B3Propagator; | ||
import io.opentelemetry.extension.trace.propagation.JaegerPropagator; | ||
import io.opentelemetry.extension.trace.propagation.OtTracePropagator; | ||
|
||
public final class OpenTelemetryUtil { | ||
private OpenTelemetryUtil() { | ||
} | ||
|
||
public static TextMapPropagator mapPropagator(OpenTelemetryConfig.Propagator propagator) { | ||
if (BAGGAGE == propagator) { | ||
return W3CBaggagePropagator.getInstance(); | ||
} | ||
if (TRACE_CONTEXT == propagator) { | ||
return W3CTraceContextPropagator.getInstance(); | ||
} | ||
if (XRAY == propagator) { | ||
ClassUtil.checkAwsExtension(propagator.name() + " propagator"); | ||
return AwsXrayPropagator.getInstance(); | ||
} | ||
// Other propagators are in the extension artifact. Check one of the propagators. | ||
ClassUtil.checkPropagatorsExtension(propagator.name() + " propagator"); | ||
|
||
switch (propagator) { | ||
case B3: | ||
return B3Propagator.injectingSingleHeader(); | ||
case B3_MULTI: | ||
return B3Propagator.injectingMultiHeaders(); | ||
case JAEGER: | ||
return JaegerPropagator.getInstance(); | ||
case OT_TRACE: | ||
return OtTracePropagator.getInstance(); | ||
default: | ||
throw new IllegalStateException("Unrecognized value for propagator: " + propagator); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.