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

Message events: use counters instead of hexdecimal value #446

Merged
merged 2 commits into from
Apr 3, 2019

Conversation

mayurkale22
Copy link
Member

@mayurkale22 mayurkale22 commented Mar 26, 2019

Fixes #442

As per the Specs, The MessageId must be calculated as two different counters starting from 1 one for sent messages and one for received message. This way we guarantee that the values will be consistent between different implementations.

To avoid breaking changes, I preferred to keep string type for id field. I am happy to change that or add support for both string|number.

@mayurkale22
Copy link
Member Author

/cc @HollandBen

@@ -84,6 +84,8 @@ export class GrpcPlugin extends BasePlugin {
static readonly ATTRIBUTE_GRPC_STATUS_CODE = 'grpc.status_code';
static readonly ATTRIBUTE_GRPC_ERROR_NAME = 'grpc.error_name';
static readonly ATTRIBUTE_GRPC_ERROR_MESSAGE = 'grpc.error_message';
private sentSeqId = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

My reading of the specs is that these counters are supposed to be per-request so that the messages for a given request can be correlated between services. Would it be possible to handle these on a per request basis?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! You're right! I checked in other libraries. In Go, id is 0 for all requests. In Python, wraps a request or response iterator to add message events to the span. Looks like Java has most accurate implementation, But I am not sure how it translate previous hop count (seq) on wire. I will talk to @songy23 and @rghetia to understand it better.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a word with @rghetia, so the seq number counter is for single request and not across multiple services. In case of unary calls only one sent and one received message will be recorded for both client and server spans. I will add support for streaming calls in another PR. I have updated the PR with this change and also changed id type from string to number. I know this is a breaking change, but this API - addMessageEvent() is mostly used internally.

@mayurkale22 mayurkale22 force-pushed the message_id branch 2 times, most recently from ec69787 to 9ac6c11 Compare April 1, 2019 17:54
@codecov-io
Copy link

codecov-io commented Apr 1, 2019

Codecov Report

Merging #446 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #446      +/-   ##
==========================================
- Coverage   94.71%   94.68%   -0.03%     
==========================================
  Files         150      150              
  Lines        9743     9765      +22     
  Branches      734      735       +1     
==========================================
+ Hits         9228     9246      +18     
- Misses        515      519       +4
Impacted Files Coverage Δ
test/test-instana.ts 53.84% <0%> (-34.62%) ⬇️
src/stackdriver-monitoring.ts 80.2% <0%> (-3.13%) ⬇️
test/test-tracecontext-format.ts 98.96% <0%> (-0.1%) ⬇️
src/http2.ts 90.32% <0%> (-0.08%) ⬇️
src/http.ts 91.63% <0%> (-0.04%) ⬇️
test/test-root-span.ts 100% <0%> (ø) ⬆️
src/grpc-stats/server-stats.ts 100% <0%> (ø) ⬆️
test/test-ocagent.ts 83.23% <0%> (ø) ⬆️
test/test-stackdriver-cloudtrace-utils.ts 100% <0%> (ø) ⬆️
test/test-no-record-root-span.ts 100% <0%> (ø) ⬆️
... and 12 more

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 0c733be...8ec4769. Read the comment docs.

@mayurkale22 mayurkale22 merged commit bd4f1b6 into census-instrumentation:master Apr 3, 2019
@mayurkale22 mayurkale22 deleted the message_id branch April 3, 2019 05:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants