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

Exporter/Stackdriver: Use Trace SDKs (v2 API) #338

Merged
merged 2 commits into from
Feb 12, 2019

Conversation

mayurkale22
Copy link
Member

Fixes #322 and #39

droppedMessageEventsCount: number): types.TimeEvents {
const timeEvents: types.TimeEvent[] = [];
if (annotationTimedEvents) {
annotationTimedEvents.forEach(annotation => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be a map rather than forEach + push?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

boolean): types.AttributeValue {
switch (typeof value) {
case 'number':
return {intValue: String(value)};
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make this be doubleValue? The number type in JS is a double so we would be losing accuracy for floating point values.

I would think if something is a BigInt and fits in 64 bits it should be made to be an intValue, which it looks like Node 10 supports

Copy link
Member Author

@mayurkale22 mayurkale22 Feb 11, 2019

Choose a reason for hiding this comment

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

v2 API doesn't support doubleValue type for AttributeValue -> https://github.com/googleapis/google-api-nodejs-client/blob/master/src/apis/cloudtrace/v2.ts#L153-L166. Also intValue is considered as String type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, OK. Then here are a couple options:

  • Just always translate number to its string representation. This is probably my suggestion. Maybe add a TODO to change this once the API supports it. The OpenCensus trace proto has doubleValue.
  • Check whether the number fits in a 64-bit int (less than the max 64-bit int and no fractional part) and only then write it as an intValue and otherwise use String.

I think intValue uses String type because number can't represent full accuracy 64-bit ints.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added TODO here to consider doubleValue type once available with cloudTrace V2 API. As per our offline discussion (+ your suggestion), will always translate number to its string representation for AttributeValue type.

return new Promise((resolve, reject) => {
cloudTrace.projects.patchTraces(traces, (err: Error) => {
cloudTrace.projects.traces.batchWrite(spans, (err: Error) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason we are using HTTP and not gRPC? (If the answer is just "that's what we did before", could you create an issue to track moving to gRPC for this?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, added TODO here.

Copy link
Contributor

@songy23 songy23 left a comment

Choose a reason for hiding this comment

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

LGTM overall

links: createLinks(span.links, span.droppedLinksCount),
status: {code: span.status.code},
sameProcessAsParentSpan: !span.remoteParent,
childSpanCount: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: leave a TODO here?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@codecov-io
Copy link

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #338     +/-   ##
=========================================
+ Coverage   94.98%   95.18%   +0.2%     
=========================================
  Files         120      122      +2     
  Lines        8332     8472    +140     
  Branches      741      750      +9     
=========================================
+ Hits         7914     8064    +150     
+ Misses        418      408     -10
Impacted Files Coverage Δ
src/types.ts 100% <0%> (ø) ⬆️
src/stackdriver-cloudtrace-utils.ts 97.18% <0%> (ø)
test/test-stackdriver-cloudtrace-utils.ts 100% <0%> (ø)
src/stackdriver-cloudtrace.ts 92.53% <0%> (+4.6%) ⬆️
test/test-stackdriver-cloudtrace.ts 100% <0%> (+10.1%) ⬆️

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 95be16e...4881ff7. Read the comment docs.

@mayurkale22 mayurkale22 merged commit 55a5545 into census-instrumentation:master Feb 12, 2019
@mayurkale22 mayurkale22 deleted the stackdriver_v2 branch February 12, 2019 21:37
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.

5 participants