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

W3C Trace propagator tests - switch to level 1 #4937

Merged

Conversation

Kielek
Copy link
Contributor

@Kielek Kielek commented Oct 9, 2023

Fixes test_tracestate_duplicated_keys from w3c test suite

Follow up to #4893, there will be one more PR to fix random flags.

Ref: https://github.com/w3c/trace-context/blob/551a5b0855171281e98b4c2a814bf9e1f837cd53/test/test.py#L565-L567

Changes

Duplicated keys are fully propagated now. It allows to drop creating HashSet for each propagation execution. Now only counter is created.

Opposite option, propagate only one value for given key. I think that it requires keeping HashSet.

Switch W3C Trace tests to level 1, based on: #4937 (comment)

Merge requirement checklist

  • CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • [ ] Appropriate CHANGELOG.md files updated for non-trivial changes
  • [ ] Changes in public API reviewed (if applicable)

@Kielek Kielek requested a review from a team October 9, 2023 07:30
@Kielek Kielek force-pushed the fix-test_tracestate_duplicated_keys branch from 90bde8d to b43bdfb Compare October 9, 2023 07:43
@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

Merging #4937 (904935a) into main (d1d6d4b) will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4937      +/-   ##
==========================================
- Coverage   83.42%   83.39%   -0.04%     
==========================================
  Files         296      296              
  Lines       12377    12377              
==========================================
- Hits        10326    10322       -4     
- Misses       2051     2055       +4     
Flag Coverage Δ
unittests 83.39% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 7 files with indirect coverage changes

@Kielek Kielek force-pushed the fix-test_tracestate_duplicated_keys branch from b43bdfb to e785a3a Compare October 9, 2023 07:57
@@ -294,19 +294,13 @@ internal static bool TryExtractTracestate(string[] tracestateCollection, out str
return false;
}

// ValidateKey() call above has ensured the key does not contain upper case letters.
if (!keySet.Add(key.ToString()))
Copy link
Contributor

@utpilla utpilla Oct 10, 2023

Choose a reason for hiding this comment

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

https://github.com/w3c/trace-context/blob/551a5b0855171281e98b4c2a814bf9e1f837cd53/test/test.py#L565-L567

expects the tracestate to be inherited, and the duplicated keys to be either kept as-is or one of them to be discarded

Could we discard the duplicate ones instead of keeping them? We are only allowed 32 keys. Why waste them by storing duplicates when we could make room for other unique keys?

Copy link
Contributor Author

@Kielek Kielek Oct 10, 2023

Choose a reason for hiding this comment

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

I have tried to answer in PR description on it what was the reason for the change:

Duplicated keys are fully propagated now. It allows to drop creating HashSet for each propagation execution. Now only counter is created.

If you think that it is worth to keep the checj, I can update this PR.

Copy link
Contributor

@utpilla utpilla Oct 11, 2023

Choose a reason for hiding this comment

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

On second thought, I think we could just keep the key as-is in favor of performance as this would be exectued in the hot-path.

@alanwest @CodeBlanch @vishweshbankwar It would be great to know your thoughts as well.

Copy link
Member

Choose a reason for hiding this comment

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

I am good to keep this as spec allows it.
Not for this PR - It would be good to check how other languages are doing it (would be good to keep consistent behavior)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pellared
Copy link
Member

Comment on lines 196 to 197
Assert.Equal("foo=1,foo=1", CallTraceContextPropagator("foo=1,foo=1"));
Assert.Equal("foo=1,foo=2", CallTraceContextPropagator("foo=1,foo=2"));
Copy link
Member

@alanwest alanwest Oct 16, 2023

Choose a reason for hiding this comment

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

Is this the correct behavior or is the behavior in @pellared's PR for opentelemetry-go correct? That is:

Assert.Equal("foo=1,foo=1", CallTraceContextPropagator("foo=1"));
Assert.Equal("foo=1,foo=2", CallTraceContextPropagator("foo=1"));

Copy link
Member

Choose a reason for hiding this comment

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

Ok, nevermind. After speaking with @utpilla, sounds like both behaviors are correct and left up to the implementation.

@alanwest
Copy link
Member

Cross-posting open-telemetry/opentelemetry-go#4638 (comment)

Not sure I understand... should this PR become a draft too because the W3C spec has not yet clarified the behavior?

@pellared
Copy link
Member

Cross-posting open-telemetry/opentelemetry-go#4638 (comment)

Not sure I understand... should this PR become a draft too because the W3C spec has not yet clarified the behavior?

Also because W3C spec is not released.

@utpilla
Copy link
Contributor

utpilla commented Oct 17, 2023

Cross-posting open-telemetry/opentelemetry-go#4638 (comment)

Not sure I understand... should this PR become a draft too because the W3C spec has not yet clarified the behavior?

Also because W3C spec is not released.

@pellared I don't follow. Are there any specific links that you're looking at to determine the readiness of the W3C spec? We are trying to find out if it's okay for us to merge the changes proposed in this PR.

@pellared
Copy link
Member

Cross-posting open-telemetry/opentelemetry-go#4638 (comment)

Not sure I understand... should this PR become a draft too because the W3C spec has not yet clarified the behavior?

Also because W3C spec is not released.

@pellared I don't follow. Are there any specific links that you're looking at to determine the readiness of the W3C spec? We are trying to find out if it's okay for us to merge the changes proposed in this PR.

  1. The changes from Specify uniqueness of tracestate keys as the sender's responsibility w3c/trace-context#477 are not part of the released W3C Trace stable release. See https://www.w3.org/TR/trace-context/#combined-header-value vs https://w3c.github.io/trace-context/#combined-header-value. They are only in the draft.
  2. I am not sure even certain if the specification clearly defines the changes proposed in this PR. I created Document handling of tracestate duplicate keys w3c/trace-context#548

CC @reyang

@Kielek
Copy link
Contributor Author

Kielek commented Oct 18, 2023

I will try to add more comment here.

When the docker test image the latest commit from

RUN git clone https://github.com/w3c/trace-context.git
is downloaded. Then the OTel implementation of propagator is executed against latest changes from https://github.com/w3c/trace-context repository.

There are 2 versions of the specification:

Changes in tests w3c/trace-context#477 was merged in 2022, so after the Level 1 was released.

I see two options to proceed here:

  1. Start executing tests on Level 1 whish is stable.
  2. Keep executing tests for Level 2 which is in lets say RC phase.

For both cases test suited should be fetched from exact commit instead of the latest main.

@utpilla
Copy link
Contributor

utpilla commented Oct 19, 2023

I will try to add more comment here.

When the docker test image the latest commit from

RUN git clone https://github.com/w3c/trace-context.git

is downloaded. Then the OTel implementation of propagator is executed against latest changes from https://github.com/w3c/trace-context repository.
There are 2 versions of the specification:

Changes in tests w3c/trace-context#477 was merged in 2022, so after the Level 1 was released.

I see two options to proceed here:

  1. Start executing tests on Level 1 whish is stable.
  2. Keep executing tests for Level 2 which is in lets say RC phase.

For both cases test suited should be fetched from exact commit instead of the latest main.

I think we should aim for complying with the stable spec.

@alanwest Thoughts?

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Oct 27, 2023
@Kielek Kielek force-pushed the fix-test_tracestate_duplicated_keys branch from c52d2a4 to f6b2d2a Compare October 27, 2023 11:21
@Kielek Kielek changed the title Fix test_tracestate_duplicated_keys W3Trace propagator tests - switch to level 1 Oct 27, 2023
@Kielek Kielek changed the title W3Trace propagator tests - switch to level 1 W3C Trace propagator tests - switch to level 1 Oct 27, 2023
@Kielek
Copy link
Contributor Author

Kielek commented Oct 27, 2023

@utpilla, @alanwest, @vishweshbankwar, please review once more time. The PR is fully changed - tests are now executed based on Level 1 of specification (and passing on .NET7).

See: f6b2d2a

@Kielek
Copy link
Contributor Author

Kielek commented Oct 27, 2023

.NET8 failure seems to be unrelated to changes. Please rerun.

@github-actions github-actions bot removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Oct 28, 2023
@utpilla utpilla merged commit ff9912f into open-telemetry:main Nov 1, 2023
35 checks passed
@Kielek Kielek deleted the fix-test_tracestate_duplicated_keys branch November 1, 2023 10:57
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.

5 participants