Search in sources :

Example 1 with OpenTelemetry

use of io.opentelemetry.api.OpenTelemetry in project wildfly by wildfly.

the class OpenTelemetrySubsystemDeploymentProcessor method setupOtelCdiBeans.

private void setupOtelCdiBeans(DeploymentPhaseContext deploymentPhaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = deploymentPhaseContext.getDeploymentUnit();
    final ClassLoader initialCl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    final ModuleClassLoader moduleCL = deploymentUnit.getAttachment(Attachments.MODULE).getClassLoader();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(moduleCL);
        String serviceName = holder.config.serviceName != null ? holder.config.serviceName : getServiceName(deploymentUnit);
        final OpenTelemetry openTelemetry = OpenTelemetryCdiExtension.registerApplicationOpenTelemetryBean(moduleCL, holder.getOpenTelemetry());
        OpenTelemetryCdiExtension.registerApplicationTracer(moduleCL, openTelemetry.getTracer(serviceName));
        OTEL_LOGGER.registeringTracer(serviceName);
    } catch (SecurityException | IllegalArgumentException ex) {
        OTEL_LOGGER.errorResolvingTracer(ex);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(initialCl);
    }
}
Also used : ModuleClassLoader(org.jboss.modules.ModuleClassLoader) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) OpenTelemetry(io.opentelemetry.api.OpenTelemetry) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

OpenTelemetry (io.opentelemetry.api.OpenTelemetry)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ModuleClassLoader (org.jboss.modules.ModuleClassLoader)1