or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mdhttp-integration.mdindex.mdruntime-api.md

index.mddocs/

0

# Quarkus SmallRye Metrics

1

2

Quarkus SmallRye Metrics is a Quarkus extension that integrates SmallRye Metrics with the MicroProfile Metrics specification for comprehensive application monitoring and observability. The extension provides automatic metrics collection, HTTP endpoint exposure, and seamless integration with Quarkus's reactive and imperative programming models.

3

4

**IMPORTANT**: This extension is deprecated in favor of the newer `quarkus-micrometer` extension. Existing applications should migrate to Micrometer for metrics collection.

5

6

## Package Information

7

8

- **Package Name**: quarkus-smallrye-metrics

9

- **Package Type**: maven

10

- **Language**: Java

11

- **Group ID**: io.quarkus

12

- **Artifact ID**: quarkus-smallrye-metrics

13

- **Installation**: Add to Maven dependencies

14

15

```xml

16

<dependency>

17

<groupId>io.quarkus</groupId>

18

<artifactId>quarkus-smallrye-metrics</artifactId>

19

</dependency>

20

```

21

22

## Core Imports

23

24

```java

25

import io.quarkus.smallrye.metrics.runtime.MetadataHolder;

26

import io.quarkus.smallrye.metrics.runtime.TagHolder;

27

import io.quarkus.smallrye.metrics.runtime.SmallRyeMetricsFactory;

28

import io.quarkus.smallrye.metrics.runtime.SmallRyeMetricsRecorder;

29

30

// MicroProfile Metrics API (provided by extension)

31

import org.eclipse.microprofile.metrics.*;

32

import org.eclipse.microprofile.metrics.annotation.*;

33

```

34

35

## Basic Usage

36

37

The extension automatically provides MicroProfile Metrics capabilities to your Quarkus application:

38

39

```java

40

import org.eclipse.microprofile.metrics.*;

41

import org.eclipse.microprofile.metrics.annotation.*;

42

import jakarta.inject.Inject;

43

44

@ApplicationScoped

45

public class MyService {

46

47

@Inject

48

MetricRegistry registry;

49

50

// Annotation-based metrics

51

@Counted(name = "service_calls", description = "Number of service calls")

52

public void myServiceMethod() {

53

// Your business logic

54

}

55

56

@Timed(name = "processing_time", description = "Processing time")

57

public String processData(String data) {

58

return data.toUpperCase();

59

}

60

61

// Programmatic metrics

62

public void createCustomMetric() {

63

Counter counter = registry.counter("custom_counter");

64

counter.inc();

65

66

Gauge<Long> gauge = registry.gauge("memory_usage",

67

() -> Runtime.getRuntime().totalMemory());

68

}

69

}

70

```

71

72

## Architecture

73

74

The extension consists of several key components:

75

76

- **Runtime Module**: Core classes for metrics collection and HTTP exposure

77

- **Build-time Processing**: Deployment-time metric registration and configuration via `SmallRyeMetricsRecorder`

78

- **HTTP Integration**: JAX-RS filters for automatic REST endpoint metrics collection

79

- **MicroProfile Metrics API**: Full compatibility with MP Metrics annotations and programmatic API

80

- **Vert.x Integration**: HTTP handler for `/metrics` endpoint exposure

81

- **CDI Integration**: Metric registry injection and lifecycle management

82

83

## Capabilities

84

85

### Core Runtime API

86

87

Essential classes for metrics metadata handling, factory integration, and build-time processing.

88

89

```java { .api }

90

public class MetadataHolder {

91

public String getName();

92

public void setName(String name);

93

public MetricType getMetricType();

94

public void setMetricType(MetricType metricType);

95

public String getDescription();

96

public void setDescription(String description);

97

public static MetadataHolder from(Metadata metadata);

98

public Metadata toMetadata();

99

}

100

101

public class SmallRyeMetricsFactory implements MetricsFactory {

102

public boolean metricsSystemSupported(String name);

103

public MetricBuilder builder(String name, MetricsFactory.Type type);

104

}

105

```

106

107

[Core Runtime API](./runtime-api.md)

108

109

### HTTP Integration

110

111

JAX-RS filters and Vert.x handlers for automatic metrics collection from REST endpoints and metrics endpoint exposure.

112

113

```java { .api }

114

public class QuarkusRestMetricsFilter {

115

// Automatic REST metrics collection for Quarkus REST

116

}

117

118

public class SmallRyeMetricsHandler implements Handler<RoutingContext> {

119

public void setMetricsPath(String metricsPath);

120

public void handle(RoutingContext routingContext);

121

}

122

```

123

124

[HTTP Integration](./http-integration.md)

125

126

### Configuration

127

128

Configuration properties and build-time setup for customizing metrics behavior.

129

130

```java { .api }

131

public interface SmallRyeMetricsConfig {

132

// Configuration properties:

133

// quarkus.smallrye-metrics.path

134

// quarkus.smallrye-metrics.extensions.enabled

135

// quarkus.smallrye-metrics.micrometer.compatibility

136

// quarkus.smallrye-metrics.jaxrs.enabled

137

}

138

```

139

140

[Configuration](./configuration.md)

141

142

## Migration Notes

143

144

**This extension is deprecated.** For new applications:

145

146

- Use `quarkus-micrometer` for metrics collection

147

- Use the management interface for operational metrics exposure

148

- Enable Micrometer compatibility mode for transition: `quarkus.smallrye-metrics.micrometer.compatibility=true`

149

150

## MicroProfile Metrics Integration

151

152

The extension provides full MicroProfile Metrics API compatibility:

153

154

```java { .api }

155

// Standard MicroProfile Metrics annotations

156

@Counted // Count method invocations

157

@Timed // Time method execution

158

@Metered // Measure throughput

159

@Gauge // Expose gauge values

160

@ConcurrentGauge // Track concurrent invocations

161

162

// Registry types

163

MetricRegistry.Type.APPLICATION // Application metrics

164

MetricRegistry.Type.BASE // JVM metrics

165

MetricRegistry.Type.VENDOR // Vendor-specific metrics

166

```

167

168

Metrics are automatically exposed at `/q/metrics` endpoint in Prometheus format, with support for JSON format via Accept headers.