Skip to content

feat: Add enabled resource providers configuration#4231

Merged
anuraaga merged 4 commits intoopen-telemetry:mainfrom
wallezhang:add-enabled-resource-providers-configuration
Mar 9, 2022
Merged

feat: Add enabled resource providers configuration#4231
anuraaga merged 4 commits intoopen-telemetry:mainfrom
wallezhang:add-enabled-resource-providers-configuration

Conversation

@wallezhang
Copy link
Copy Markdown
Contributor

@wallezhang wallezhang commented Mar 3, 2022

Add a new configuration: otel.java.enabled.resource.providers.

All resource providers will be enabled if this configuration key is not configured, otherwise only the specific resource providers will be enabled.

If a resource provider is configured in both otel.java.enabled.resource.providers and otel.java.disabled.resource.providers, then it will be disabled.

close #4220

@wallezhang wallezhang requested a review from a user March 3, 2022 06:30
@wallezhang wallezhang requested a review from Oberon00 as a code owner March 3, 2022 06:30
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2022

Codecov Report

Merging #4231 (01cea9f) into main (2527359) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #4231      +/-   ##
============================================
+ Coverage     90.31%   90.33%   +0.02%     
+ Complexity     4749     4744       -5     
============================================
  Files           553      553              
  Lines         14600    14589      -11     
  Branches       1402     1404       +2     
============================================
- Hits          13186    13179       -7     
+ Misses          954      952       -2     
+ Partials        460      458       -2     
Impacted Files Coverage Δ
...metry/sdk/autoconfigure/ResourceConfiguration.java 100.00% <100.00%> (+7.40%) ⬆️
...etry/exporter/prometheus/PrometheusHttpServer.java 72.34% <0.00%> (-5.32%) ⬇️
...java/io/opentelemetry/api/GlobalOpenTelemetry.java 92.59% <0.00%> (ø)
...lemetry/sdk/metrics/view/MeterSelectorBuilder.java 100.00% <0.00%> (ø)
.../opentelemetry/exporter/prometheus/Serializer.java 85.29% <0.00%> (ø)
...entelemetry/exporter/prometheus/MetricAdapter.java 91.17% <0.00%> (ø)
...ry/sdk/metrics/internal/view/StringPredicates.java 66.66% <0.00%> (ø)
...ry/sdk/metrics/view/InstrumentSelectorBuilder.java 100.00% <0.00%> (ø)
...elemetry/sdk/testing/assertj/MetricAssertions.java 66.66% <0.00%> (ø)
...elemetry/sdk/testing/assertj/MetricDataAssert.java 100.00% <0.00%> (ø)
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2527359...01cea9f. Read the comment docs.

@wallezhang
Copy link
Copy Markdown
Contributor Author

TBR

}

@Test
void onlyEnabledCustomResourceProvider() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to have a unit test to verify the behavior when things are specified in both lists, especially when the same provider is in both lists.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable, I will add the missing unit tests.

Copy link
Copy Markdown
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Resource result = Resource.getDefault();

Set<String> enabledProviders =
new HashSet<>(config.getList("otel.java.enabled.resource.providers"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate that only one of these is set as it would probably result in confusing behavior?

Copy link
Copy Markdown
Contributor Author

@wallezhang wallezhang Mar 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only missing case should be only setting the otel.java.enabled.resource.providers configuration. Only setting otel.java.disabled.resource.providers configuration is validated in other test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add otel.java.enabled.resource.providers config key

3 participants