Skip to content

Commit

Permalink
[GOBBLIN-2059] Send empty resource if no custom configs are specified (
Browse files Browse the repository at this point in the history
…#3939)

* Send empty resource if no custom configs are specified
  • Loading branch information
Will-Lo authored Apr 30, 2024
1 parent 4de95d6 commit 33660f5
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,17 @@ protected void initialize(State state) {
log.info("Initializing OpenTelemetry metrics");
Properties metricProps = PropertiesUtils.extractChildProperties(state.getProperties(),
ConfigurationKeys.METRICS_REPORTING_OPENTELEMETRY_CONFIGS_PREFIX);
AttributesBuilder attributesBuilder = Attributes.builder();
for (String key : metricProps.stringPropertyNames()) {
attributesBuilder.put(AttributeKey.stringKey(key), metricProps.getProperty(key));
// Default to empty resource because default resource still populates some values
Resource metricsResource = Resource.empty();
if (metricProps.isEmpty()) {
log.warn("No OpenTelemetry metrics properties found, sending empty resource");
} else {
AttributesBuilder attributesBuilder = Attributes.builder();
for (String key : metricProps.stringPropertyNames()) {
attributesBuilder.put(AttributeKey.stringKey(key), metricProps.getProperty(key));
}
metricsResource = Resource.getDefault().merge(Resource.create(attributesBuilder.build()));
}
Resource metricsResource = Resource.getDefault().merge(Resource.create(attributesBuilder.build()));

SdkMeterProvider meterProvider = SdkMeterProvider.builder()
.setResource(metricsResource)
.registerMetricReader(
Expand Down

0 comments on commit 33660f5

Please sign in to comment.