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

fix(net.peer.port): net.peer.port needs to be a number not a string #1916

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

esara
Copy link
Contributor

@esara esara commented Jan 28, 2024

I noticed that a number of contrib instrumentation populated the net.peer.port as a string parsed out of the connection string. This not only violates the semantic convensations, but in same cases causes and exception the the span attributes are parsed. https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/trace/semantic_conventions/database.md#connection-level-attributes

Which problem is this PR solving?

This is related to #781
More specifically, there is an inconsistency, where the port variable is a string in multiple instrumentation (memcached, mongodb, mysql/mysql2, mongodb) for example
https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts#L802
compared to other instrumentation, where is correctly defined as an int (cassandra and others)
https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts#L179

Short description of the changes

Making sure that the net.peer.port attribute is a number instead of a string

BEGIN_COMMIT_OVERRIDE
fix(instrumentation-memcached): parse attribute value for net.peer.port to a number
fix(instrumentation-mongodb): parse attribute value for net.peer.port to a number
fix(instrumentation-mysql): parse attribute value for net.peer.port to a number
fix(instrumentation-mysql2): parse attribute value for net.peer.port to a number
END_COMMIT_OVERRIDE

@esara esara requested a review from a team January 28, 2024 19:06
Copy link

linux-foundation-easycla bot commented Jan 28, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@esara esara changed the title net.peer.port needs to be a number not a string fix(net.peer.port): net.peer.port needs to be a number not a string Jan 28, 2024
@esara esara force-pushed the netpeerport branch 2 times, most recently from 5f1372f to c9b3671 Compare February 4, 2024 15:56
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Looks good! 🙂
Thanks for taking care of this. 🙂

Copy link

codecov bot commented Feb 5, 2024

Codecov Report

Merging #1916 (2768981) into main (5b0b67f) will decrease coverage by 0.03%.
The diff coverage is 93.33%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1916      +/-   ##
==========================================
- Coverage   91.02%   91.00%   -0.03%     
==========================================
  Files         146      146              
  Lines        7478     7491      +13     
  Branches     1497     1502       +5     
==========================================
+ Hits         6807     6817      +10     
- Misses        671      674       +3     
Files Coverage Δ
...try-instrumentation-mongodb/src/instrumentation.ts 53.27% <100.00%> (+0.42%) ⬆️
...e/opentelemetry-instrumentation-mysql/src/utils.ts 97.72% <100.00%> (-2.28%) ⬇️
.../opentelemetry-instrumentation-mysql2/src/utils.ts 96.96% <100.00%> (-3.04%) ⬇️
...entelemetry-instrumentation-memcached/src/utils.ts 80.00% <80.00%> (-1.25%) ⬇️

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Ah looks like the tests also need to be updated (they assert that the values are strings, instead of number)

@esara
Copy link
Contributor Author

esara commented Feb 13, 2024

Ah looks like the tests also need to be updated (they assert that the values are strings, instead of number)

@pichlermarc let me know if the test look better now

@esara esara force-pushed the netpeerport branch 2 times, most recently from 45cdd3d to 6c7e62e Compare February 14, 2024 01:16
@pichlermarc
Copy link
Member

@esara, please don't force-push. It makes it hard to review the PR because the history disappears every time I check back 😅

(also makes it hard to see if the tests were passing as I have to dig into old workflow runs to find the run that was associated with the commit before the force-push)

@pichlermarc pichlermarc merged commit 038e0bf into open-telemetry:main Feb 19, 2024
17 checks passed
@esara esara deleted the netpeerport branch March 18, 2024 01:12
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.

6 participants