use of org.wildfly.extension.opentelemetry.api.OpenTelemetryCdiExtension in project wildfly by wildfly.
the class OpenTelemetryDependencyProcessor method addDependencies.
private void addDependencies(DeploymentUnit deploymentUnit) {
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
try {
CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
WeldCapability weldCapability = support.getCapabilityRuntimeAPI(Capabilities.WELD_CAPABILITY_NAME, WeldCapability.class);
if (weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
weldCapability.registerExtensionInstance(new OpenTelemetryCdiExtension(), deploymentUnit);
// Export the -api module only if CDI is available
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, API_MODULE, false, true, true, false));
}
// Export all other modules regardless of CDI availability
for (String module : EXPORTED_MODULES) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, module, false, true, true, false));
}
} catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
throw new IllegalStateException();
}
}
Aggregations