Skip to content

Commit

Permalink
Add resource attributes to all observations
Browse files Browse the repository at this point in the history
  • Loading branch information
amvanbaren committed Feb 22, 2024
1 parent 6dbba8e commit 1c54327
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* ****************************************************************************** */
package org.eclipse.openvsx.metrics;

import io.micrometer.common.KeyValue;
import io.micrometer.observation.ObservationFilter;
import io.micrometer.observation.ObservationRegistry;
import io.micrometer.observation.aop.ObservedAspect;
import org.springframework.context.annotation.Bean;
Expand All @@ -22,4 +24,12 @@ public class MetricsConfiguration {
public ObservedAspect observedAspect(ObservationRegistry observationRegistry) {
return new ObservedAspect(observationRegistry, new RegistryObservationConvention());
}

@Bean
public ObservationFilter observationFilter() {
return context -> context
.addLowCardinalityKeyValue(KeyValue.of("service.name", "test-app"))
.addLowCardinalityKeyValue(KeyValue.of("deployment.environment", "staging"))
.addLowCardinalityKeyValue(KeyValue.of("service.instance.id", "open-vsx-org-staging"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ public RegistryObservationConvention() {
this.mapper = new ObjectMapper();
}

public KeyValues getLowCardinalityKeyValues(ObservedAspect.ObservedAspectContext context) {
var keyValues = new KeyValue[] {
KeyValue.of("resource.service.name", "test-app"),
KeyValue.of("resource.deployment.environment", "staging"),
KeyValue.of("resource.service.instance.id", "open-vsx-org-staging")
};
return ObservationConvention.super.getHighCardinalityKeyValues(context).and(keyValues);
}

@Override
public KeyValues getHighCardinalityKeyValues(ObservedAspect.ObservedAspectContext context) {
var joinPoint = context.getProceedingJoinPoint();
Expand Down

0 comments on commit 1c54327

Please sign in to comment.