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

Add support for recording exemplars #405

Merged
merged 2 commits into from
Mar 11, 2019

Conversation

@codecov-io
Copy link

codecov-io commented Mar 8, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #405      +/-   ##
==========================================
+ Coverage   94.82%   94.86%   +0.03%     
==========================================
  Files         136      136              
  Lines        8935     8990      +55     
  Branches      656      657       +1     
==========================================
+ Hits         8473     8528      +55     
  Misses        462      462
Impacted Files Coverage Δ
src/stats/types.ts 100% <0%> (ø) ⬆️
test/test-recorder.ts 100% <0%> (ø) ⬆️
src/stats/stats.ts 98.07% <0%> (ø) ⬆️
src/stats/recorder.ts 97.61% <0%> (+0.05%) ⬆️
test/test-view.ts 98.38% <0%> (+0.2%) ⬆️
src/stats/view.ts 97.67% <0%> (+0.23%) ⬆️

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 89cb441...e018a4c. Read the comment docs.

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.

Very cool! LGTM with some nits. Will there be a follow up to automatically add metric exmplars for things like traced HTTP/gRPC calls in those metrics?

@@ -181,8 +186,13 @@ export interface View {
* Measurements with measurement type INT64 will have its value truncated.
* @param measurement The measurement to record
* @param tags The tags to which the value is applied
* @param attachments optional The contextual information associated with an
* example value. THe contextual information is represented as key - value
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit typo The not THe

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, thanks.

@@ -114,8 +115,13 @@ export class BaseView implements View {
* Measurements with measurement type INT64 will have its value truncated.
* @param measurement The measurement to record
* @param tags The tags to which the value is applied
* @param attachments optional The contextual information associated with an
* example value. THe contextual information is represented as key - value
Copy link
Contributor

Choose a reason for hiding this comment

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

The not THe

timestamp: timestampFromMillis(statsExemplar.timestamp),
attachments: statsExemplar.attachments
}
} as metricBucket;
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: rather than use a type cast here with a let above, could you make a helper function say getMetricBucket that returns a metricBucket type and then you could even just call buckets.push(getMetricBucket(statsExemplar, bucketCount)) with no intermediate variable?

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 suggestion, done.

const buckets = [];
for (let bucket = 0; bucket < data.bucketCounts.length; bucket++) {
const bucketCount = data.bucketCounts[bucket];
let statsExemplar;
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 a let, what would you think about using const and a ternary expression, so:
const statsExemplar = exmplars ? exemplars[bucket] : undefined;?

Copy link
Member Author

Choose a reason for hiding this comment

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

Accepted.

@@ -176,6 +176,41 @@ describe('Recorder', () => {
}
});

describe(`for distribution aggregation data with attachments`, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I tend to only use template backticks when something needs to be interpolated

Copy link
Member Author

Choose a reason for hiding this comment

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

This is due to copy-paste from previous tests, fixed.

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

Will there be a follow up to automatically add metric exmplars for things like traced HTTP/gRPC calls in those metrics?

Yes, the plan is to modify the plug-ins to record Exemplar by default. Currently we only record SpanContext as Exemplars, so whenever there's a sampled trace it will be recorded in the plug-ins.

Fix typos (THe -> The).
Use const and a ternary expression instead of let.
Remove unwanted template backticks.
Add separate function to create/get metric Bucket (getMetricBucket).
@mayurkale22
Copy link
Member Author

Very cool! LGTM with some nits. Will there be a follow up to automatically add metric exmplars for things like traced HTTP/gRPC calls in those metrics?

Yes, will create an issue to track this.

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