Search in sources :

Example 1 with MetricCollector

use of org.wildfly.extension.metrics.MetricCollector in project wildfly by wildfly.

the class DeploymentMetricService method install.

public static void install(ServiceTarget serviceTarget, DeploymentUnit deploymentUnit, Resource rootResource, ManagementResourceRegistration managementResourceRegistration, boolean exposeAnySubsystem, List<String> exposedSubsystems, String prefix) {
    PathAddress deploymentAddress = createDeploymentAddressPrefix(deploymentUnit);
    ServiceBuilder<?> sb = serviceTarget.addService(deploymentUnit.getServiceName().append("metrics"));
    Supplier<MetricCollector> metricCollector = sb.requires(WILDFLY_COLLECTOR);
    Supplier<MetricRegistry> metricRegistry = sb.requires(METRICS_REGISTRY_RUNTIME_CAPABILITY.getCapabilityServiceName());
    Supplier<Executor> managementExecutor = sb.requires(ServerService.EXECUTOR_CAPABILITY.getCapabilityServiceName());
    /*
         * The deployment metric service depends on the deployment complete service name to ensure that the metrics from
         * the deployment are collected and registered once the deployment services have all been properly installed.
         */
    sb.requires(DeploymentCompleteServiceProcessor.serviceName(deploymentUnit.getServiceName()));
    sb.setInstance(new DeploymentMetricService(rootResource, managementResourceRegistration, deploymentAddress, metricCollector, metricRegistry, managementExecutor, exposeAnySubsystem, exposedSubsystems, prefix)).install();
}
Also used : Executor(java.util.concurrent.Executor) PathAddress(org.jboss.as.controller.PathAddress) MetricRegistry(org.wildfly.extension.metrics.MetricRegistry) MetricCollector(org.wildfly.extension.metrics.MetricCollector)

Example 2 with MetricCollector

use of org.wildfly.extension.metrics.MetricCollector in project wildfly by wildfly.

the class MicroProfileMetricsSubsystemAdd method performBoottime.

@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    super.performBoottime(context, operation, model);
    final List<String> exposedSubsystems = MicroProfileMetricsSubsystemDefinition.EXPOSED_SUBSYSTEMS.unwrap(context, model);
    final boolean exposeAnySubsystem = exposedSubsystems.remove("*");
    final String prefix = MicroProfileMetricsSubsystemDefinition.PREFIX.resolveModelAttribute(context, model).asStringOrNull();
    final boolean securityEnabled = MicroProfileMetricsSubsystemDefinition.SECURITY_ENABLED.resolveModelAttribute(context, model).asBoolean();
    context.addStep(new AbstractDeploymentChainStep() {

        public void execute(DeploymentProcessorTarget processorTarget) {
            processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, DEPENDENCIES, DEPENDENCIES_MICROPROFILE_METRICS, new DependencyProcessor());
            processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, INSTALL, POST_MODULE_MICROPROFILE_METRICS, new DeploymentMetricProcessor(exposeAnySubsystem, exposedSubsystems, prefix));
        }
    }, RUNTIME);
    MetricsHTTTPSecurityService.install(context, securityEnabled);
    final MicroProfileVendorMetricRegistry vendorMetricRegistry = new MicroProfileVendorMetricRegistry();
    MicroProfileMetricsContextService.install(context, vendorMetricRegistry);
    // delay the registration of the metrics in the VERIFY stage so that all resources
    // created during the RUNTIME phase will have been registered in the MRR.
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext operationContext, ModelNode modelNode) {
            ServiceController<?> serviceController = context.getServiceRegistry(false).getService(WILDFLY_COLLECTOR);
            MetricCollector metricCollector = MetricCollector.class.cast(serviceController.getValue());
            ImmutableManagementResourceRegistration rootResourceRegistration = context.getRootResourceRegistration();
            Resource rootResource = context.readResourceFromRoot(EMPTY_ADDRESS);
            MetricRegistration registration = new MetricRegistration(vendorMetricRegistry);
            metricCollector.collectResourceMetrics(rootResource, rootResourceRegistration, Function.identity(), exposeAnySubsystem, exposedSubsystems, prefix, registration);
            JmxRegistrar jmxRegistrar = new JmxRegistrar();
            try {
                jmxRegistrar.init();
            } catch (IOException e) {
                throw LOGGER.failedInitializeJMXRegistrar(e);
            }
        }
    }, VERIFY);
    MicroProfileMetricsLogger.LOGGER.activatingSubsystem();
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) Resource(org.jboss.as.controller.registry.Resource) IOException(java.io.IOException) MetricRegistration(org.wildfly.extension.metrics.MetricRegistration) DependencyProcessor(org.wildfly.extension.microprofile.metrics.deployment.DependencyProcessor) DeploymentMetricProcessor(org.wildfly.extension.microprofile.metrics.deployment.DeploymentMetricProcessor) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) MetricCollector(org.wildfly.extension.metrics.MetricCollector) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) ServiceController(org.jboss.msc.service.ServiceController) ImmutableManagementResourceRegistration(org.jboss.as.controller.registry.ImmutableManagementResourceRegistration) JmxRegistrar(io.smallrye.metrics.setup.JmxRegistrar) ModelNode(org.jboss.dmr.ModelNode)

Example 3 with MetricCollector

use of org.wildfly.extension.metrics.MetricCollector in project wildfly by wildfly.

the class DeploymentMetricService method install.

public static void install(ServiceTarget serviceTarget, DeploymentUnit deploymentUnit, Resource rootResource, ManagementResourceRegistration managementResourceRegistration, boolean exposeAnySubsystem, List<String> exposedSubsystems, String prefix) {
    PathAddress deploymentAddress = createDeploymentAddressPrefix(deploymentUnit);
    ServiceBuilder<?> sb = serviceTarget.addService(deploymentUnit.getServiceName().append("microprofile-metrics"));
    Supplier<MetricCollector> metricCollector = sb.requires(WILDFLY_COLLECTOR);
    Supplier<Executor> managementExecutor = sb.requires(ServerService.EXECUTOR_CAPABILITY.getCapabilityServiceName());
    /*
         * The deployment metric service depends on the deployment complete service name to ensure that the metrics from
         * the deployment are collected and registered once the deployment services have all be properly installed.
         */
    sb.requires(DeploymentCompleteServiceProcessor.serviceName(deploymentUnit.getServiceName()));
    sb.setInstance(new DeploymentMetricService(rootResource, managementResourceRegistration, deploymentAddress, metricCollector, managementExecutor, exposeAnySubsystem, exposedSubsystems, prefix)).install();
}
Also used : Executor(java.util.concurrent.Executor) PathAddress(org.jboss.as.controller.PathAddress) MetricCollector(org.wildfly.extension.metrics.MetricCollector)

Aggregations

MetricCollector (org.wildfly.extension.metrics.MetricCollector)3 Executor (java.util.concurrent.Executor)2 PathAddress (org.jboss.as.controller.PathAddress)2 JmxRegistrar (io.smallrye.metrics.setup.JmxRegistrar)1 IOException (java.io.IOException)1 OperationContext (org.jboss.as.controller.OperationContext)1 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)1 ImmutableManagementResourceRegistration (org.jboss.as.controller.registry.ImmutableManagementResourceRegistration)1 Resource (org.jboss.as.controller.registry.Resource)1 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)1 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceController (org.jboss.msc.service.ServiceController)1 MetricRegistration (org.wildfly.extension.metrics.MetricRegistration)1 MetricRegistry (org.wildfly.extension.metrics.MetricRegistry)1 DependencyProcessor (org.wildfly.extension.microprofile.metrics.deployment.DependencyProcessor)1 DeploymentMetricProcessor (org.wildfly.extension.microprofile.metrics.deployment.DeploymentMetricProcessor)1