Search in sources :

Example 1 with JaegerTracerConfiguration

use of org.wildfly.extension.microprofile.opentracing.resolver.JaegerTracerConfiguration in project wildfly by wildfly.

the class JaegerTracerConfigurationAddHandler method performRuntime.

@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    super.performRuntime(context, operation, model);
    CapabilityServiceBuilder builder = context.getCapabilityServiceTarget().addCapability(TRACER_CAPABILITY);
    String outboundSocketBindingName = TracerAttributes.SENDER_BINDING.resolveModelAttribute(context, model).asStringOrNull();
    Supplier<OutboundSocketBinding> outboundSocketBindingSupplier;
    if (outboundSocketBindingName != null) {
        outboundSocketBindingSupplier = builder.requiresCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, OutboundSocketBinding.class, outboundSocketBindingName);
    } else {
        outboundSocketBindingSupplier = () -> null;
    }
    TracerConfiguration config = new JaegerTracerConfiguration(context, context.getCurrentAddressValue(), operation, outboundSocketBindingSupplier);
    Consumer<TracerConfiguration> injector = builder.provides(TRACER_CAPABILITY);
    builder.setInstance(new Service() {

        @Override
        public void start(StartContext context) {
            injector.accept(config);
            WildFlyTracerFactory.registerTracer(config.getName()).accept(config);
        }

        @Override
        public void stop(StopContext context) {
            WildFlyTracerFactory.registerTracer(config.getName()).accept(null);
        }
    });
    builder.setInitialMode(ON_DEMAND).install();
}
Also used : JaegerTracerConfiguration(org.wildfly.extension.microprofile.opentracing.resolver.JaegerTracerConfiguration) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) StopContext(org.jboss.msc.service.StopContext) StartContext(org.jboss.msc.service.StartContext) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) TracerConfiguration(org.wildfly.microprofile.opentracing.smallrye.TracerConfiguration) JaegerTracerConfiguration(org.wildfly.extension.microprofile.opentracing.resolver.JaegerTracerConfiguration) Service(org.jboss.msc.Service)

Aggregations

CapabilityServiceBuilder (org.jboss.as.controller.CapabilityServiceBuilder)1 OutboundSocketBinding (org.jboss.as.network.OutboundSocketBinding)1 Service (org.jboss.msc.Service)1 StartContext (org.jboss.msc.service.StartContext)1 StopContext (org.jboss.msc.service.StopContext)1 JaegerTracerConfiguration (org.wildfly.extension.microprofile.opentracing.resolver.JaegerTracerConfiguration)1 TracerConfiguration (org.wildfly.microprofile.opentracing.smallrye.TracerConfiguration)1