Search in sources :

Example 1 with TracerConfiguration

use of org.wildfly.microprofile.opentracing.smallrye.TracerConfiguration 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)

Example 2 with TracerConfiguration

use of org.wildfly.microprofile.opentracing.smallrye.TracerConfiguration in project wildfly by wildfly.

the class SubsystemAdd method performBoottime.

@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    WildFlyTracerFactory.registerTracer(ENV_TRACER).accept(new JaegerEnvTracerConfiguration());
    TracingExtensionLogger.ROOT_LOGGER.activatingSubsystem();
    String defaultTracer = DEFAULT_TRACER.resolveModelAttribute(context, operation).asStringOrNull();
    if (defaultTracer != null && !defaultTracer.isEmpty()) {
        CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(DEFAULT_TRACER_CAPABILITY);
        final Supplier<TracerConfiguration> config = builder.requiresCapability(TRACER_CAPABILITY_NAME, TracerConfiguration.class, defaultTracer);
        final Consumer<TracerConfiguration> injector = builder.provides(DEFAULT_TRACER_CAPABILITY);
        builder.setInstance(new Service() {

            @Override
            public void start(StartContext context) throws StartException {
                injector.accept(config.get());
                WildFlyTracerFactory.registerDefaultTracer().accept(config.get());
            }

            @Override
            public void stop(StopContext context) {
                injector.accept(null);
                WildFlyTracerFactory.registerDefaultTracer().accept(config.get());
            }
        }).setInitialMode(ServiceController.Mode.ACTIVE).install();
    }
    context.addStep(new AbstractDeploymentChainStep() {

        @Override
        public void execute(DeploymentProcessorTarget processorTarget) {
            processorTarget.addDeploymentProcessor(SubsystemExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_MICROPROFILE_OPENTRACING, new TracingDependencyProcessor());
            processorTarget.addDeploymentProcessor(SubsystemExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_MICROPROFILE_OPENTRACING, new TracingDeploymentProcessor());
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : StopContext(org.jboss.msc.service.StopContext) TracerConfiguration(org.wildfly.microprofile.opentracing.smallrye.TracerConfiguration) JaegerEnvTracerConfiguration(org.wildfly.extension.microprofile.opentracing.resolver.JaegerEnvTracerConfiguration) Service(org.jboss.msc.Service) JaegerEnvTracerConfiguration(org.wildfly.extension.microprofile.opentracing.resolver.JaegerEnvTracerConfiguration) StartContext(org.jboss.msc.service.StartContext) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) StartException(org.jboss.msc.service.StartException) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep)

Aggregations

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