Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Use semver to determine API compatibility #10

Merged
merged 5 commits into from
Feb 26, 2021

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Feb 24, 2021

Replaces #6 and depends on #9. This will be kept as a draft until #9 merges.

This PR introduces the ability for the API to use its version to determine compatibility with the global API instance in a semver compatible manner, replacing the API_COMPATIBILITY_VERSION constant which had to be manually incremented.

In order to do this, it introduces registerGlobal and unregisterGlobal functions.

registerGlobal

Takes a string which identifies the API type and an instance of that API. Checks that no API of that name has been registered. Also checks that it is compatible with previously registered API types so that we can be sure interoperation between APIs is safe. This is not exported and is not meant to be called by end users directly.

unregisterGlobal

This is called when the user disables an API. It removes the globally registered API instance identified by the string. This is not exported and is not meant to be called by end users directly.

@codecov
Copy link

codecov bot commented Feb 24, 2021

Codecov Report

Merging #10 (127b712) into main (9ef335b) will increase coverage by 0.87%.
The diff coverage is 96.80%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
+ Coverage   93.77%   94.65%   +0.87%     
==========================================
  Files          37       39       +2     
  Lines         466      505      +39     
  Branches       75       80       +5     
==========================================
+ Hits          437      478      +41     
+ Misses         29       27       -2     
Impacted Files Coverage Δ
src/internal/global-utils.ts 90.32% <90.32%> (ø)
src/api/context.ts 96.42% <100.00%> (+2.67%) ⬆️
src/api/diag.ts 100.00% <100.00%> (+2.56%) ⬆️
src/api/propagation.ts 100.00% <100.00%> (+6.66%) ⬆️
src/api/trace.ts 95.83% <100.00%> (+2.97%) ⬆️
src/internal/semver.ts 100.00% <100.00%> (ø)
src/version.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ef335b...9d4eb29. Read the comment docs.

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.

nit pick, otherwise lgtm

This will prevent any chance of a version X API interfering with a
version Y API if X and Y are different major versions.
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

@dyladan dyladan added the enhancement New feature or request label Feb 26, 2021
@dyladan dyladan merged commit 92c1700 into open-telemetry:main Feb 26, 2021
@dyladan dyladan deleted the semver-compatibility-rebase branch February 26, 2021 19:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants