Skip to content

Commit

Permalink
expose platform and application version as opentelemetry metric
Browse files Browse the repository at this point in the history
365941

see 14cf2df
  • Loading branch information
brunokoeferli committed May 14, 2024
1 parent dd6d295 commit 865d0a2
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2024 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -25,6 +25,8 @@
import org.eclipse.scout.rt.platform.config.AbstractStringConfigProperty;
import org.eclipse.scout.rt.platform.config.CONFIG;
import org.eclipse.scout.rt.platform.config.PlatformConfigProperties.ApplicationNameProperty;
import org.eclipse.scout.rt.platform.config.PlatformConfigProperties.ApplicationVersionProperty;
import org.eclipse.scout.rt.platform.config.PlatformConfigProperties.PlatformVersionProperty;
import org.eclipse.scout.rt.platform.opentelemetry.IHistogramViewHintProvider;
import org.eclipse.scout.rt.platform.opentelemetry.IMetricProvider;
import org.slf4j.Logger;
Expand Down Expand Up @@ -117,10 +119,17 @@ protected Map<String, String> getDefaultProperties() {
defaultConfig.put("otel.metric.export.interval", "30000"); // 30s

defaultConfig.put("otel.service.name", CONFIG.getPropertyValue(ApplicationNameProperty.class));
defaultConfig.put("otel.resource.attributes", "service.instance.id=" + NodeId.current().unwrapAsString());
defaultConfig.put("otel.resource.attributes", String.join(",",
toResourceAttribute("service.instance.id", NodeId.current().unwrapAsString()),
toResourceAttribute("scout.platform.version", CONFIG.getPropertyValue(PlatformVersionProperty.class)),
toResourceAttribute("scout.application.version", CONFIG.getPropertyValue(ApplicationVersionProperty.class))));
return defaultConfig;
}

protected String toResourceAttribute(String key, String value) {
return key + "=" + value;
}

protected SdkMeterProviderBuilder customizeMeterProvider(SdkMeterProviderBuilder builder, ConfigProperties config) {
for (IHistogramViewHintProvider viewHintProvider : BEANS.all(IHistogramViewHintProvider.class)) {
LOG.info("Initialize view from {}", viewHintProvider.getClass().getName());
Expand Down

0 comments on commit 865d0a2

Please sign in to comment.