Created
March 14, 2023 07:55
-
-
Save jkuipers/d86cb8de4c3c05bdb7f19f0b4ee18826 to your computer and use it in GitHub Desktop.
Spring bean definition that ensures that client.name tags are included in HTTP client metrics again
This file contains hidden or 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
/** | |
* Starting with Boot 3, the {@code client.name} tag is no longer included by default | |
* in the {@code http.client.requests} metrics. Restore it by overriding | |
* {@link DefaultClientRequestObservationConvention#getLowCardinalityKeyValues(ClientRequestObservationContext)}. | |
* | |
* @return {@link ClientRequestObservationConvention} that adds the {@code client.name} to the low cardinality key-values. | |
*/ | |
@Bean | |
ClientRequestObservationConvention clientNameAddingObservationConvention() { | |
return new DefaultClientRequestObservationConvention() { | |
@Override | |
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) { | |
return super.getLowCardinalityKeyValues(context).and(this.clientName(context)); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment