Search in sources :

Example 1 with InterceptorBindingRegistrar

use of io.quarkus.arc.processor.InterceptorBindingRegistrar in project quarkus by quarkusio.

the class MicrometerProcessor method registerAdditionalBeans.

@BuildStep(onlyIf = MicrometerEnabled.class)
UnremovableBeanBuildItem registerAdditionalBeans(CombinedIndexBuildItem indexBuildItem, BuildProducer<MicrometerRegistryProviderBuildItem> providerClasses, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses, BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<InterceptorBindingRegistrarBuildItem> interceptorBindings) {
    // Create and keep some basic Providers
    additionalBeans.produce(AdditionalBeanBuildItem.builder().setUnremovable().addBeanClass(ClockProvider.class).addBeanClass(CompositeRegistryCreator.class).build());
    // Add annotations and associated interceptors
    additionalBeans.produce(AdditionalBeanBuildItem.builder().addBeanClass(MeterFilterConstraint.class).addBeanClass(MeterFilterConstraints.class).addBeanClass(TIMED_ANNOTATION.toString()).addBeanClass(TIMED_INTERCEPTOR.toString()).addBeanClass(COUNTED_ANNOTATION.toString()).addBeanClass(COUNTED_BINDING.toString()).addBeanClass(COUNTED_INTERCEPTOR.toString()).build());
    // @Timed is registered as an additional interceptor binding
    interceptorBindings.produce(new InterceptorBindingRegistrarBuildItem(new InterceptorBindingRegistrar() {

        @Override
        public List<InterceptorBinding> getAdditionalBindings() {
            return List.of(InterceptorBinding.of(Timed.class, m -> true));
        }
    }));
    IndexView index = indexBuildItem.getIndex();
    reflectiveClasses.produce(createReflectiveBuildItem(COUNTED_ANNOTATION, index));
    reflectiveClasses.produce(createReflectiveBuildItem(TIMED_ANNOTATION, index));
    reflectiveClasses.produce(ReflectiveClassBuildItem.builder("org.HdrHistogram.Histogram", "org.HdrHistogram.DoubleHistogram", "org.HdrHistogram.ConcurrentHistogram").constructors(true).build());
    return UnremovableBeanBuildItem.beanTypes(METER_REGISTRY, METER_BINDER, METER_FILTER, NAMING_CONVENTION);
}
Also used : InterceptorBindingRegistrar(io.quarkus.arc.processor.InterceptorBindingRegistrar) MeterFilter(io.micrometer.core.instrument.config.MeterFilter) UnremovableBeanBuildItem(io.quarkus.arc.deployment.UnremovableBeanBuildItem) MicrometerCounted(io.quarkus.micrometer.runtime.MicrometerCounted) InterceptorBindingRegistrar(io.quarkus.arc.processor.InterceptorBindingRegistrar) MeterBinder(io.micrometer.core.instrument.binder.MeterBinder) ShutdownContextBuildItem(io.quarkus.deployment.builditem.ShutdownContextBuildItem) NonApplicationRootPathBuildItem(io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) MetricsCapabilityBuildItem(io.quarkus.deployment.metrics.MetricsCapabilityBuildItem) MicrometerCountedInterceptor(io.quarkus.micrometer.runtime.MicrometerCountedInterceptor) BooleanSupplier(java.util.function.BooleanSupplier) MethodInfo(org.jboss.jandex.MethodInfo) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) InterceptorBindingRegistrarBuildItem(io.quarkus.arc.deployment.InterceptorBindingRegistrarBuildItem) AnnotationTarget(org.jboss.jandex.AnnotationTarget) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) AnnotationValue(org.jboss.jandex.AnnotationValue) Collection(java.util.Collection) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) Set(java.util.Set) Annotations(io.quarkus.arc.processor.Annotations) AnnotationsTransformer(io.quarkus.arc.processor.AnnotationsTransformer) Feature(io.quarkus.deployment.Feature) List(java.util.List) Counted(io.micrometer.core.annotation.Counted) CompositeRegistryCreator(io.quarkus.micrometer.runtime.CompositeRegistryCreator) AnnotationInstance(org.jboss.jandex.AnnotationInstance) BeanContainerBuildItem(io.quarkus.arc.deployment.BeanContainerBuildItem) ClockProvider(io.quarkus.micrometer.runtime.ClockProvider) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Record(io.quarkus.deployment.annotations.Record) Timed(io.micrometer.core.annotation.Timed) DotName(org.jboss.jandex.DotName) MetricsFactoryConsumerBuildItem(io.quarkus.deployment.metrics.MetricsFactoryConsumerBuildItem) PrometheusRegistryProcessor(io.quarkus.micrometer.deployment.export.PrometheusRegistryProcessor) MetricsFactory(io.quarkus.runtime.metrics.MetricsFactory) HashSet(java.util.HashSet) BuildStep(io.quarkus.deployment.annotations.BuildStep) RuntimeValue(io.quarkus.runtime.RuntimeValue) Kind(org.jboss.jandex.AnnotationTarget.Kind) MeterFilterConstraint(io.quarkus.micrometer.runtime.MeterFilterConstraint) IndexView(org.jboss.jandex.IndexView) MicrometerTimedInterceptor(io.quarkus.micrometer.runtime.MicrometerTimedInterceptor) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) MicrometerRecorder(io.quarkus.micrometer.runtime.MicrometerRecorder) NamingConvention(io.micrometer.core.instrument.config.NamingConvention) MicrometerConfig(io.quarkus.micrometer.runtime.config.MicrometerConfig) MeterFilterConstraints(io.quarkus.micrometer.runtime.MeterFilterConstraints) InterceptorBindingRegistrarBuildItem(io.quarkus.arc.deployment.InterceptorBindingRegistrarBuildItem) Timed(io.micrometer.core.annotation.Timed) IndexView(org.jboss.jandex.IndexView) ClockProvider(io.quarkus.micrometer.runtime.ClockProvider) MeterFilterConstraints(io.quarkus.micrometer.runtime.MeterFilterConstraints) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with InterceptorBindingRegistrar

