0
# Core Build Items and Processors
1
2
Core deployment-time components that handle the fundamental Micrometer configuration and registry management during Quarkus application builds.
3
4
## Capabilities
5
6
### MicrometerRegistryProviderBuildItem
7
8
Build item for registering MeterRegistry classes in the composite registry during build time.
9
10
```java { .api }
11
/**
12
* Build item that registers MeterRegistry classes for inclusion in the composite registry
13
*/
14
public final class MicrometerRegistryProviderBuildItem extends MultiBuildItem {
15
/**
16
* Register a MeterRegistry class by Class reference
17
* @param providedRegistryClass The MeterRegistry class to register
18
*/
19
public MicrometerRegistryProviderBuildItem(Class<?> providedRegistryClass);
20
21
/**
22
* Register a MeterRegistry class by class name string
23
* @param registryClassName The fully qualified class name of the MeterRegistry
24
*/
25
public MicrometerRegistryProviderBuildItem(String registryClassName);
26
27
/**
28
* Get the registry class that was registered
29
* @return The MeterRegistry class
30
*/
31
public Class<? extends MeterRegistry> getRegistryClass();
32
33
/**
34
* String representation of the build item
35
* @return String describing the registered registry
36
*/
37
public String toString();
38
}
39
```
40
41
**Usage Examples:**
42
43
```java
44
// Register by class reference
45
@BuildStep
46
MicrometerRegistryProviderBuildItem prometheusRegistry() {
47
return new MicrometerRegistryProviderBuildItem(PrometheusMeterRegistry.class);
48
}
49
50
// Register by class name
51
@BuildStep
52
MicrometerRegistryProviderBuildItem customRegistry() {
53
return new MicrometerRegistryProviderBuildItem("com.example.CustomMeterRegistry");
54
}
55
```
56
57
### RootMeterRegistryBuildItem
58
59
Build item providing access to the root MeterRegistry runtime value.
60
61
```java { .api }
62
/**
63
* Build item that provides runtime value of the root MeterRegistry
64
*/
65
public final class RootMeterRegistryBuildItem extends SimpleBuildItem {
66
/**
67
* Create build item with registry runtime value
68
* @param value The runtime value containing the MeterRegistry
69
*/
70
public RootMeterRegistryBuildItem(RuntimeValue<MeterRegistry> value);
71
72
/**
73
* Get the runtime value of the root MeterRegistry
74
* @return RuntimeValue wrapping the MeterRegistry
75
*/
76
public RuntimeValue<MeterRegistry> getValue();
77
}
78
```
79
80
### MicrometerProcessor
81
82
Main deployment processor handling core Micrometer configuration and setup.
83
84
```java { .api }
85
/**
86
* Main processor for Micrometer configuration and setup
87
*/
88
@BuildSteps(onlyIf = MicrometerProcessor.MicrometerEnabled.class)
89
public class MicrometerProcessor {
90
91
/**
92
* Creates metrics capability build item when Prometheus is not enabled
93
* @return MetricsCapabilityBuildItem for general metrics support
94
*/
95
@BuildStep(onlyIfNot = PrometheusRegistryProcessor.PrometheusEnabled.class)
96
public MetricsCapabilityBuildItem metricsCapabilityBuildItem();
97
98
/**
99
* Registers empty exemplar provider when Prometheus is not enabled
100
* @param additionalBeans Producer for additional beans
101
*/
102
@BuildStep(onlyIfNot = PrometheusRegistryProcessor.PrometheusEnabled.class)
103
public void registerEmptyExamplarProvider(
104
BuildProducer<AdditionalBeanBuildItem> additionalBeans
105
);
106
107
/**
108
* Creates Prometheus-specific metrics capability when Prometheus is enabled
109
* @param nonApplicationRootPathBuildItem Non-application root path configuration
110
* @return MetricsCapabilityBuildItem for Prometheus metrics
111
*/
112
@BuildStep(onlyIf = PrometheusRegistryProcessor.PrometheusEnabled.class)
113
public MetricsCapabilityBuildItem metricsCapabilityPrometheusBuildItem(
114
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem
115
);
116
117
/**
118
* Registers core Micrometer beans and configures reflection for CDI
119
* @param indexBuildItem Combined index for annotation processing
120
* @param providerClasses Producer for registry provider build items
121
* @param reflectiveClasses Producer for reflective class build items
122
* @param additionalBeans Producer for additional bean build items
123
* @param interceptorBindings Producer for interceptor binding registrar build items
124
* @param reflectiveMethods Producer for reflective method build items
125
* @return UnremovableBeanBuildItem for core unremovable beans
126
*/
127
@BuildStep
128
public UnremovableBeanBuildItem registerAdditionalBeans(
129
CombinedIndexBuildItem indexBuildItem,
130
BuildProducer<MicrometerRegistryProviderBuildItem> providerClasses,
131
BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
132
BuildProducer<AdditionalBeanBuildItem> additionalBeans,
133
BuildProducer<InterceptorBindingRegistrarBuildItem> interceptorBindings,
134
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods
135
);
136
137
/**
138
* Configures logging levels for Micrometer components
139
* @param logCategoryProducer Producer for log category build items
140
*/
141
@BuildStep
142
public void configLoggingLevel(BuildProducer<LogCategoryBuildItem> logCategoryProducer);
143
144
/**
145
* Creates the root meter registry
146
* @param recorder Micrometer recorder for runtime operations
147
* @param nonApplicationRootPathBuildItem Non-application root path configuration
148
* @return RootMeterRegistryBuildItem with configured registry
149
*/
150
@BuildStep
151
@Consume(BeanContainerBuildItem.class)
152
@Record(ExecutionTime.STATIC_INIT)
153
public RootMeterRegistryBuildItem createRootRegistry(
154
MicrometerRecorder recorder,
155
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem
156
);
157
158
/**
159
* Registers static initialization extension metrics
160
* @param recorder Micrometer recorder for runtime operations
161
* @param metricsFactoryConsumerBuildItems List of metrics factory consumer build items
162
*/
163
@BuildStep
164
@Consume(RootMeterRegistryBuildItem.class)
165
@Record(ExecutionTime.STATIC_INIT)
166
public void registerExtensionMetrics(
167
MicrometerRecorder recorder,
168
List<MetricsFactoryConsumerBuildItem> metricsFactoryConsumerBuildItems
169
);
170
171
/**
172
* Configures meter registries with customizers and runtime initialization metrics
173
* @param recorder Micrometer recorder for runtime operations
174
* @param providerClassItems List of registry provider build items
175
* @param metricsFactoryConsumerBuildItems List of metrics factory consumer build items
176
* @param shutdownContextBuildItem Shutdown context for cleanup
177
*/
178
@BuildStep
179
@Consume(RootMeterRegistryBuildItem.class)
180
@Consume(LoggingSetupBuildItem.class)
181
@Record(ExecutionTime.RUNTIME_INIT)
182
public void configureRegistry(
183
MicrometerRecorder recorder,
184
List<MicrometerRegistryProviderBuildItem> providerClassItems,
185
List<MetricsFactoryConsumerBuildItem> metricsFactoryConsumerBuildItems,
186
ShutdownContextBuildItem shutdownContextBuildItem
187
);
188
189
/**
190
* Creates DevUI card for development mode (development only)
191
* @param registries Available registry build items
192
* @return CardPageBuildItem for DevUI integration
193
*/
194
@BuildStep(onlyIf = IsDevelopment.class)
195
public CardPageBuildItem createCard(List<RegistryBuildItem> registries);
196
}
197
```
198
199
### MicrometerConfigAlwaysEnabledProcessor
200
201
Always-enabled processor for basic Micrometer configuration that runs regardless of feature enablement.
202
203
```java { .api }
204
/**
205
* Always-enabled processor for basic configuration
206
*/
207
public class MicrometerConfigAlwaysEnabledProcessor {
208
209
/**
210
* Returns FeatureBuildItem for Micrometer
211
* @return Feature build item identifying Micrometer support
212
*/
213
@BuildStep
214
public FeatureBuildItem feature();
215
216
/**
217
* Makes MicrometerConfig unremovable for CDI
218
* @return UnremovableBeanBuildItem for config preservation
219
*/
220
@BuildStep
221
public UnremovableBeanBuildItem mpConfigAsBean();
222
}
223
```
224
225
### Core Constants and Utilities
226
227
```java { .api }
228
// Feature enablement condition
229
public static class MicrometerEnabled implements BooleanSupplier {
230
/**
231
* Check if Micrometer is enabled
232
* @return true if Micrometer feature is enabled
233
*/
234
public boolean getAsBoolean();
235
}
236
237
// Important DotName constants for annotation processing and build items
238
public static final DotName METER_REGISTRY = DotName.createSimple(MeterRegistry.class.getName());
239
public static final DotName METER_BINDER = DotName.createSimple(MeterBinder.class.getName());
240
public static final DotName METER_FILTER = DotName.createSimple(MeterFilter.class.getName());
241
public static final DotName METER_REGISTRY_CUSTOMIZER = DotName.createSimple(MeterRegistryCustomizer.class.getName());
242
public static final DotName NAMING_CONVENTION = DotName.createSimple(NamingConvention.class.getName());
243
244
// Annotation processing constants
245
public static final DotName COUNTED_ANNOTATION = DotName.createSimple(Counted.class.getName());
246
public static final DotName COUNTED_INTERCEPTOR = DotName.createSimple(MicrometerCountedInterceptor.class.getName());
247
public static final DotName TIMED_ANNOTATION = DotName.createSimple(Timed.class.getName());
248
public static final DotName TIMED_INTERCEPTOR = DotName.createSimple(MicrometerTimedInterceptor.class.getName());
249
public static final DotName METER_TAG_SUPPORT = DotName.createSimple(MeterTagsSupport.class.getName());
250
251
// Operating system bean class names for system metrics reflection
252
public static final List<String> OPERATING_SYSTEM_BEAN_CLASS_NAMES = List.of(
253
"com.ibm.lang.management.OperatingSystemMXBean", // J9
254
"com.sun.management.OperatingSystemMXBean" // HotSpot
255
);
256
```
257
258
**Usage Examples:**
259
260
```java
261
// Custom extension using MicrometerProcessor features
262
@BuildSteps
263
public class CustomMetricsProcessor {
264
265
@BuildStep(onlyIf = MicrometerProcessor.MicrometerEnabled.class)
266
AdditionalBeanBuildItem addCustomMetrics() {
267
return AdditionalBeanBuildItem.builder()
268
.addBeanClass(CustomMetricProducer.class)
269
.setUnremovable()
270
.build();
271
}
272
273
@BuildStep
274
@Record(ExecutionTime.RUNTIME_INIT)
275
SyntheticBeanBuildItem configureCustomMetrics(
276
RootMeterRegistryBuildItem rootRegistry,
277
CustomMetricsRecorder recorder
278
) {
279
return SyntheticBeanBuildItem.configure(CustomMetricsManager.class)
280
.supplier(recorder.createCustomMetricsManager(rootRegistry.getValue()))
281
.done();
282
}
283
}
284
```