Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resource assertion methods to SpanDataAssert and MetricAssert #5160

Conversation

Donnerbart
Copy link
Contributor

@Donnerbart Donnerbart commented Jan 31, 2023

The SpanDataAssert and MetricAssert classes are missing convenient methods to assert resource attributes. The provided hasResource() quickly reaches its limits when the captured Resource is populated with (system dependent) autoconfigured values (e.g. host resources).

This PR adds a ResourceAssert class with methods to assert the resource schema URL and the resource attributes, copying the already established assertion methods from the span attributes.

See also https://cloud-native.slack.com/archives/C014L2KCTE3/p1675083869242799

@Donnerbart Donnerbart requested a review from a team January 31, 2023 21:50
@codecov
Copy link

codecov bot commented Jan 31, 2023

Codecov Report

Base: 91.00% // Head: 91.13% // Increases project coverage by +0.12% 🎉

Coverage data is based on head (e938c09) compared to base (7068cb3).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5160      +/-   ##
============================================
+ Coverage     91.00%   91.13%   +0.12%     
+ Complexity     4899     4885      -14     
============================================
  Files           549      549              
  Lines         14538    14420     -118     
  Branches       1393     1380      -13     
============================================
- Hits          13230    13141      -89     
+ Misses          906      889      -17     
+ Partials        402      390      -12     
Impacted Files Coverage Δ
...emetry/sdk/testing/assertj/AttributeAssertion.java 83.33% <ø> (ø)
...pentelemetry/sdk/testing/assertj/MetricAssert.java 100.00% <100.00%> (+4.34%) ⬆️
...ntelemetry/sdk/testing/assertj/ResourceAssert.java 100.00% <100.00%> (ø)
...ntelemetry/sdk/testing/assertj/SpanDataAssert.java 91.26% <100.00%> (+0.15%) ⬆️
...ry/sdk/metrics/internal/aggregator/Aggregator.java 33.33% <0.00%> (-54.17%) ⬇️
...trics/internal/exemplar/NoopExemplarReservoir.java 60.00% <0.00%> (-40.00%) ⬇️
...metrics/internal/view/NoopAttributesProcessor.java 75.00% <0.00%> (-25.00%) ⬇️
...dk/metrics/internal/aggregator/DropAggregator.java 35.71% <0.00%> (-8.74%) ⬇️
.../metrics/internal/aggregator/AggregatorHandle.java 88.23% <0.00%> (-5.10%) ⬇️
.../java/io/opentelemetry/api/logs/DefaultLogger.java 100.00% <0.00%> (ø)
... and 61 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Donnerbart Donnerbart force-pushed the improvement/add-resource-assertions-to-spandataassert branch 3 times, most recently from 05914cb to eccc93c Compare February 3, 2023 02:50
@Donnerbart Donnerbart force-pushed the improvement/add-resource-assertions-to-spandataassert branch 2 times, most recently from 46d4e9f to 4ad1559 Compare February 3, 2023 03:00
@Donnerbart Donnerbart changed the title Add resource assertion methods to SpanDataAssert Add resource assertion methods to SpanDataAssert and MetricAssert Feb 4, 2023
Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Couple minor comments but looks good. @jkwatson think we can get this in for tomorrow's release?

@Donnerbart Donnerbart force-pushed the improvement/add-resource-assertions-to-spandataassert branch from 4ad1559 to fa8c46f Compare February 9, 2023 20:06
@Donnerbart
Copy link
Contributor Author

Addressed the PR comments.

@Donnerbart Donnerbart force-pushed the improvement/add-resource-assertions-to-spandataassert branch from fa8c46f to 8b73cc9 Compare February 9, 2023 20:16
@Donnerbart Donnerbart force-pushed the improvement/add-resource-assertions-to-spandataassert branch from 8b73cc9 to e938c09 Compare February 9, 2023 20:31
@jack-berg jack-berg merged commit 2b7fe75 into open-telemetry:main Feb 9, 2023
@Donnerbart Donnerbart deleted the improvement/add-resource-assertions-to-spandataassert branch February 9, 2023 22:41
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.

3 participants