-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HTTP response to HttpServerMetricsTagsContributor.Context
This is useful for creating tags based on HTTP response headers for example Closes: #45717
- Loading branch information
Showing
5 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
integration-tests/micrometer-prometheus/src/main/java/io/quarkus/ResponseHeaderTag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import io.micrometer.core.instrument.Tags; | ||
import io.quarkus.micrometer.runtime.HttpServerMetricsTagsContributor; | ||
|
||
@Singleton | ||
public class ResponseHeaderTag implements HttpServerMetricsTagsContributor { | ||
|
||
@Override | ||
public Tags contribute(Context context) { | ||
var headerValue = context.response().headers().get("foo-response"); | ||
String value = "UNSET"; | ||
if ((headerValue != null) && !headerValue.isEmpty()) { | ||
value = headerValue; | ||
} | ||
return Tags.of("foo-response", value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters