or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-processors.mdframework-binders.mdindex.mdmp-metrics-compatibility.mdregistry-exports.md

registry-exports.mddocs/

0

# Registry Export Processors

1

2

Processors that configure and expose metrics through various registry endpoints, providing different formats and protocols for metrics consumption by monitoring systems.

3

4

## Capabilities

5

6

### RegistryBuildItem

7

8

Build item representing a configured meter registry endpoint that will be exposed by the application.

9

10

```java { .api }

11

/**

12

* Build item representing a configured meter registry endpoint

13

*/

14

public final class RegistryBuildItem extends MultiBuildItem {

15

/**

16

* Create a registry build item with name and path

17

* @param name The name identifier of the registry

18

* @param path The HTTP path where the registry will be exposed

19

*/

20

public RegistryBuildItem(String name, String path);

21

22

/**

23

* Get the registry name

24

* @return The name identifier of this registry

25

*/

26

public String name();

27

28

/**

29

* Get the registry path

30

* @return The HTTP path where this registry is exposed

31

*/

32

public String path();

33

}

34

```

35

36

### Prometheus Registry Processor

37

38

Configures Prometheus meter registry and creates HTTP endpoints for Prometheus metrics scraping.

39

40

```java { .api }

41

/**

42

* Deployment processor for Prometheus registry configuration

43

*/

44

@BuildSteps

45

public class PrometheusRegistryProcessor {

46

47

/**

48

* Creates Prometheus registry provider

49

* @param config Micrometer configuration

50

* @param additionalBeans Producer for additional bean build items

51

* @return MicrometerRegistryProviderBuildItem for Prometheus registry

52

*/

53

@BuildStep

54

public MicrometerRegistryProviderBuildItem createPrometheusRegistry(

55

MicrometerConfig config,

56

BuildProducer<AdditionalBeanBuildItem> additionalBeans

57

);

58

59

/**

60

* Registers OpenTelemetry exemplar sampler provider when tracing is enabled

61

* @param additionalBeans Producer for additional bean build items

62

*/

63

@BuildStep(onlyIf = TraceEnabled.class)

64

public void registerOpentelemetryExemplarSamplerProvider(

65

BuildProducer<AdditionalBeanBuildItem> additionalBeans

66

);

67

68

/**

69

* Registers empty exemplar provider when tracing is disabled

70

* @param additionalBeans Producer for additional bean build items

71

*/

72

@BuildStep(onlyIfNot = TraceEnabled.class)

73

public void registerEmptyExamplarProvider(

74

BuildProducer<AdditionalBeanBuildItem> additionalBeans

75

);

76

77

/**

78

* Creates Prometheus metrics endpoints

79

* @param routes Producer for route build items

80

* @param registries Producer for registry build items

81

* @param mConfig Micrometer configuration

82

* @param nonApplicationRootPathBuildItem Non-application root path configuration

83

* @param managementBuildTimeConfig Management interface build-time configuration

84

* @param launchModeBuildItem Launch mode build item

85

* @param recorder Prometheus recorder for runtime operations

86

*/

87

@BuildStep

88

@Record(value = ExecutionTime.STATIC_INIT)

89

public void createPrometheusRoute(

90

BuildProducer<RouteBuildItem> routes,

91

BuildProducer<RegistryBuildItem> registries,

92

MicrometerConfig mConfig,

93

NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,

94

ManagementInterfaceBuildTimeConfig managementBuildTimeConfig,

95

LaunchModeBuildItem launchModeBuildItem,

96

PrometheusRecorder recorder

97

);

98

99

// Enablement conditions

100

public static class PrometheusEnabled implements BooleanSupplier;

101

public static class TraceEnabled implements BooleanSupplier;

102

}

103

```

104

105

**Usage Examples:**

106

107

```java

108

// Prometheus registry provides metrics at /q/metrics endpoint by default

109

// Example HTTP request to get Prometheus metrics:

110

// GET /q/metrics

111

// Content-Type: text/plain; version=0.0.4; charset=utf-8

112

113

// Example Prometheus metrics output:

114

# HELP http_server_requests_seconds Duration of HTTP server request handling

115

# TYPE http_server_requests_seconds summary

116

http_server_requests_seconds{method="GET",outcome="SUCCESS",status="200",uri="/api/users",quantile="0.5",} 0.002

117

http_server_requests_seconds{method="GET",outcome="SUCCESS",status="200",uri="/api/users",quantile="0.95",} 0.005

118

http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/api/users",} 42.0

119

http_server_requests_seconds_sum{method="GET",outcome="SUCCESS",status="200",uri="/api/users",} 0.123

120

```

121

122

### JSON Registry Processor

123

124

Configures JSON meter registry and creates HTTP endpoints for JSON-formatted metrics output.

125

126

