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

[mdatagen] generate utility code to test telemetry #10212

Merged

Conversation

codeboten
Copy link
Contributor

This will allow components to more easily test the telemetry they should be emitting.

codeboten added 2 commits May 22, 2024 15:27
This will allow components to more easily test the telemetry they should be emitting.

Signed-off-by: Alex Boten <[email protected]>
@codeboten codeboten marked this pull request as ready for review May 23, 2024 18:39
@codeboten codeboten requested review from a team and atoulme May 23, 2024 18:39
Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 92.54%. Comparing base (5ba6000) to head (82548ce).

Files Patch % Lines
cmd/mdatagen/internal/samplereceiver/factory.go 60.00% 1 Missing and 1 partial ⚠️
cmd/mdatagen/main.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10212   +/-   ##
=======================================
  Coverage   92.53%   92.54%           
=======================================
  Files         387      387           
  Lines       18191    18198    +7     
=======================================
+ Hits        16833    16841    +8     
+ Misses       1019     1016    -3     
- Partials      339      341    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Alex Boten <[email protected]>
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

This looks really nice! Just a couple of comments around a possible shutdown function, but LGTM otherwise.

"go.opentelemetry.io/collector/receiver/receivertest"
)

type componentTestTelemetry struct {
Copy link
Member

Choose a reason for hiding this comment

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

would it make sense to provide a "Reset" function here, so that multiple tests can exist without re-creating test settings for each case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to add this as needed. I suspect it will be needed sooner than later but this particular PR doesn't need it just yet

reader := sdkmetric.NewManualReader()
return componentTestTelemetry{
reader: reader,
meterProvider: sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader)),
Copy link
Member

Choose a reason for hiding this comment

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

I think either the metric provider or the manual reader needs to be shutdown after the test. Perhaps store the mp somewhere, and provide a shutdown function?

Copy link
Member

Choose a reason for hiding this comment

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

Definitely would be good to have a Shutdown(context) on the componentTestTelemetry struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shutdown added and used in the samplereceiver test

reader := sdkmetric.NewManualReader()
return componentTestTelemetry{
reader: reader,
meterProvider: sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader)),
Copy link
Member

Choose a reason for hiding this comment

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

Definitely would be good to have a Shutdown(context) on the componentTestTelemetry struct.

@codeboten codeboten merged commit 2940226 into open-telemetry:main May 27, 2024
47 of 48 checks passed
@codeboten codeboten deleted the codeboten/add-mdatagen-testutility branch May 27, 2024 16:09
@github-actions github-actions bot added this to the next release milestone May 27, 2024
steves-canva pushed a commit to Canva/opentelemetry-collector that referenced this pull request Jun 14, 2024
)

This will allow components to more easily test the telemetry they should
be emitting.

---------

Signed-off-by: Alex Boten <[email protected]>
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