Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Set g.co/agent in Stackdriver exported via Node info#604

Merged
pjanotti merged 5 commits intocensus-instrumentation:masterfrom
draffensperger:write-agent-label
Aug 8, 2019
Merged

Set g.co/agent in Stackdriver exported via Node info#604
pjanotti merged 5 commits intocensus-instrumentation:masterfrom
draffensperger:write-agent-label

Conversation

@draffensperger
Copy link
Contributor

This uses the Language, CoreLibraryVersion and ExporterVersion fields of the LibraryInfo message on Node to set the g.co/agent span label in the Stackdriver exporter.

Because this code is running in the OpenCensus service (agent/collector) it's safe to assume that the exporter type in the application library code must have been the ocagent-exporter. Hence, it sets the g.co/agent string as follows: opencensus-[Language] [CoreLibraryVersion]; ocagent-exporter [ExporterVersion], e.g. opencensus-python 0.0.1; ocagent-exporter 0.0.2

Fixes #525.

@codecov
Copy link

codecov bot commented Jul 6, 2019

Codecov Report

Merging #604 into master will increase coverage by 0.52%.
The diff coverage is 86.11%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #604      +/-   ##
=========================================
+ Coverage   68.97%   69.5%   +0.52%     
=========================================
  Files          93      92       -1     
  Lines        6125    6142      +17     
=========================================
+ Hits         4225    4269      +44     
+ Misses       1679    1646      -33     
- Partials      221     227       +6
Impacted Files Coverage Δ
exporter/exporterwrapper/exporterwrapper.go 0% <0%> (ø) ⬆️
exporter/stackdriverexporter/stackdriver.go 57.69% <91.17%> (+57.69%) ⬆️
receiver/prometheusreceiver/internal/ocastore.go 72.41% <0%> (-27.59%) ⬇️
...iver/prometheusreceiver/internal/metricsbuilder.go 100% <0%> (ø) ⬆️
...ceiver/prometheusreceiver/internal/metricfamily.go
...eceiver/prometheusreceiver/internal/transaction.go 89.06% <0%> (+4.21%) ⬆️
receiver/prometheusreceiver/metrics_receiver.go 72.13% <0%> (+4.91%) ⬆️
receiver/prometheusreceiver/internal/metadata.go 75% <0%> (+75%) ⬆️
receiver/prometheusreceiver/internal/logger.go 77.77% <0%> (+77.77%) ⬆️

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 b5a7ae3...3f28c6d. Read the comment docs.

@draffensperger
Copy link
Contributor Author

draffensperger commented Jul 9, 2019

@songy23 and @pjanotti would you be open to merging this PR even though the OpenCensus service is being replaced by the OpenTelemetry service?

I noticed that the OpenTelemetry service doesn't have a Stackdriver exporter yet, so I think merging this PR would make it easier to adopt this feature in OpenTelemetry if we base the Stackdriver exporter on the OpenCensus service one.

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. It makes sense to me to have this fix in OC-Service first. @pjanotti any opinion?

@pjanotti
Copy link

Yes, this should be done first here (OC) then we can pick it up on the contrib side of OpenTelemetry when that gets ready.

Copy link

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

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

Hi @draffensperger, thanks for the PR. A few comments and Qs.

return "opencensus-" + getLanguageName(li.Language) + " " + li.CoreLibraryVersion + "; ocagent-exporter " + li.ExporterVersion
}

func getLanguageName(l commonpb.LibraryInfo_Language) string {

Choose a reason for hiding this comment

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

iirc proto can transform this in a string, any specific reason to have this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I changed to calling .String() on the language enum. Initially I was hoping to make these agent labels match what is set from the libraries by default (e.g. opencensus-node rather than opencensus-node_js), but I think standardizing on the proto enum names is fine. I did lowercase it so that it's a little more similar to the way that agent labels get set on the per-language exporters.

@pjanotti
Copy link

It seems that code coverage numbers are wrong and don't reflect that actual PR numbers...

@draffensperger
Copy link
Contributor Author

Thanks for the reviews! I'll may not get to this for several days but I plan to fix it up per the comments.

@draffensperger
Copy link
Contributor Author

@pjanotti I think I've addressed all the comments (though wasn't sure how to easily remove the OCSpanExporter interface). Could you take another look?

Copy link

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

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

@draffensperger one last thing: could you double check the comment regarding the new interface?

@draffensperger
Copy link
Contributor Author

@pjanotti friendly ping on this - are you comfortable with keeping the new interface instead of adding a dependency on opencensus-go? Would this be ready to merge?

@pjanotti
Copy link

pjanotti commented Aug 8, 2019

hi @draffensperger - sorry, missed your reply earlier. I will merge this and cut a release later this week.

Copy link

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

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

LGTM

@pjanotti pjanotti merged commit 6de0938 into census-instrumentation:master Aug 8, 2019
@draffensperger
Copy link
Contributor Author

@pjanotti awesome, thanks so much for your help with this!

@draffensperger draffensperger deleted the write-agent-label branch August 8, 2019 11:22
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.

Set g.co/agent span attribute for Stackdriver exporter based library/version of node

5 participants