Skip to content

Instantly share code, notes, and snippets.

@Phury
Last active February 17, 2023 11:16
Show Gist options
  • Save Phury/86045f4de05f70fd7b4608e14ddf38c4 to your computer and use it in GitHub Desktop.
Save Phury/86045f4de05f70fd7b4608e14ddf38c4 to your computer and use it in GitHub Desktop.
Configure observability at smals
// configure with spring
@Configuration
public class MetricsContractConfiguration {
@Bean
public MetricContractManager sepiaMetricContractManager(MetricContractManager metricContractManager) {
metricContractManager.addContract("dss_signature_sign", "docType", "signType", "responseCode", "errorType", "callOrigin", "enterpriseNumber", "signProfile");
metricContractManager.addContract("dss_signature_timestamp");
return metricContractManager;
}
@Bean
public MetricsService metricsService(@Autowired BusinessMetricManager businessMetricManager) {
return new MetricsServiceAdapter("dss_signature_sign", businessMetricManager);
}
}
// configure the metrics
metricContractManager.addContract("dss_signature_sign", "docType", "signType", "responseCode", "errorType", "callOrigin", "enterpriseNumber", "signProfile");
metricContractManager.addContract("dss_signature_timestamp");
// add a new value to a metric
businessMetricManager.addTagToRecordingMetric(metricName, tag, value);
businessMetricManager.stopRecordingAndEmitMetricFor(metricName);
// capture the metrics
@Observe(name = "dss_signature_sign", isEmitProcessingTimeMetric = true, isStopObserveWhenException = false)
<dependency>
<groupId>be.smals.axess</groupId>
<artifactId>axess-tools.business-observability</artifactId>
<version>0.0.6</version>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment