Use consistent list of micrometer tags in web observation handler
The tag `spring.security.reached.filter.name` is only set if a filter-name is available, otherwise the tag is omitted entirely. This leads to issues with metric-exporters that don't support dynamic tags, but rather expect tag-names of a metric to be always the same. The most prominent example is the Prometheus-exporter. Instead of omitting the tag if no filer-name is set, a none-value is applied instead, making the tag-list consistent in all cases Closes gh-13179
This commit is contained in:
committed by
Josh Cummings
parent
b438bc5384
commit
af233a2a00
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import io.micrometer.common.KeyValue;
|
||||
import io.micrometer.common.KeyValues;
|
||||
import io.micrometer.observation.Observation;
|
||||
import io.micrometer.observation.ObservationConvention;
|
||||
@@ -515,13 +516,11 @@ public final class ObservationFilterChainDecorator implements FilterChainProxy.F
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(FilterChainObservationContext context) {
|
||||
KeyValues kv = KeyValues.of(CHAIN_SIZE_NAME, String.valueOf(context.getChainSize()))
|
||||
return KeyValues.of(CHAIN_SIZE_NAME, String.valueOf(context.getChainSize()))
|
||||
.and(CHAIN_POSITION_NAME, String.valueOf(context.getChainPosition()))
|
||||
.and(FILTER_SECTION_NAME, context.getFilterSection());
|
||||
if (context.getFilterName() != null) {
|
||||
kv = kv.and(FILTER_NAME, context.getFilterName());
|
||||
}
|
||||
return kv;
|
||||
.and(FILTER_SECTION_NAME, context.getFilterSection())
|
||||
.and(FILTER_NAME, (context.getFilterName() != null && !context.getFilterName().isEmpty())
|
||||
? context.getFilterName() : KeyValue.NONE_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -686,13 +686,11 @@ public final class ObservationWebFilterChainDecorator implements WebFilterChainP
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(WebFilterChainObservationContext context) {
|
||||
KeyValues kv = KeyValues.of(CHAIN_SIZE_NAME, String.valueOf(context.getChainSize()))
|
||||
return KeyValues.of(CHAIN_SIZE_NAME, String.valueOf(context.getChainSize()))
|
||||
.and(CHAIN_POSITION_NAME, String.valueOf(context.getChainPosition()))
|
||||
.and(FILTER_SECTION_NAME, context.getFilterSection());
|
||||
if (context.getFilterName() != null) {
|
||||
kv = kv.and(FILTER_NAME, context.getFilterName());
|
||||
}
|
||||
return kv;
|
||||
.and(FILTER_SECTION_NAME, context.getFilterSection())
|
||||
.and(FILTER_NAME, (context.getFilterName() != null && !context.getFilterName().isEmpty())
|
||||
? context.getFilterName() : KeyValue.NONE_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user