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

refactor: simplify b3 options #2054

Merged
merged 6 commits into from
Mar 31, 2021
Merged

Conversation

mwear
Copy link
Member

@mwear mwear commented Mar 30, 2021

Which problem is this PR solving?

Short description of the changes

Based on the discussion on open-telemetry/opentelemetry-specification#1562 we always want to extract both b3 single and multi header formats. There really isn't a use case for extracting the formats individually, so this PR reduces the b3 surface area by not exporting the B3SinglePropagator or B3MultiPropagator.

  • B3MultiPropagator and B3SinglePropagator are no longer exported
  • B3 header constants where moved to a constants file and remain exported
  • Readme was updated to reflect these changes

@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #2054 (e423522) into main (239745f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head e423522 differs from pull request most recent head 5536cf3. Consider uploading reports for the commit 5536cf3 to get more accurate results

@@           Coverage Diff           @@
##             main    #2054   +/-   ##
=======================================
  Coverage   93.03%   93.03%           
=======================================
  Files         153      154    +1     
  Lines        5972     5975    +3     
  Branches     1246     1246           
=======================================
+ Hits         5556     5559    +3     
  Misses        416      416           
Impacted Files Coverage Δ
...entelemetry-propagator-b3/src/B3MultiPropagator.ts 100.00% <100.00%> (ø)
...es/opentelemetry-propagator-b3/src/B3Propagator.ts 100.00% <100.00%> (ø)
...ntelemetry-propagator-b3/src/B3SinglePropagator.ts 100.00% <100.00%> (ø)
...kages/opentelemetry-propagator-b3/src/constants.ts 100.00% <100.00%> (ø)

Copy link
Member

@naseemkullah naseemkullah left a comment

Choose a reason for hiding this comment

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

May want to add upgrade notes and flag as breaking due to export removals

api.propagation.setGlobalPropagator(new B3MultiPropagator());
```

### CompositePropagator
Copy link
Member

Choose a reason for hiding this comment

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

is CompositePropagator not allowed anymore, as with regards to possibility I think it should still be possible ?

const api = require('@opentelemetry/api');
const { B3Propagator } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(
  new CompositePropagator({
    propagators: [
      new B3Propagator(), 
      new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })
    ],
  })
);

?

Copy link
Member

Choose a reason for hiding this comment

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

By default it already extracts both. Is there a usecase where we need to also inject both? Of course you can always use a composite just like you can with any propagator, but keeping it documented feels unnecessary for such a niche usecase.

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, but we had this before so if anyone is using such case it might be hard to understand how it should be done now after these changes

Copy link
Member Author

Choose a reason for hiding this comment

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

It's still possible. I don't think it's a common use case, but we can document it.

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

Looks there are no functionality changes? Just docs and moving some constants around into their own file.

@dyladan
Copy link
Member

dyladan commented Mar 30, 2021

@obecny looks like you added breaking label but there is no functionality actually changed here.

@obecny
Copy link
Member

obecny commented Mar 30, 2021

Looks there are no functionality changes? Just docs and moving some constants around into their own file.

we have now B3Propagator previously we had B3MultiPropagator and B3SinglePropagator so once you update yr code will definitely break

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

I think we should also update all usage replacing B3Multi and B3Single with new class

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

and lastly we should add info to README.md section Upgrade Guidelines showing how to use B3 now with single and multi

B3SinglePropagator -> new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })

etc.

@dyladan
Copy link
Member

dyladan commented Mar 30, 2021

Looks there are no functionality changes? Just docs and moving some constants around into their own file.

we have now B3Propagator previously we had B3MultiPropagator and B3SinglePropagator so once you update yr code will definitely break

I think we should also update all usage replacing B3Multi and B3Single with new class

and lastly we should add info to README.md section Upgrade Guidelines showing how to use B3 now with single and multi

B3SinglePropagator -> new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })

etc.

There is no new class. We already have B3MultiPropagator (for multi-header), B3SinglePropagator (for single-header), and B3Propagator (which uses both for incoming and only uses one for outgoing depending on config). This PR doesn't change that.

@obecny
Copy link
Member

obecny commented Mar 30, 2021

There is no new class. We already have B3MultiPropagator (for multi-header), B3SinglePropagator (for single-header), and B3Propagator (which uses both for incoming and only uses one for outgoing depending on config). This PR doesn't change that.

Am I the only one that see that both classes B3MultiPropagator and B3SinglePropagator has been removed from index.ts and they are not exported anymore thus cannot be used by users after this change ?

@dyladan
Copy link
Member

dyladan commented Mar 30, 2021

Oh I see. @mwear was that an intended change?

@vmarchaud
Copy link
Member

vmarchaud commented Mar 30, 2021

Oh I see. @mwear was that an intended change?

I think it is exactly what changed, end users should always use multi b3 propagator and configure it to use only single or only multi headers if they dont want both

@mwear
Copy link
Member Author

mwear commented Mar 30, 2021

Oh I see. @mwear was that an intended change?

Yeah, that was the intention of this PR and a result of a discussion from the spec repo, namely this comment: open-telemetry/opentelemetry-specification#1562 (comment). We had a number of ways to configure b3, but we probably want to steer users towards using the B3Propagator. Its implementation will match the OTel implementations in other languages.

I'll address upgrade notes and other docs concerns.

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

lgtm, thx for changes

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.

Simplify B3 options
5 participants