-
Notifications
You must be signed in to change notification settings - Fork 838
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
feat(tracer): implement span processor #149
Conversation
* 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 { |
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.
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); |
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.
Already done in separate PR #145, please add comments there (if any).
Event, | ||
} from '@opentelemetry/types'; | ||
|
||
export interface ReadableSpan { |
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 added in #150, please comment there.
packages/opentelemetry-basic-tracer/src/export/BatchSampledSpanProcessor.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); |
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 we already have the reference to the tracer
should we do this._tracer.spanProcessor(this)
?
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.
_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) { |
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.
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?
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.
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.
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 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?
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.
Why is the processor even needed? What is the purpose of the processor?
73c394e
to
4c208e3
Compare
packages/opentelemetry-basic-tracer/src/platform/browser/timer-util.ts
Outdated
Show resolved
Hide resolved
49331a9
to
ef28b4e
Compare
Codecov Report
@@ 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
|
ef28b4e
to
c039d0d
Compare
c039d0d
to
4b09b68
Compare
assert.strictEqual(processor['_spansDataList'].length, 0); | ||
}); | ||
|
||
// it('should force flush when timeout exceeded', done => { |
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.
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)
Will revise this PR based on specs decision: open-telemetry/opentelemetry-specification#205. Feel free to add comments there. |
639648b
to
a9035ed
Compare
Per SIG discussion, please add comments on open-telemetry/opentelemetry-specification#205 to shape |
a9035ed
to
ede8972
Compare
Closing this now, handled this in the multiple separate PRs. |
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).