-
Notifications
You must be signed in to change notification settings - Fork 97
Stats/Stackdriver: export data using metrics API #275
Stats/Stackdriver: export data using metrics API #275
Conversation
Codecov Report
@@ Coverage Diff @@
## master #275 +/- ##
==========================================
- Coverage 94.81% 94.58% -0.24%
==========================================
Files 110 110
Lines 7771 7421 -350
Branches 713 679 -34
==========================================
- Hits 7368 7019 -349
+ Misses 403 402 -1
Continue to review full report at Codecov.
|
8c51192
to
37c367a
Compare
const resourceLabels = {project_id: this.projectId}; | ||
const monitoredResource = {type: 'global', labels: resourceLabels}; | ||
|
||
metricsList.map(metric => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the value is not being used here, could you do a for (const .. of ..)
loop instead of a .map
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
metricsList.map(metric => { | ||
const timeSeriesList = | ||
createTimeSeriesList(metric, monitoredResource, this.metricPrefix); | ||
timeSeriesList.forEach(ts => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using forEach
and push
, could you use map
here? And would that allow you to make the initial assignment of timeSeries
above be the result of the map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{[key: string]: {view: View; tags: {[key: string]: Tags;}}}; | ||
private displayNamePrefix: string; | ||
// tslint:disable:no-any | ||
private onMetricUploadError: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a possible value of this is a function. Could you make the type something like (err: Error) => void|{}
, which would allow it to either a function that takes an error, or just any arbitrary object? That way there is some amount of documentation about what role it plays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, done.
37c367a
to
459df54
Compare
for (const metricProducer of metricProducerManager.getAllMetricProducer()) { | ||
for (const metric of metricProducer.getMetrics()) { | ||
const isRegistered = | ||
await this.registerMetricDescriptor(metric.descriptor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth running these registerMetricDescriptor
calls in parallel? Not sure how useful it would be but they don't seem dependent on each other in this loop.
It seems like if you ran them all in parallel with something like Promise.all
then you could aggregate their results together into the metricsList
list once they all complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to register each metricDescriptor once (and ignore metricDescriptor that are already registered). If we run registerMetricDescriptor
in parallel, there are chances will make more external calls than usual. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I suppose registering metric descriptors may not happen that often, so it's probably OK to leave as is. Maybe just something we can think of if anybody has a performance issue with it that we could try to compress it to a Set
and run in parallel, but I like leaving it alone for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is certainly a good point, I have added TODO comment for now to track this in future.
I will merge this PR later today, if no other comments. |
This PR is part of #257
The majority of work has been handled/covered in
StackdriverStatsExporterUtils
#266, this PR is based on that work to export data to backend.