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

feat: add stackdriver stats exporter #94

Merged
merged 2 commits into from
Aug 22, 2018

Conversation

eduardoemery
Copy link
Contributor

@eduardoemery eduardoemery commented Aug 14, 2018

No description provided.

@eduardoemery eduardoemery force-pushed the stats_stackdriver branch 3 times, most recently from 95a80f8 to 2625906 Compare August 17, 2018 10:16

return new Promise((resolve, reject) => {
monitoring.projects.metricDescriptors.create(request, (err: Error) => {
this.logger.debug(request.resource);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you prefix debug calls with info about the data being printed, or remove them entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, please let me know if the message doesn't make ir clearer.

}

/**
* Formats an OpenCensus' Distribution to Stackdriver's format.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove first '

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

* Gets the bucket boundaries in an monotonicaly increasing order.
* @param buckets The bucket list to get the boundaries from
*/
private getBucketBoundaries(buckets: Bucket[]): number[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for this array not to be in order in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, since buckets is public, anyone can mutate it (like I was doing myself), not guaranteeing that Stackdriver will receive the bucket boundaries in order.


private getBucketCounts(buckets: Bucket[]): number[] {
return buckets
.sort((bucket1, bucket2) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

(1) Same comment as above, wouldn't it be better to make it a pre-condition that buckets is sorted? If this can't be uphold, you should at least clone buckets first since .sort mutates it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure that making buckets sorted as precondition is a great idea. Since buckets is public, anyone (just like I was doing) can mutate it, making it harder to guarantee it will always be sorted. We should trust the user won't change the order.

Thanks for remembering about the cloning!

}
return MetricKind.GAUGE;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@kjin kjin merged commit f7e053f into census-instrumentation:master Aug 22, 2018
kjin pushed a commit to kjin/opencensus-node that referenced this pull request Aug 24, 2018
* feat: add stackdriver stats exporter

* refactor(fix): changes to address review comments
kjin pushed a commit to kjin/opencensus-node that referenced this pull request Aug 24, 2018
* feat: add stackdriver stats exporter

* refactor(fix): changes to address review comments
kjin pushed a commit to kjin/opencensus-node that referenced this pull request Aug 24, 2018
* feat: add stackdriver stats exporter

* refactor(fix): changes to address review comments
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

3 participants