```java { .api }

127

/**

128

* Deployment processor for JSON registry configuration

129

*/

130

@BuildSteps

131

public class JsonRegistryProcessor {

132

133

/**

134

* Initializes JSON registry and endpoints

135

* @param config Micrometer configuration

136

* @param registryProviders Producer for registry provider build items

137

* @param routes Producer for route build items

138

* @param additionalBeans Producer for additional bean build items

139

* @param registries Producer for registry build items

140

* @param nonApplicationRootPathBuildItem Non-application root path configuration

141

* @param managementBuildTimeConfig Management interface build-time configuration

142

* @param launchModeBuildItem Launch mode build item

143

* @param recorder JSON recorder for runtime operations

144

*/

145

@BuildStep

146

@Record(ExecutionTime.STATIC_INIT)

147

public void initializeJsonRegistry(

148

MicrometerConfig config,

149

BuildProducer<MicrometerRegistryProviderBuildItem> registryProviders,

150

BuildProducer<RouteBuildItem> routes,

151

BuildProducer<AdditionalBeanBuildItem> additionalBeans,

152

BuildProducer<RegistryBuildItem> registries,

153

NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,

154

ManagementInterfaceBuildTimeConfig managementBuildTimeConfig,

155

LaunchModeBuildItem launchModeBuildItem,

156

JsonRecorder recorder

157

);

158

159

// Enablement condition

160

public static class JsonRegistryEnabled implements BooleanSupplier;

161

}

162

```

163

164

**Usage Examples:**

165

166

```java

167

// JSON registry provides metrics at /q/metrics/json endpoint by default

168

// Example HTTP request to get JSON metrics:

169

// GET /q/metrics/json

170

// Content-Type: application/json

171

172

// Example JSON metrics output:

173

{

174

"names": ["http.server.requests", "jvm.memory.used", "system.cpu.usage"],

175

"measurements": [

176

{

177

"statistic": "COUNT",

178

"value": 42.0

179

},

180

{

181

"statistic": "TOTAL_TIME",

182

"value": 0.123

183

}

184

],

185

"availableTags": [

186

{

187

"tag": "method",

188

"values": ["GET", "POST", "PUT", "DELETE"]

189

},

190

{

191

"tag": "status",

192

"values": ["200", "404", "500"]

193

}

194

]

195

}

196

```

197

198

### Registry Constants and Utilities

199

200

```java { .api }

201

// Prometheus registry class constants

202

public static final String REGISTRY_CLASS_NAME = "io.micrometer.prometheus.PrometheusMeterRegistry";

203

public static final Class<?> REGISTRY_CLASS; // Lazily loaded class reference

204

205

// Registry configuration utilities

206

public static boolean isPrometheusEnabled() {

207

return ConfigProvider.getConfig()

208

.getOptionalValue("quarkus.micrometer.export.prometheus.enabled", Boolean.class)

209

.orElse(true);

210

}

211

212

public static boolean isJsonRegistryEnabled() {

213

return ConfigProvider.getConfig()

214

.getOptionalValue("quarkus.micrometer.export.json.enabled", Boolean.class)

215

.orElse(false);

216

}

217

```

218

219

### Custom Registry Integration

220

221

```java

222

// Example: Adding a custom registry export processor

223

@BuildSteps

224

public class CustomRegistryProcessor {

225

226

@BuildStep(onlyIf = CustomRegistryEnabled.class)

227

MicrometerRegistryProviderBuildItem createCustomRegistry() {

228

return new MicrometerRegistryProviderBuildItem(CustomMeterRegistry.class);

229

}

230

231

@BuildStep(onlyIf = CustomRegistryEnabled.class)

232

@Record(ExecutionTime.RUNTIME_INIT)

233

List<RouteBuildItem> createCustomEndpoints(

234

List<RegistryBuildItem> registries,

235

CustomRegistryRecorder recorder

236

) {

237

return List.of(

238

RouteBuildItem.builder()

239

.route("/q/metrics/custom")

240

.handler(recorder.createCustomHandler())

241

.build()

242

);

243

}

244

245

@BuildStep(onlyIf = CustomRegistryEnabled.class)

246

RegistryBuildItem registerCustomEndpoint() {

247

return new RegistryBuildItem("custom", "/q/metrics/custom");

248

}

249

250

public static class CustomRegistryEnabled implements BooleanSupplier {

251

@Override

252

public boolean getAsBoolean() {

253

return ConfigProvider.getConfig()

254

.getOptionalValue("quarkus.micrometer.export.custom.enabled", Boolean.class)

255

.orElse(false);

256

}

257

}

258

}

259

```

260

261

### OpenTelemetry Integration

262

263

The Prometheus processor includes special support for OpenTelemetry exemplars when tracing is enabled:

264

265

```java { .api }

266

/**

267

* OpenTelemetry exemplar integration when both Prometheus and tracing are enabled

268

*/

269

@BuildStep(onlyIf = {PrometheusEnabled.class, TraceEnabled.class})

270

UnremovableBeanBuildItem registerOpentelemetryExemplarSamplerProvider() {

271

return UnremovableBeanBuildItem.beanClassNames(

272

"io.quarkus.micrometer.runtime.export.exemplars.OpenTelemetryExemplarSamplerProvider"

273

);

274

}

275

```

276

277

**Configuration Examples:**

278

279

```properties

280

# Enable Prometheus metrics (enabled by default)

281

quarkus.micrometer.export.prometheus.enabled=true

282

283

# Customize Prometheus endpoint path

284

quarkus.micrometer.export.prometheus.path=/custom-metrics

285

286

# Enable JSON metrics export

287

quarkus.micrometer.export.json.enabled=true

288

289

# Enable OpenTelemetry exemplars for Prometheus

290

quarkus.micrometer.export.prometheus.enable-exemplars=true

291

292

# Configure registry-specific settings

293

quarkus.micrometer.export.prometheus.step=PT1M

294

quarkus.micrometer.export.prometheus.descriptions=true

295

```