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

fix(tracer): report every span to exporters #493

Conversation

hekike
Copy link
Contributor

@hekike hekike commented May 3, 2019

Today Tracer only reports root spans to exporters.
After this change every span will be reported to exporters, letting exporters filter on what they want to handle.
Today some exporters (opencensus-exporter-jaeger) walk through rootSpan.spans, while others (opencensus-exporter-ocagent) use adaptRootSpan() to flatten spans, while other exporters completely skip child spans.

This PR doesn't change Jaeger and ocagent exporters behaviour.

Changes:

  • report all spans to exporters
  • filter to RootSpan only in opencensus-exporter-jaeger to match the previous behaviour
  • filter to RootSpan only in opencensus-exporter-ocagent to match the previous behaviour
  • fix Zipkin reporting shared property for child spans
  • upgrade handlebar to avoid security vulnerability (unrelated change, to pass PR checks)

I learned yesterday from @bogdandrutu that Java reports all the spans to exporters.

@hekike hekike force-pushed the fix/tracer-exporter-span-notifier branch 3 times, most recently from 9884134 to 70dc167 Compare May 3, 2019 15:28
@hekike
Copy link
Contributor Author

hekike commented May 3, 2019

Hmm, both tests and code coverage succeed locally.

@hekike hekike force-pushed the fix/tracer-exporter-span-notifier branch from 70dc167 to 359e3c2 Compare May 3, 2019 15:45
@@ -155,7 +155,7 @@ describe('Zipkin Exporter', function() {
'localEndpoint': {'serviceName': 'opencensus-tests'},
'name': 'spanTest',
'parentId': rootSpan.id,
'shared': true,
'shared': false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test for when shared should be true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, it has one bigger test that contains both root and child span translation and covers both cases of shared. shared is not the only difference, but I guess we could break it down to separate root and child span tests.

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 separated them

root.end();
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 1);
// 5 child spand + root span ended
Copy link
Contributor

Choose a reason for hiding this comment

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

spans

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

added a few comments, otherwise LGTM

@@ -80,7 +80,7 @@ export class ExporterBuffer {
*/
addToBuffer(root: modelTypes.Span) {
Copy link
Member

Choose a reason for hiding this comment

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

s/root/span, also update the param comment?

@@ -41,10 +41,10 @@ describe('Span', () => {
/**
* Should create a span
*/
describe('new Span()', () => {
describe('new Span(tracer, )', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: remove comma or add span param.

@@ -101,6 +101,11 @@ export class JaegerTraceExporter implements Exporter {
* @param root the ended span
*/
onEndSpan(root: Span) {
Copy link
Member

Choose a reason for hiding this comment

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

s/root/span?

@@ -155,7 +155,7 @@ export class ZipkinTraceExporter implements Exporter {
* @param span Span to be translated
*/
translateSpan(span: Span): TranslatedSpan {
const spanTraslated = {
const spanTranslated = {
Copy link
Member

Choose a reason for hiding this comment

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

👍

onEndSpan(root: Span) {
this.endedRootSpans.push(root);
onEndSpan(span: Span) {
// TODO(hekike): Tests depends on the order of recorded spans.
Copy link
Member

Choose a reason for hiding this comment

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

If possible, please create an issue to track this later.

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 idea, added: #501

@mayurkale22
Copy link
Member

Please fix the build

@hekike hekike force-pushed the fix/tracer-exporter-span-notifier branch from fac2ccc to 0d560ab Compare May 6, 2019 17:58
@codecov-io
Copy link

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #493      +/-   ##
==========================================
- Coverage   94.97%   94.65%   -0.32%     
==========================================
  Files         145      145              
  Lines       10208    10237      +29     
  Branches      874      876       +2     
==========================================
- Hits         9695     9690       -5     
- Misses        513      547      +34
Impacted Files Coverage Δ
test/test-http2.ts 77.83% <0%> (-18.99%) ⬇️
src/trace/model/root-span.ts 94.73% <0%> (-1.42%) ⬇️
src/common-utils.ts 95.83% <0%> (-0.84%) ⬇️
src/http-stats.ts 100% <0%> (ø) ⬆️
src/binary-format.ts 100% <0%> (ø) ⬆️
src/grpc-stats/server-stats.ts 100% <0%> (ø) ⬆️
test/test-stackdriver-cloudtrace.ts 100% <0%> (ø) ⬆️
test/test-http.ts 98.46% <0%> (ø) ⬆️
src/grpc-stats/client-stats.ts 100% <0%> (ø) ⬆️
src/grpc-stats/common-distributions.ts 100% <0%> (ø) ⬆️
... and 16 more

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 58dd3ab...824bd9c. Read the comment docs.

@hekike
Copy link
Contributor Author

hekike commented May 6, 2019

Thanks, CI fixed

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR.

@mayurkale22
Copy link
Member

I will merge this PR later today if no other comment(s) from @draffensperger

@mayurkale22 mayurkale22 merged commit d4c3b19 into census-instrumentation:master May 8, 2019
@hekike hekike deleted the fix/tracer-exporter-span-notifier branch May 8, 2019 17:29
@mayurkale22 mayurkale22 added this to the Release 0.0.12 milestone May 9, 2019
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.

6 participants