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

chore(instrumentation-pg): Inline incubating constants from @opentelemetry/semantic-conventions #2599

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nwalters512
Copy link
Contributor

@nwalters512 nwalters512 commented Dec 10, 2024

Which problem is this PR solving?

No other instrumentation packages pin @opentelemetry/semantic-conventions, and from what I can tell, there's no good reason that @opentelemetry/instumentation-pg should be pinning it. When the dependency is pinned, npm can't dedupe it to a higher version, which results in multiple versions of this package being installed.

As decided in open-telemetry/opentelemetry-js#5182 (comment), incubating constants from @opentelemetry/semantic-conventions should be inlined instead of pinning @opentelemetry/semantic-conventions to a particular version.

Short description of the changes

In @opentelemetry/instrumentation-pg, @opentelemetry/semantic-conventions now uses a ^ semver range to allow newer minor versions to be installed.

This PR updates @opentelemetry/instrumentation-pg to include inlined copies of the experimental constants it needs. This, in turn, allows us to unpin @opentelemetry/semantic-conventions.

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.79%. Comparing base (91c9089) to head (6a07e55).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2599      +/-   ##
==========================================
+ Coverage   90.78%   90.79%   +0.01%     
==========================================
  Files         169      170       +1     
  Lines        8055     8064       +9     
  Branches     1643     1643              
==========================================
+ Hits         7313     7322       +9     
  Misses        742      742              
Files with missing lines Coverage Δ
...elemetry-instrumentation-pg/src/instrumentation.ts 90.21% <ø> (ø)
...try-instrumentation-pg/src/semantic-conventions.ts 100.00% <100.00%> (ø)
...node/opentelemetry-instrumentation-pg/src/utils.ts 97.65% <ø> (ø)

@maryliag
Copy link
Contributor

The reason for this versioning being pinned, it's because this package is using the incubating entrypoint, which may break on minor bumps.
This was added on purpose here: #2473
Once it's no longer using the incubating, it can be unpinned.

I see other packages that use the incubating entrypoint are not pinning the value, like this one. @pichlermarc do you know if this was just a mistake or we can now unpin for these cases?

@nwalters512
Copy link
Contributor Author

Ah! Apologies, I didn't go digging deep enough. In that case, can I just change this PR to pin to 1.28.0 so that it will be deduped by package managers (at least until 1.29.0 comes out)?

@pichlermarc
Copy link
Member

pichlermarc commented Dec 11, 2024

I see other packages that use the incubating entrypoint are not pinning the value, like this one. @pichlermarc do you know if this was just a mistake or we can now unpin for these cases?

Hi 🙂 I'd say it's a mistake. When using the incubating entrypoint, we should always pin for now until we have a decision on open-telemetry/opentelemetry-js#5182. Sorry for the inconvenience.

@maryliag
Copy link
Contributor

Hi @nwalters512 , looks like we will go with a different approach of copying those specific values from the incubation, see more here: open-telemetry/opentelemetry-js#5182 (comment)

I would be happy to review if that is something you want to work on.

@nwalters512
Copy link
Contributor Author

@maryliag I'd be happy to open some PRs for this! I'll work on instrumentation-pg to start, and I can follow up with other packages that are using the incubating entrypoint.

@maryliag
Copy link
Contributor

thank you @nwalters512!

@nwalters512 nwalters512 changed the title chore(instrumentation-pg): Unpin @opentelemetry/semantic-conventions chore(instrumentation-pg): Inline incubating constants from @opentelemetry/semantic-conventions Dec 11, 2024
Copy link
Contributor Author

@nwalters512 nwalters512 left a comment

Choose a reason for hiding this comment

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

@maryliag I repurposed this PR to include the inlining of the relevant constants.

@@ -65,7 +65,7 @@ import {
METRIC_DB_CLIENT_OPERATION_DURATION,
ATTR_DB_NAMESPACE,
ATTR_DB_OPERATION_NAME,
} from '@opentelemetry/semantic-conventions/incubating';
} from './semantic-conventions';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

open-telemetry/opentelemetry-js#5182 (comment) suggested using semconv.ts; I went with semantic-conventions.ts since it directly matches the package name. Happy to use the other suggestion if that's strongly preferred.

Comment on lines +1 to +4
/**
* These constants are considered experimental exports of `@opentelemetry/semantic-conventions`.
* They're being inlined until they're officially exported by `@opentelemetry/semantic-conventions`.
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This little comment will appear at the top of this file in other packages; let's workshop it if needed before it proliferates.

/**
* The number of connections that are currently in state described by the `state` attribute
*
* @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied these all in full, including the "experimental" warning. Happy to edit this to remove it desired.

@nwalters512
Copy link
Contributor Author

Sorry about the failing tests, I'll get those fixed up.

@maryliag
Copy link
Contributor

Thank you for working on this!

@trentm would you mind confirming if that is what you had in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants