Skip to content

feat: stabilization of opentelemetry-etw-logs #247

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

Merged
merged 95 commits into from
Jun 16, 2025

Conversation

psandana
Copy link
Contributor

@psandana psandana commented Apr 11, 2025

Fixes #
Design discussion issue (if applicable) #

Changes

Changing from a trait extension to a LogProcessor factory.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@psandana psandana requested a review from a team as a code owner April 11, 2025 21:03
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 99.05063% with 3 lines in your changes missing coverage. Please review.

Project coverage is 49.5%. Comparing base (ea3320a) to head (ebf17c1).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...pentelemetry-etw-logs/src/logs/exporter/options.rs 97.2% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #247     +/-   ##
=======================================
+ Coverage   48.0%   49.5%   +1.5%     
=======================================
  Files         60      60             
  Lines       8576    8760    +184     
=======================================
+ Hits        4121    4342    +221     
+ Misses      4455    4418     -37     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@psandana psandana changed the title feat: Use "Log" as default event name feat: Add "Log" as default event name Apr 22, 2025
@psandana psandana changed the title feat: Add "Log" as default event name feat: Event mapping support on target attribute Apr 22, 2025
@psandana
Copy link
Contributor Author

psandana commented Jun 2, 2025

Thanks! The direction looks good, here are few things we need to reconsider

  1. Please remove all changes unrelated to changing from "with_etw" to the processor builder pattern. Large PRs gets harder to review, especially when new commits are pushed.
  2. Unsure if we should use a totally different approach of returning Errors here - I suggest to stick with returning Box for now.
  3. user-events did recent refactor to support the new processor builder, see if we can make it consistent with that. I think we should simplify code bit more to make it easier to follow, left some comments about this in couple of places.

Hi @cijothomas . I reworked the PR using the feedback provided. Errors are Boxed and simplified things. Please review.

@@ -11,15 +11,19 @@ keywords = ["opentelemetry", "log", "trace", "etw"]
license = "Apache-2.0"

[dependencies]
tracelogging_dynamic = "1.2.4"
chrono = { version = "0.4.40", default-features = false, features = [
Copy link
Member

Choose a reason for hiding this comment

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

its hard to tell if this file actually has changes or not..looks like just re-arranging ? please remove unrelated changes from this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I won't trim this PR further. Please, accept this PR as is. Subsequent ones should be small, incremental changes.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I don't follow. Does this file actually have any changes or just re-arranging the order?
Its putting unnecessary burden on reviewers to closely check and confirm if this is actually changed or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, this is a limitation of the diff tool and how git works. At this time, is only reordering.

The project does not have a toml formatting, causing this kind of inconsistencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its putting unnecessary burden on reviewers to closely check and confirm if this is actually changed or not.

I’m with @cijothomas on this. Simplifying the PR for review not only helps reviewers but also benefits the author by increasing the chances of a quicker merge. In this case, the only intended change appears to be the removal of microbench from the dev dependencies. Ideally, that should have been the sole modification, without reordering the other dependencies.

The project does not have a toml formatting, causing this kind of inconsistencies.

It’s usually a good idea to stick to the existing style, formatting, or conventions used in the project when sending in PRs. If there doesn’t seem to be a clear standard yet, it might be better to open a separate PR to introduce one, rather than mixing style changes into an unrelated change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know it may help to have smaller targeted PRs, but at the same time, there has been a lot of back and forth in design and decisions that makes it difficult to track in smaller PRs at this moment.

We added more deps on this PR initially, then we removed some of them. That, in combination with leaving the files better than before, led to the changes as you see today. For me, this is a motto: leave everything better than was before. I know this can be noisier to review, but the idea is to pay this cost once (now), than in the future.

Copy link
Member

Choose a reason for hiding this comment

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

Totally fine with the idea of improving everything, but please do it only in own, separate PRs.

///
/// The resulting name must be a valid CommonSchema 4.0 TraceLoggingDynamic event name. Otherwise,
/// the default "Log" ETW event name will be used.
pub fn etw_event_name_from_callback(
Copy link
Member

Choose a reason for hiding this comment

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

Please see the discussion here : #275 (comment)

We need to decide how best to handle this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw that discussion. I propose we merge this PR without releasing a version yet. Once we agree upon a design, we change in both etw and ue exporters.

Copy link
Member

Choose a reason for hiding this comment

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

please add a TODO or something to indicate this needs to be discussed further. Okay to merge with this.

use tracing_subscriber::prelude::*;

let processor = Processor::builder("provider-name")
.etw_event_name_from_callback(|_| "CustomEvent")
Copy link
Member

Choose a reason for hiding this comment

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

unsure what is the validation this test is doing? I see "CustomEvent" is returned, but there is no validation.. Is this test just to ensure no panic etc. occurs? Please add a small comment so its easy to tell the intent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an integration test at this moment. Renamed to tracing_integration_test. We can move it to the tests folder (we should create it) if you prefer, either on this PR or a new one.

Copy link
Member

Choose a reason for hiding this comment

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

My comment was more about - "There are not asserts in the test, so what is the purpose of the test"?

.etw_event_name_from_callback(|log_record| log_record.event_name().unwrap_or_default());

let result = options.get_etw_event_name(&log_record);
assert_eq!(result, "Log");
Copy link
Member

Choose a reason for hiding this comment

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

interesting that "Log" is still the name, though the callback is always returning something... Is this trying to test that invalid_event_name_from_callback_will_use_default ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not surprising, the name initially is empty, thus the validation, in its current basic form, fails and default to "Log".

Copy link
Member

Choose a reason for hiding this comment

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

Got it. It's better to have a targeted test for the same. invalid_event_name_from_callback_will_use_default would be my suggestion.

Not a blocker.

let result = options.get_etw_event_name(&log_record);
assert_eq!(result, "Log");

log_record.set_target("target-name");
Copy link
Member

Choose a reason for hiding this comment

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

what happens if we pass empty string to target?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Depends on the callback given. Assuming the callback is returning the target, the current validation will discard it because it is empty and return the default "Log".

}

#[test]
fn test_get_event_name_from_callback_returning_target() {
Copy link
Member

Choose a reason for hiding this comment

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

not sure what are these tests trying to test. For the callback, we just take the name from the callback - does it matter where/how the callback is returning the value from? It can do it from event_name or target or static.. doesn't matter.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

LGTM

@cijothomas cijothomas merged commit d8f105e into open-telemetry:main Jun 16, 2025
22 checks passed
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.

8 participants