use of io.quarkus.arc.processor.InterceptorBindingRegistrar in project quarkus by quarkusio.

the class OpenTelemetryProcessor method registerWithSpan.

@BuildStep(onlyIf = OpenTelemetryEnabled.class)
void registerWithSpan(BuildProducer<InterceptorBindingRegistrarBuildItem> interceptorBindingRegistrar, BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
    interceptorBindingRegistrar.produce(new InterceptorBindingRegistrarBuildItem(new InterceptorBindingRegistrar() {

        @Override
        public List<InterceptorBinding> getAdditionalBindings() {
            return List.of(InterceptorBinding.of(WithSpan.class, Set.of("value", "kind")));
        }
    }));
    additionalBeans.produce(new AdditionalBeanBuildItem(WithSpanInterceptor.class));
}
Also used : InterceptorBindingRegistrar(io.quarkus.arc.processor.InterceptorBindingRegistrar) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) WithSpanInterceptor(io.quarkus.opentelemetry.runtime.tracing.cdi.WithSpanInterceptor) InterceptorBindingRegistrarBuildItem(io.quarkus.arc.deployment.InterceptorBindingRegistrarBuildItem) WithSpan(io.opentelemetry.extension.annotations.WithSpan) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)2 InterceptorBindingRegistrarBuildItem (io.quarkus.arc.deployment.InterceptorBindingRegistrarBuildItem)2 InterceptorBindingRegistrar (io.quarkus.arc.processor.InterceptorBindingRegistrar)2 BuildStep (io.quarkus.deployment.annotations.BuildStep)2 Counted (io.micrometer.core.annotation.Counted)1 Timed (io.micrometer.core.annotation.Timed)1 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 MeterBinder (io.micrometer.core.instrument.binder.MeterBinder)1 MeterFilter (io.micrometer.core.instrument.config.MeterFilter)1 NamingConvention (io.micrometer.core.instrument.config.NamingConvention)1 WithSpan (io.opentelemetry.extension.annotations.WithSpan)1 AnnotationsTransformerBuildItem (io.quarkus.arc.deployment.AnnotationsTransformerBuildItem)1 BeanContainerBuildItem (io.quarkus.arc.deployment.BeanContainerBuildItem)1 UnremovableBeanBuildItem (io.quarkus.arc.deployment.UnremovableBeanBuildItem)1 Annotations (io.quarkus.arc.processor.Annotations)1 AnnotationsTransformer (io.quarkus.arc.processor.AnnotationsTransformer)1 Feature (io.quarkus.deployment.Feature)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 ExecutionTime (io.quarkus.deployment.annotations.ExecutionTime)1 Record (io.quarkus.deployment.annotations.Record)1