Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tracer): implement span processor #149

Conversation

mayurkale22
Copy link
Member

@mayurkale22 mayurkale22 commented Jul 31, 2019

This is very big PR (sorry for that), but I felt this was important to connect most of the pieces together like SpanProcessor, BatchSampledSpanProcessor, SimpleSampledSpanProcessor etc.

*Tests are still pending, but I would like to get initial feedback before moving forward (either I will split into smaller PRs or update this PR).

* SpanProcessor is the interface Tracer SDK uses to allow synchronous hooks
* for when a {@link Span} is started or when a {@link Span} is ended.
*/
export interface SpanProcessor {
Copy link
Member Author

Choose a reason for hiding this comment

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

Already done in separate PR #136, please add comments there (if any).

spanId,
});
options.parent = parentSpanContext;
const span = new Span(this, name, options, this._spanProcessor);
Copy link
Member Author

Choose a reason for hiding this comment

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

Already done in separate PR #145, please add comments there (if any).

Event,
} from '@opentelemetry/types';

export interface ReadableSpan {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is added in #150, please comment there.

@mayurkale22 mayurkale22 added the Discussion Issue or PR that needs/is extended discussion. label Jul 31, 2019
@mayurkale22 mayurkale22 added this to the SDK complete milestone Jul 31, 2019
packages/opentelemetry-basic-tracer/src/BasicTracer.ts Outdated Show resolved Hide resolved
@@ -65,6 +68,7 @@ export class Span implements types.Span {
}
this._kind = options.kind || types.SpanKind.INTERNAL;
this._startTime = options.startTime || performance.now();
spanProcessor.onStart(this);
Copy link
Member

Choose a reason for hiding this comment

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

if we already have the reference to the tracer should we do this._tracer.spanProcessor(this)?

Copy link
Member Author

Choose a reason for hiding this comment

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

_spanProcessor is a private member in the tracer class. Need to make it public in order to achieve this.

private _bufferTimeoutInProgress = false;
private _spansDataList: ReadableSpan[] = [];

constructor(private readonly exporter: SpanExporter, config: BufferConfig) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm slightly confused here about the tracer-processor-exporter relationship. If the tracer has one processor and the processor has ONE exporter, how you can have multiple exporters? Shouldn't the processor work with multiple exporters?

Copy link
Member

Choose a reason for hiding this comment

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

I'm also confused about exactly what a processor is supposed to be in this case and the relationship with the exporter. I would think they are unrelated concepts, and vendors should be able to add any number of processors and/or exporters independently.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the tracer has one processor and the processor has ONE exporter, how you can have multiple exporters? Shouldn't the processor work with multiple exporters?

Makes sense to me, I have changed the SpanProcessor to work with multiple exporters.

vendors should be able to add any number of processors and/or exporters independently.

I have exposed registerExporter() method on tracer to add any number of exporters and for now, SpanProcessor is default to BatchSampledSpanProcessor. Maybe later will allow vendors/users to configure SpanProcessor also. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Why is the processor even needed? What is the purpose of the processor?

@mayurkale22 mayurkale22 force-pushed the span_processor_and_exporter branch from 73c394e to 4c208e3 Compare August 2, 2019 19:13
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 2, 2019
@mayurkale22 mayurkale22 force-pushed the span_processor_and_exporter branch from 49331a9 to ef28b4e Compare August 3, 2019 03:13
@codecov-io
Copy link

codecov-io commented Aug 3, 2019

Codecov Report

Merging #149 into master will decrease coverage by 11.72%.
The diff coverage is 72.92%.

@@             Coverage Diff             @@
##           master     #149       +/-   ##
===========================================
- Coverage   91.95%   80.23%   -11.73%     
===========================================
  Files          48       57        +9     
  Lines        1405     1523      +118     
  Branches       96      109       +13     
===========================================
- Hits         1292     1222       -70     
- Misses        113      301      +188
Impacted Files Coverage Δ
...kages/opentelemetry-basic-tracer/test/Span.test.ts 0% <0%> (-100%) ⬇️
...ry-basic-tracer/src/platform/browser/timer-util.ts 0% <0%> (ø)
...ic-tracer/src/export/SimpleSampledSpanProcessor.ts 100% <100%> (ø)
...metry-basic-tracer/src/platform/node/timer-util.ts 100% <100%> (ø)
...acer/test/export/BatchSampledSpanProcessor.test.ts 100% <100%> (ø)
...ntelemetry-basic-tracer/src/platform/node/index.ts 100% <100%> (ø)
...s/opentelemetry-basic-tracer/src/platform/index.ts 100% <100%> (ø)
packages/opentelemetry-basic-tracer/src/Span.ts 50% <100%> (-35.72%) ⬇️
...emetry-basic-tracer/src/export/NoopSpanExporter.ts 100% <100%> (ø)
...ages/opentelemetry-basic-tracer/src/BasicTracer.ts 9.09% <7.69%> (-72.73%) ⬇️
... and 16 more

@mayurkale22 mayurkale22 force-pushed the span_processor_and_exporter branch from ef28b4e to c039d0d Compare August 6, 2019 17:46
@open-telemetry open-telemetry deleted a comment from codecov-io Aug 6, 2019
@mayurkale22 mayurkale22 force-pushed the span_processor_and_exporter branch from c039d0d to 4b09b68 Compare August 6, 2019 17:49
assert.strictEqual(processor['_spansDataList'].length, 0);
});

// it('should force flush when timeout exceeded', done => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out? If it doesn't work yet, would you be open to just having a @todo comment and create an issue for it? (I'm a bit wary of checking in commented out code since it might not be clear to future people why it's there)

@mayurkale22 mayurkale22 removed the request for review from justindsmith August 7, 2019 21:20
@mayurkale22
Copy link
Member Author

Will revise this PR based on specs decision: open-telemetry/opentelemetry-specification#205. Feel free to add comments there.

@mayurkale22 mayurkale22 changed the title feat(tracer): add span processor and exporter feat(tracer): implement span processor Aug 9, 2019
@mayurkale22 mayurkale22 force-pushed the span_processor_and_exporter branch 3 times, most recently from 639648b to a9035ed Compare August 13, 2019 17:58
@mayurkale22
Copy link
Member Author

Per SIG discussion, please add comments on open-telemetry/opentelemetry-specification#205 to shape SpanProcessor in the right direction.

@mayurkale22
Copy link
Member Author

Closing this now, handled this in the multiple separate PRs.

@mayurkale22 mayurkale22 deleted the span_processor_and_exporter branch September 10, 2019 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Issue or PR that needs/is extended discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants