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(sdk-base)!: Use TypeScript overload signature for addEvent #5359

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chancancode
Copy link
Contributor

Which problem is this PR solving?

Stumbled upon this #5333. If it creates conflicts I'm perfectly happy with @brianphillips absorbing these into there.

This makes the intent more clear, and makes the invalid signature addEvent(name, timeStamp1, timeStamp2) explicitly illegal in TS.

This has always been the intent, and the textual documentation somewhat implies that already.

Technically, this is breaking change for TypeScript users. There are situations previously valid TS code will stop being accepted by the type checker, even if the code is semantically valid. It mostly arises when the caller is trying to propagate the same-ish overload signature. It can still be done safely, just requires a bit more care.

In any case, this will go into the 2.0 release so it's a great time to make this change.

That being said, the change/breakage may be too in the weeds to warrant a CHANGELOG entry? Not sure.

Short description of the changes

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • TypeScript compiles

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@chancancode chancancode requested a review from a team as a code owner January 23, 2025 02:36
@chancancode chancancode force-pushed the typescript-overload-signatures branch from df1f61c to 3198cfb Compare January 23, 2025 02:38
This makes the intent more clear, and makes the invalid signature
`addEvent(name, timeStamp1, timeStamp2)` explicitly illegal in TS.

This has always been the intent, and the textual documentation
somewhat implies that already.

Technically, this is breaking change for TypeScript users. There
are situations previously valid TS code will stop being accepted
by the type checker, even if the code is semantically valid. It
mostly arises when the caller is trying to propagate the same-ish
overload signature. It can still be done safely, just requires a
bit more care.

In any case, this will go into the 2.0 release so it's a great
time to make this change.
@chancancode chancancode force-pushed the typescript-overload-signatures branch from 3198cfb to 4f7c300 Compare January 23, 2025 02:39
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.54%. Comparing base (c00f36e) to head (4f7c300).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5359   +/-   ##
=======================================
  Coverage   94.54%   94.54%           
=======================================
  Files         318      318           
  Lines        8051     8051           
  Branches     1694     1694           
=======================================
  Hits         7612     7612           
  Misses        439      439           
Files with missing lines Coverage Δ
api/src/trace/NonRecordingSpan.ts 95.65% <100.00%> (ø)
packages/opentelemetry-sdk-trace-base/src/Span.ts 97.61% <100.00%> (ø)

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.

1 participant