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-grpc): cleanup remnants of grpc-native support #3886

Merged
merged 19 commits into from
Jul 4, 2023

Conversation

llc1123
Copy link
Contributor

@llc1123 llc1123 commented Jun 12, 2023

Which problem is this PR solving?

Fixes #3869

Short description of the changes

  • Removed all import * from '@grpc/grpc-js' and use destructuring imports instead.
  • Removed passing grpc instance as a parameter.
    • grpcClient in getMetadata()
    • grpcClient in _patchClient()
    • grpcClient in _patchLoadPackageDefinition()
    • grpcClient in _getPatchedClientMethods()
    • grpcClient in _patchLoadedPackage()
    • metadata in shouldNotTraceServerCall()
      *idk if this one should be removed but metadata is not used in this function and it's not exported outside the package.
  • Removed related tests.

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

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

  • Existing Tests

Checklist:

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

@llc1123 llc1123 requested a review from a team June 12, 2023 12:43
@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #3886 (6caaa95) into main (c51c9eb) will increase coverage by 1.98%.
The diff coverage is 96.96%.

❗ Current head 6caaa95 differs from pull request most recent head faf08ca. Consider uploading reports for the commit faf08ca to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3886      +/-   ##
==========================================
+ Coverage   91.15%   93.14%   +1.98%     
==========================================
  Files         127      298     +171     
  Lines        2747     8868    +6121     
  Branches      548     1826    +1278     
==========================================
+ Hits         2504     8260    +5756     
- Misses        243      608     +365     
Impacted Files Coverage Δ
...emetry-instrumentation-grpc/src/instrumentation.ts 72.72% <50.00%> (ø)
...ry-instrumentation-grpc/src/grpc-js/clientUtils.ts 92.85% <100.00%> (ø)
...elemetry-instrumentation-grpc/src/grpc-js/index.ts 92.68% <100.00%> (ø)
...ry-instrumentation-grpc/src/grpc-js/serverUtils.ts 91.78% <100.00%> (ø)
...es/opentelemetry-instrumentation-grpc/src/utils.ts 82.69% <100.00%> (ø)

... and 184 files with indirect coverage changes

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

Generally looks good to me. I think removing metadata from shouldNotTraceServerCall is fine since it is unused and unexported

experimental/CHANGELOG.md Outdated Show resolved Hide resolved
@llc1123
Copy link
Contributor Author

llc1123 commented Jun 29, 2023

cc @pichlermarc

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.

Thanks for taking care of this. 🙂
Just one possible caveat: I'm wondering what happens when we wrap two different versions of @grpc/grpc-js in the same app. 🤔

@llc1123
Copy link
Contributor Author

llc1123 commented Jun 29, 2023

I reverted the import * from "@grpc/grpc-js" part.

But the problem still exists:
In src/grpc-js/index.ts, to pass grpc-js instance to the wrapping methods, you still need to do import * from "@grpc/grpc-js". import type doesn't work.

In the output JS code, there is still something like const grpcJs = require("@grpc/grpc-js");.
Maybe we should avoid using new Metadata() in clientUtils.ts.

@pichlermarc
Copy link
Member

I reverted the import * from "@grpc/grpc-js" part.

But the problem still exists: In src/grpc-js/index.ts, to pass grpc-js instance to the wrapping methods, you still need to do import * from "@grpc/grpc-js". import type doesn't work.

In the output JS code, there is still something like const grpcJs = require("@grpc/grpc-js");. Maybe we should avoid using new Metadata() in clientUtils.ts.

You can pass moduleExports instead of grpcJs as was done in the original code - then you should be able to use type imports only. 🙂

Unfortunately, we need to construct Metadata if it is not provided by the user. Otherwise, we won't be able to inject context into it, which will result in broken traces.

@llc1123
Copy link
Contributor Author

llc1123 commented Jun 29, 2023

You can pass moduleExports instead of grpcJs as was done in the original code.

Nice.

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 addressing the comments 🙂

@llc1123
Copy link
Contributor Author

llc1123 commented Jul 4, 2023

cc @dyladan

@pichlermarc pichlermarc merged commit dccd906 into open-telemetry:main Jul 4, 2023
14 checks passed
@llc1123 llc1123 deleted the chore/grpc-cleanup branch July 4, 2023 15:26
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.

[instrumentation-grpc] refactor/clean-up remnants of grpc-native support
3 participants