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

Grpc instrumentation attributes fix #3089

Conversation

andrewzenkov
Copy link
Contributor

@andrewzenkov andrewzenkov commented Jul 13, 2022

Which problem is this PR solving?

Opentelemtry grpc instrumentation is not consistent in terms of creating grpc attributes in requests.
For example in Java/Python instrumentations it contains necessary attributes for grpc connection:

  • rpc.method
  • rpc.service
  • rpc.system

image

But these attributes are missed in js grpc instrumentation. It doesn't set attributes.
Additionally, if compare Python/Java and Nodejs attributes.
Already existing attribute rpc.method is implemented incorrectly in Nodejs.

Fixes # (issue)

Short description of the changes

  • Renamed rpc.method from grpc.method to rpc.method attribute (Client, Server)
  • Added rpc.service attribute (Client, Server)
  • Added rpc.system attribute (Client, Server)
  • Fixedrpc.method value calculating for some use case. (it should be method, but value is just full path)

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)

How Has This Been Tested?

Create GRPC example, run opentelemetry SDK using authoinstrumentation, or manually set new GrpcInstrumentation(), you will see that Grpc instrumentation detects grpc connection and creates spans but with missing attributes:

  • rpc.method (server?/client?)
  • rpc.system (server/client)
  • rpc.service (server/client)

And for client rpc.method has incorrect value.

Before:
Client/server
image

After:
Client/Server
image

@andrewzenkov andrewzenkov requested a review from a team July 13, 2022 14:00
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 13, 2022

CLA Missing ID CLA Not Signed

@@ -19,7 +19,9 @@
*/
export enum AttributeNames {
GRPC_KIND = 'grpc.kind', // SERVER or CLIENT
GRPC_METHOD = 'grpc.method',
GRPC_METHOD = 'rpc.method',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the RPC_METHOD of @opentelemetry/semantic-convention could be used for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice point, will update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@weyert, resolved
There were some issues because of Typescript
It forced me to make enum as Readonly constant

Copy link
Contributor

@weyert weyert left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@dyladan dyladan added spec-noncompliant An existing feature incorrectly or incompletely implements the OTel spec. May or may not be a bug priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect labels Jul 20, 2022
@andrewzenkov
Copy link
Contributor Author

@legendecas
Please check it out

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!


export const AttributeNames: Readonly<AttributesType> = {
RPC_SYSTEM: RPC_SYSTEM,
GRPC_METHOD: RPC_METHOD,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: might be worth preventing introducing new names for existing semantic attributes.

Suggested change
GRPC_METHOD: RPC_METHOD,
RPC_METHOD,

Copy link
Member

Choose a reason for hiding this comment

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

might be worth directy using SemanticAttributes.RPC_METHOD directly and removing it them from AttributeNames IMO

@legendecas
Copy link
Member

CLA check is still not green: #3089 (comment). You may need to revisit your commit author to ensure all your commits were authorized.


export const AttributeNames: Readonly<AttributesType> = {
RPC_SYSTEM: RPC_SYSTEM,
GRPC_METHOD: RPC_METHOD,
Copy link
Member

Choose a reason for hiding this comment

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

might be worth directy using SemanticAttributes.RPC_METHOD directly and removing it them from AttributeNames IMO

@codecov
Copy link

codecov bot commented Jul 23, 2022

Codecov Report

Merging #3089 (a334484) into main (df58fac) will decrease coverage by 0.40%.
The diff coverage is 100.00%.

❗ Current head a334484 differs from pull request most recent head 9d708eb. Consider uploading reports for the commit 9d708eb to get more accurate results

@@            Coverage Diff             @@
##             main    #3089      +/-   ##
==========================================
- Coverage   93.07%   92.67%   -0.41%     
==========================================
  Files         195      174      -21     
  Lines        6384     5513     -871     
  Branches     1347     1165     -182     
==========================================
- Hits         5942     5109     -833     
+ Misses        442      404      -38     
Impacted Files Coverage Δ
...ry-instrumentation-grpc/src/grpc-js/clientUtils.ts 92.50% <ø> (-0.10%) ⬇️
...metry-instrumentation-grpc/src/grpc/clientUtils.ts 88.23% <ø> (-0.18%) ⬇️
...y-instrumentation-grpc/src/enums/AttributeNames.ts 100.00% <100.00%> (ø)
...-instrumentation-grpc/src/enums/AttributeValues.ts 100.00% <100.00%> (ø)
...elemetry-instrumentation-grpc/src/grpc-js/index.ts 91.26% <100.00%> (+0.35%) ⬆️
...entelemetry-instrumentation-grpc/src/grpc/index.ts 93.27% <100.00%> (+0.17%) ⬆️
...es/opentelemetry-instrumentation-grpc/src/utils.ts 94.73% <100.00%> (+0.79%) ⬆️
packages/opentelemetry-resources/karma.worker.js 0.00% <0.00%> (-100.00%) ⬇️
...kages/opentelemetry-sdk-trace-base/karma.worker.js 0.00% <0.00%> (-100.00%) ⬇️
...lemetry-resources/src/detectors/BrowserDetector.ts 53.33% <0.00%> (-46.67%) ⬇️
... and 36 more

@andrewzenkov
Copy link
Contributor Author

andrewzenkov commented Jul 25, 2022

@legendecas

I can see they are not authorized
But seems like I cannot resign them without rebase
What do you think I have to do?
Is there point to create new pr based on that having clean git history?

@dyladan
Copy link
Member

dyladan commented Jul 25, 2022

Looks like some of the commits have a different author email which is making them miss out on the CLA. A rebase is probably fine since the PR squashes anyway so individual commits aren't that important.

@legendecas
Copy link
Member

@andrewzenkov I would squash the commits and reset the author email of the commits to the one correctly authorized. I'm not sure about the policy regarding merging unauthorized commits. I'd be happy to defer to @dyladan's opinion.

@dyladan
Copy link
Member

dyladan commented Jul 27, 2022

The policy is that no unauthorized commits will be merged

@andrewzenkov
Copy link
Contributor Author

@legendecas

I created new PR as extended from it with authorized commit and all necessary changes
#3127

Please add necessary labels, and mark current PR as closed or draft :)
I decided to do it, to speed up contribution and not create a mess in all stuff

@dyladan dyladan closed this Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect spec-noncompliant An existing feature incorrectly or incompletely implements the OTel spec. May or may not be a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants