Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Use binary format for grpc plugin #354

Conversation

mayurkale22
Copy link
Member

@mayurkale22 mayurkale22 commented Feb 20, 2019

Based on: https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/gRPC.md#propagation

This PR contains below things

  1. Use default binary format instead of B3 format.
  2. Enforce strictNullChecks on grpc repo. (part of feat: enable strictNullChecks on this repo. #348)
  3. Enforce noUnusedLocals on grpc repo.
  4. Update index.ts for [opencensus-propagation-binaryformat] package.

Copy link
Contributor

@draffensperger draffensperger left a comment

Choose a reason for hiding this comment

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

Could you add a test for this new header assignment logic?

@@ -444,7 +428,7 @@ export class GrpcPlugin extends BasePlugin {
* https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/blob/src/plugins/plugin-grpc.ts#L96)
*/
// tslint:disable-next-line:no-any
private getMetadata(original: GrpcClientFunc, args: any[], span: Span):
private getMetadata(original: GrpcClientFunc, args: any[]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than using any here, could this just be an empty object {}?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping on this: @mayurkale22 is it possible to use {} here instead of any and remove the tslint disable above the line? (This was already here so if you don't want to do it now that's OK, but figure it's nice to clean up if we can while we're in here).

* Returns a span context on a Metadata object if it exists and is
* well-formed, or null otherwise.
* @param metadata The Metadata object from which span context should be
* retrieved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could you indent "retrieved" by 4 spaces to show it is a continuation of the @param JSDoc tag?

/**
* Set span context on a Metadata object if it exists.
* @param metadata The Metadata object to which a span context should be
* added.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here on the indent

@@ -7,7 +7,8 @@
"pretty": true,
"module": "commonjs",
"target": "es6",
"strictNullChecks": false
"strictNullChecks": true,
"noUnusedLocals": true
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!! 👍

@codecov-io
Copy link

codecov-io commented Feb 20, 2019

Codecov Report

Merging #354 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #354      +/-   ##
==========================================
+ Coverage   95.28%   95.32%   +0.04%     
==========================================
  Files         124      124              
  Lines        8339     8390      +51     
  Branches      619      624       +5     
==========================================
+ Hits         7946     7998      +52     
+ Misses        393      392       -1
Impacted Files Coverage Δ
test/test-grpc.ts 99.64% <0%> (+0.06%) ⬆️
src/grpc.ts 94.08% <0%> (+0.3%) ⬆️
src/stackdriver-monitoring.ts 84.21% <0%> (+1.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc5f4d1...b2e8835. Read the comment docs.

@mayurkale22
Copy link
Member Author

Could you add a test for this new header assignment logic?

Good call, done b2e8835

Copy link
Contributor

@draffensperger draffensperger left a comment

Choose a reason for hiding this comment

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

LGTM with minor comment about cleaning up a use of any if possible.

@@ -444,7 +428,7 @@ export class GrpcPlugin extends BasePlugin {
* https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/blob/src/plugins/plugin-grpc.ts#L96)
*/
// tslint:disable-next-line:no-any
private getMetadata(original: GrpcClientFunc, args: any[], span: Span):
private getMetadata(original: GrpcClientFunc, args: any[]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Ping on this: @mayurkale22 is it possible to use {} here instead of any and remove the tslint disable above the line? (This was already here so if you don't want to do it now that's OK, but figure it's nice to clean up if we can while we're in here).

@mayurkale22
Copy link
Member Author

is it possible to use {} here instead of any and remove the tslint disable above the line? (This was already here so if you don't want to do it now that's OK, but figure it's nice to clean up if we can while we're in here

This is done in many places in gRPC plugin, I would prefer to address this in separate PR. WDYT?

@draffensperger
Copy link
Contributor

Yes, that's fine to leave the any there for now, makes sense!

@mayurkale22 mayurkale22 merged commit 5b8dced into census-instrumentation:master Feb 21, 2019
@mayurkale22 mayurkale22 deleted the use_binaryformat_for_grpc_plugin branch February 21, 2019 19:08
@mayurkale22 mayurkale22 added this to the Release 0.0.10 milestone Mar 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants