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

Use global API instances #943

Merged
merged 8 commits into from
Apr 29, 2020

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Apr 7, 2020

As discussed in the SIG and on issue #885, this uses the global object to store references to the global APIs. When an API method is called, it tries to get the global API instance by calling a method with its API version. If the version matches, the call is properly proxied through to the API, else it calls a no-op version.

@codecov-io
Copy link

codecov-io commented Apr 7, 2020

Codecov Report

Merging #943 into master will decrease coverage by 0.05%.
The diff coverage is 78.94%.

@@            Coverage Diff             @@
##           master     #943      +/-   ##
==========================================
- Coverage   94.95%   94.90%   -0.06%     
==========================================
  Files         210      212       +2     
  Lines        8571     8676     +105     
  Branches      772      791      +19     
==========================================
+ Hits         8139     8234      +95     
- Misses        432      442      +10     
Impacted Files Coverage Δ
...ckages/opentelemetry-web/test/registration.test.ts 0.00% <0.00%> (ø)
packages/opentelemetry-api/src/api/propagation.ts 46.66% <23.07%> (-10.48%) ⬇️
packages/opentelemetry-api/src/api/metrics.ts 47.61% <33.33%> (-5.72%) ⬇️
packages/opentelemetry-api/src/api/context.ts 75.00% <75.00%> (+27.94%) ⬆️
packages/opentelemetry-api/src/api/trace.ts 85.71% <90.00%> (-0.96%) ⬇️
packages/opentelemetry-api/src/api/global-utils.ts 100.00% <100.00%> (ø)
packages/opentelemetry-api/test/api/api.test.ts 96.96% <100.00%> (+0.30%) ⬆️
packages/opentelemetry-api/test/api/global.test.ts 100.00% <100.00%> (ø)
...opentelemetry-node/test/NodeTracerProvider.test.ts 100.00% <100.00%> (ø)
...kages/opentelemetry-node/test/registration.test.ts 100.00% <100.00%> (ø)
... and 10 more

@dyladan dyladan force-pushed the global-api branch 2 times, most recently from 82f13d5 to 94d557b Compare April 8, 2020 02:02
Copy link
Member

@vmarchaud vmarchaud left a comment

Choose a reason for hiding this comment

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

lgtm, i have just one question concerning the api version for each api, how do we bump them ? For each major ?

@dyladan
Copy link
Member Author

dyladan commented Apr 8, 2020

We bump them whenever we make a change that is not backwards compatible. So adding a method would not require a version bump, as an old version of the API module would simply not call that method. Removing a method that may be called by an older version of the API module would require a version bump.

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.

Added few comments.
This is just a suggestion as I don't have the whole view on the spec. But few things are repeated (setting, getting, disabling) maybe it makes sense to make some helper function / functions or class for that so the code can be reused and tested in one place ? The difference is only with global key and the returned type, so there could be some similarities. Are they going to be more globals in future too, which should be implemented the same way then ?

packages/opentelemetry-api/src/api/context.ts Show resolved Hide resolved
packages/opentelemetry-api/src/api/context.ts Outdated Show resolved Hide resolved
packages/opentelemetry-api/src/api/propagation.ts Outdated Show resolved Hide resolved
packages/opentelemetry-api/src/api/propagation.ts Outdated Show resolved Hide resolved
packages/opentelemetry-api/src/api/trace.ts Outdated Show resolved Hide resolved
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 those changes

@dyladan
Copy link
Member Author

dyladan commented Apr 24, 2020

@mayurkale22 would appreciate if you can take another look at this

@dyladan dyladan added enhancement New feature or request Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) labels Apr 28, 2020
@dyladan dyladan merged commit e4e71b8 into open-telemetry:master Apr 29, 2020
@dyladan dyladan deleted the global-api branch April 29, 2020 00:21
dyladan added a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
martinkuba pushed a commit to martinkuba/opentelemetry-js that referenced this pull request Mar 13, 2024
martinkuba pushed a commit to martinkuba/opentelemetry-js that referenced this pull request Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants