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

Stats/Stackdriver: Add user agent as client header #320

Merged
merged 2 commits into from
Jan 31, 2019

Conversation

mayurkale22
Copy link
Member

Fixes #194

@mayurkale22
Copy link
Member Author

I had offline discussion with @JustinBeckwith, decided to add options at create method level, as currently it is not supported (bug) with top level option (https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-exporter-stackdriver/src/stackdriver-monitoring.ts#L23).

(err: Error) => {
this.logger.debug(
'sent time series', request.resource.timeSeries);
err ? reject(err) : resolve();
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional nit: since you are checking for the presence of err, should you have the parameter be err?: Error?

(Although the package doesn't have strict null checks enabled, I think it's still helpful to think in terms of them and then if eventually we want to turn them on they will be easier to enable).

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.

err ? reject(err) : resolve();
});
monitoring.projects.metricDescriptors.create(
request, {headers: OC_HEADER, userAgentDirectives: [OC_USER_AGENT]},
Copy link
Contributor

Choose a reason for hiding this comment

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

Will you need similar logic for other types of Google API calls in the exporter, e.g. writing traces?

If so, what would you think about exporting the larger {headers: OC_HEADER, userAgentDirectives: [OC_USER_AGENT]} constant as something like OC_HEADER_OPTIONS or similar and making it be in a shared utility between trace and metrics?

Copy link
Member Author

Choose a reason for hiding this comment

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

As per my understanding, User Agent requirement is only Stackdriver stats exporter specific. For Stackdriver Trace exporter, we add agent information as a part of the label (example: g.co/agent -> opencensus-node [{version}]). This is implemented in all the libraries except node. Issue #39 -> to address that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, makes sense, then keeping these constants in this file only seems fine.

@codecov-io
Copy link

codecov-io commented Jan 31, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #320      +/-   ##
=========================================
- Coverage   94.93%   94.9%   -0.04%     
=========================================
  Files         118     118              
  Lines        8101    8105       +4     
  Branches      723     723              
=========================================
+ Hits         7691    7692       +1     
- Misses        410     413       +3
Impacted Files Coverage Δ
src/stackdriver-monitoring.ts 80.85% <0%> (-2.49%) ⬇️

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 99c04ee...096641f. Read the comment docs.

@mayurkale22 mayurkale22 merged commit 2a13a77 into census-instrumentation:master Jan 31, 2019
@mayurkale22 mayurkale22 deleted the add_user_agent branch January 31, 2019 18:03
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

5 participants