Skip to content

Commit 4ddc85a

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent c3f8698 commit 4ddc85a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

micrometer-support/src/main/java/io/javaoperatorsdk/operator/monitoring/micrometer/MicrometerMetricsV2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void eventReceived(Event event, Map<String, Object> metadata) {
179179
} else {
180180
incrementCounter(
181181
EVENTS_RECEIVED,
182-
null,
182+
event.getRelatedCustomResourceID().getNamespace().orElse(null),
183183
metadata,
184184
Tag.of(EVENT, event.getClass().getSimpleName()),
185185
Tag.of(ACTION, UNKNOWN_ACTION_TAG));

sample-operators/metrics-processing/src/test/java/io/javaoperatorsdk/operator/sample/metrics/MetricsHandlingE2E.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,17 @@ private void verifyPrometheusMetrics() {
230230
// First verify events_received_total exists at all (from ResourceEvents)
231231
assertMetricPresent(prometheusUrl, "events_received_total", Duration.ofSeconds(30));
232232

233-
// Verify timer event source events are recorded with "no_namespace" tag
234-
// Timer events are not ResourceEvents so they have no namespace.
235-
// exported_namespace is needed because of otel collector.
233+
// Verify timer event source events are recorded.
234+
// Timer events are not ResourceEvents, so they get action="unknown".
235+
// The namespace comes from the event's ResourceID (same as the associated resource).
236+
// The "exported_namespace" label is used because OTel collector's
237+
// resource_to_telemetry_conversion renames Micrometer's "namespace" tag.
236238
assertMetricPresent(
237239
prometheusUrl,
238-
"events_received_total{exported_namespace=\"no_namespace\"}",
240+
"events_received_total{action=\"unknown\"}",
239241
Duration.ofSeconds(30),
240242
"events_received_total",
241-
"exported_namespace");
243+
"unknown");
242244

243245
log.info("All metrics verified successfully in Prometheus");
244246
}

0 commit comments

Comments
 (0)