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

RFC for Removing and replacing SpanData #8

Merged
merged 18 commits into from
Aug 9, 2019

Conversation

bg451
Copy link
Member

@bg451 bg451 commented Jul 12, 2019

No description provided.

0004-remove-spandata.md Outdated Show resolved Hide resolved

SpanData's primary use case comes from the need to construct and report out of band spans, meaning that you're creating "custom" spans for an operation you don't own. A good example of this is a program that takes in structured logs that contain correlation IDs and a duration (e.g. from splunk) and [converts them](https://github.com/lightstep/splunktospan/blob/master/splunktospan/span.py#L43) to spans for your tracing system. [Another example](https://github.com/lightstep/haproxy_log2span/blob/master/lib/lib.go#L292) is running a sidecar on an HAProxy machine, tailing the request logs, and creating spans. SpanData supports the out of band reporting case, whereas you can’t with the current Span API as you cannot set the start and end timestamp, or add any tags at span creation that the sampler might need.

I'd like to propose getting rid of SpanData and `tracer.recordSpanData()` and replacing it by allowing `tracer.startSpan()` and `span.finish()` to accept start and end timestamp options. This reduces the API surface, consolidating on a single span type. Options would meet the requirements for out of band reporting.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it was my misunderstanding, I thought SpanData was targeting consumers (e.g. exporters) where immutable is desired.
Span was targeting producers, where different components can grab the "current active span" from the context/tracer and append extra information.

Copy link
Member

Choose a reason for hiding this comment

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

SpanData in the API has the motivation explained by the RFC. In the SDK may have a different usage, but if we need something in the SDK then we can define it there.

Copy link
Contributor

Choose a reason for hiding this comment

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

There has been additional confusion because the exporters declare a SpanData type, but it's not the same thing that's been discussed as a way to handle "out of band" spans. This RFC is about removing SpanData from the API, not the observer.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Overall LG with some minor comments. But I am happy to approve this if they are solved.

0004-remove-spandata.md Outdated Show resolved Hide resolved

SpanData's primary use case comes from the need to construct and report out of band spans, meaning that you're creating "custom" spans for an operation you don't own. A good example of this is a program that takes in structured logs that contain correlation IDs and a duration (e.g. from splunk) and [converts them](https://github.com/lightstep/splunktospan/blob/master/splunktospan/span.py#L43) to spans for your tracing system. [Another example](https://github.com/lightstep/haproxy_log2span/blob/master/lib/lib.go#L292) is running a sidecar on an HAProxy machine, tailing the request logs, and creating spans. SpanData supports the out of band reporting case, whereas you can’t with the current Span API as you cannot set the start and end timestamp, or add any tags at span creation that the sampler might need.

I'd like to propose getting rid of SpanData and `tracer.recordSpanData()` and replacing it by allowing `tracer.startSpan()` and `span.finish()` to accept start and end timestamp options. This reduces the API surface, consolidating on a single span type. Options would meet the requirements for out of band reporting.
Copy link
Member

Choose a reason for hiding this comment

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

SpanData in the API has the motivation explained by the RFC. In the SDK may have a different usage, but if we need something in the SDK then we can define it there.

0004-remove-spandata.md Outdated Show resolved Hide resolved
0004-remove-spandata.md Outdated Show resolved Hide resolved
0004-remove-spandata.md Outdated Show resolved Hide resolved
0004-remove-spandata.md Outdated Show resolved Hide resolved
0004-remove-spandata.md Outdated Show resolved Hide resolved
0004-remove-spandata.md Outdated Show resolved Hide resolved
@tsloughter
Copy link
Member

I reread this and now I'm back to reading it as saying there is no way to add to a span during its life and only when it starts or finishes?

If that is the case one worry I have is exception handling. If you can only add events/logs/status when starting or finishing a span it removes the possibility to add those attributes during the life of the span and finishing the span in the handling of a thrown exception.

@bg451
Copy link
Member Author

bg451 commented Jul 17, 2019

as saying there is no way to add to a span during its life and only when it starts or finishes?

@tsloughter This wouldn't be the case, just talking about the concept of bulk logging when a span finishes, which is something opentracing allows.

@tsloughter
Copy link
Member

@bg451 ah, ok. The phrasing, "getting rid of SpanData and tracer.recordSpanData() and replacing it by allowing tracer.startSpan() and span.finish() to accept start and end timestamp options", threw me off.

Is this also around being able to create spans after the fact from log data? This is important to me for support of an Erlang/Elixir library that outputs events like database query times after the db call that we'd like to generate spans from and attach as children to the process that makes the db request.

@bg451
Copy link
Member Author

bg451 commented Jul 17, 2019

Is this also around being able to create spans after the fact from log data?

If I'm understanding the question correctly, yes this is one of the supported use cases. If you can extract a trace context/identifier from your log, you'd be able to make it a child span in that trace. For example (with opentracing start options), this is a sidecar program that would tail HAProxy logs, look for a span context to become a child of, then create/finish the span with the timestamp and tags coming from the parsed log line: https://github.com/lightstep/haproxy_log2span/blob/master/lib/lib.go#L290

@tsloughter
Copy link
Member

@bg451 yup, exactly that, thanks.

@bogdandrutu
Copy link
Member

This is currently blocked on the author side to respond to all the comments. Waiting for that before another review.

0004-remove-spandata.md Outdated Show resolved Hide resolved
0004-remove-spandata.md Outdated Show resolved Hide resolved
0004-remove-spandata.md Outdated Show resolved Hide resolved
@carlosalberto
Copy link
Contributor

Hey hey @bogdandrutu

I will merge this PR later today unless you have something to say ;)

And of course, you can always provide feedback/PRs later on.

@bogdandrutu
Copy link
Member

@carlosalberto one small issue that can be resolved in the specification is time correlation (ensuring monotonic time is used). We do want to ensure inside a span or a sub-trace (spans generated by the same process) that the timestamp is correctly (monotonic) calculated.

I would suggest just a small item in the future work for the moment.

0004-remove-spandata.md Outdated Show resolved Hide resolved
@pavolloffay
Copy link
Member

There are benefits of defining it in the SDK. For instance sdk-processors spec can reference it.

@bogdandrutu
Copy link
Member

@bg451 please fix the last two comments and I will merge this.

@bg451
Copy link
Member Author

bg451 commented Aug 8, 2019

There are benefits of defining it in the SDK.

Just to clarify, it being spandata here right? If so I agree, there still needs to be some sort of concrete type that SDK exporters can read from.

@bogdandrutu
Copy link
Member

@bg451 please also respond to my comments in this post #8 (comment)

@bg451
Copy link
Member Author

bg451 commented Aug 9, 2019

Oh huh I thought I pushed my changes yesterday morn, looks like I didn't.

@bogdandrutu 375c397#diff-f62a07a10e742d00e2ef6471e1d80d13R39 re your comment

@bogdandrutu
Copy link
Member

@tedsuo @carlosalberto @AloisReitbauer @yurishkuro @SergeyKanzhelev @c24t any more comments on this? I would like to merge it but I am looking to have at least one or ideally two more approvers.

Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

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

LGTM

@bogdandrutu bogdandrutu merged commit 8625418 into open-telemetry:master Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet