-
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.
Merge pull request #43321 from PhilKes/http-client-request-tags-contr…
…ibutor Add HttpClientMetricsTagsContributor for custom client request tags
- Loading branch information
Showing
7 changed files
with
155 additions
and
13 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
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
15 changes: 15 additions & 0 deletions
15
...nsions/micrometer/deployment/src/test/java/io/quarkus/micrometer/test/ClientDummyTag.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,15 @@ | ||
package io.quarkus.micrometer.test; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import io.micrometer.core.instrument.Tags; | ||
import io.quarkus.micrometer.runtime.HttpClientMetricsTagsContributor; | ||
|
||
@Singleton | ||
public class ClientDummyTag implements HttpClientMetricsTagsContributor { | ||
|
||
@Override | ||
public Tags contribute(Context context) { | ||
return Tags.of("dummy", "value"); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...sions/micrometer/deployment/src/test/java/io/quarkus/micrometer/test/ClientHeaderTag.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.micrometer.test; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import io.micrometer.core.instrument.Tags; | ||
import io.quarkus.micrometer.runtime.HttpClientMetricsTagsContributor; | ||
|
||
@Singleton | ||
public class ClientHeaderTag implements HttpClientMetricsTagsContributor { | ||
|
||
@Override | ||
public Tags contribute(Context context) { | ||
String headerValue = context.request().headers().get("Foo"); | ||
String value = "UNSET"; | ||
if ((headerValue != null) && !headerValue.isEmpty()) { | ||
value = headerValue; | ||
} | ||
return Tags.of("foo", value); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...runtime/src/main/java/io/quarkus/micrometer/runtime/HttpClientMetricsTagsContributor.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,24 @@ | ||
package io.quarkus.micrometer.runtime; | ||
|
||
import io.micrometer.core.instrument.Tags; | ||
import io.micrometer.core.instrument.config.MeterFilter; | ||
import io.vertx.core.spi.observability.HttpRequest; | ||
|
||
/** | ||
* Allows code to add additional Micrometer {@link Tags} to the metrics collected for completed HTTP client requests. | ||
* <p> | ||
* The implementations of this interface are meant to be registered via CDI beans. | ||
* | ||
* @see MeterFilter for a more advanced and feature complete way of interacting with {@link Tags} | ||
*/ | ||
public interface HttpClientMetricsTagsContributor { | ||
|
||
/** | ||
* Called when Vert.x http client request has ended | ||
*/ | ||
Tags contribute(Context context); | ||
|
||
interface Context { | ||
HttpRequest request(); | ||
} | ||
} |
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