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

logtest: Add Recorder #5134

Merged
merged 40 commits into from
Apr 9, 2024
Merged

logtest: Add Recorder #5134

merged 40 commits into from
Apr 9, 2024

Conversation

dmathieu
Copy link
Member

@dmathieu dmathieu commented Apr 2, 2024

This adds a Recorder into a new logtest log package, with the purpose of avoiding code repetition in each log bridge tests.

@dmathieu
Copy link
Member Author

dmathieu commented Apr 2, 2024

The links failure is expected, as the README currently points to a missing package.
Once the PR is merged, the package won't be missing anymore.

Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.9%. Comparing base (b9752eb) to head (a6d4db0).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #5134   +/-   ##
=====================================
  Coverage   83.8%   83.9%           
=====================================
  Files        254     255    +1     
  Lines      16539   16596   +57     
=====================================
+ Hits       13872   13927   +55     
- Misses      2374    2376    +2     
  Partials     293     293           
Files Coverage Δ
log/logtest/recorder.go 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

Bridges should not depend on the SDK.

I would rather prefer to have logtest with something like: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/d15fe4f317e0376ff4a65a435b785a1c88e11b7c/bridges/otelslog/handler_test.go#L35-L76.

I think we could consider adding it to the go.opentelemetry.io/otel/log module (as go.opentelemetry.io/otel/log/logtest package) because one using the Bridge API would most likely would like to test the bridge implementation using this logtest package. Then we would not need to create test modules like https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/net/http/otelhttp/test/doc.go.

Related comment: open-telemetry/opentelemetry-go-contrib#5279 (comment)

@pellared pellared added the area:logs Part of OpenTelemetry logs label Apr 3, 2024
@dmathieu dmathieu force-pushed the logtest branch 2 times, most recently from 8b23c86 to 7455f59 Compare April 3, 2024 07:31
log/logtest/config.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
log/logtest/config.go Outdated Show resolved Hide resolved
@pellared pellared changed the title Add logtest module with in-memory log exporter logtest: Add Recorder Apr 3, 2024
Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

🎉

dmathieu and others added 3 commits April 3, 2024 11:16
Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

Only non-nit is the comment about enabledFn.

log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
log/logtest/recorder.go Outdated Show resolved Hide resolved
dmathieu and others added 10 commits April 8, 2024 09:52
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
@pellared pellared requested a review from MrAlias April 8, 2024 08:09
@pellared
Copy link
Member

pellared commented Apr 8, 2024

@MadVikingGod, @dashpole, @XSAM, can you please review as it touches the API module?

Copy link
Member

@XSAM XSAM left a comment

Choose a reason for hiding this comment

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

Looks good overall

log/logtest/recorder_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

Optional suggestion

log/logtest/recorder.go Show resolved Hide resolved
@MrAlias MrAlias added this to the v1.26.0 milestone Apr 9, 2024
@MrAlias MrAlias merged commit 8d1d62b into open-telemetry:main Apr 9, 2024
26 of 27 checks passed
pellared added a commit to pellared/opentelemetry-go that referenced this pull request Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:logs Part of OpenTelemetry logs
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants