Bridges the gap between Microprofile Metrics and Cloud Monitoring.
This implementation attempts the following:
- Snapshots the data as fast as possible,
- If not created already does it's best to create a
com.google.api.MetricDescriptor
for theMetric
and persists to Cloud Monitoring, - Iterates around the snapshot data persisting it to Cloud Monitoring.
Metric will have the following values:
- Type:
custom.googleapis.com/microprofile/<registry_type>/<MetricId#name>
- Display Name:
MetricId#displayName
- Description:
Metadata#description
- Unit:
Metadata#unit
- Value Type: Detected from first sample of data
Limitations:
- Missing
org.eclipse.microprofile.metrics.Meter
, - Performance testing - No idea of the runtime impact of this library underload.
ℹ️ Repeat quick start/stop of instances may result in a
INVALID_ARGUMENT: ... One or more points were written more frequently than the maximum sampling period configured for the metric.
error. This is especially true for local development as it will tend to use theglobal
monitored resource type. This will not appear when running in GKE or GCE as the hostname has sufficient entropy to avoid conflicts.
By simply adding this as a dependency is sufficient for it to start exporting metrics to Cloud Monitoring.
Key | Description | Value | Default | Notes |
---|---|---|---|---|
cloudMonitoring.samplingRate |
The duration between collection of metrics | STANDARD|HIGH_RESOLUTION |
STANDARD |
For more info see here. |
The following metrics can be collected from JAX-RS for both Container and Client:
request.count
: The number of requests received withpath
tag,response.count
: The number of requests received withpath
andresponse_code
tags,request.latency
: The time it took for the application code to process the request and respond withpath
andresponse_code
tags.
To enable these use the following classes:
uk.dansiviter.gcp.microprofile.metrics.jaxrs.ContainerMetricsFeature
,uk.dansiviter.gcp.microprofile.metrics.jaxrs.ClientMetricsFeature
.
In some circumstances you may not want the metrics to be pushed to Cloud Monitoring. See uk.dansiviter.gcp.microprofile.metrics.Filter
for more information.
dashboard.json
is an example Cloud Monitoring dashboard that shows some of the Microprofile metrics.