phet commented on code in PR #3939:
URL: https://github.com/apache/gobblin/pull/3939#discussion_r1585430217
##########
gobblin-metrics-libs/gobblin-metrics/src/main/java/org/apache/gobblin/metrics/OpenTelemetryMetrics.java:
##########
@@ -86,12 +86,16 @@ 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));
+ 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()));
Review Comment:
maybe add comment on why better NOT to go ahead w/ using
`Resource.getDefault()` if no attrs sent. I might think the default resource
could be independent of attrs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]