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

Trace SDK: Provide definitions for readable and read/write span. #669

Conversation

Oberon00
Copy link
Member

@Oberon00 Oberon00 commented Jun 24, 2020

Resolves #663 "Allow for global processing of spans in SpanProcessor".
Required for #158 "Describe proto.Span class".

  • OnStart must be read/write.
  • OnEnd must be readable , may additionally be writable.

Also clean up related wording for span exporters that couldn't decide whether they want to work for different kinds of telemetry data or only spans (they work only for spans).

@Oberon00
Copy link
Member Author

linkcheck repeatedly failed with HTTP 429 for github.com, markdown should be clean though.

@arminru arminru mentioned this pull request Jun 24, 2020
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks! The change looks good and clears up what read, vs read/write span are well for me.

specification/trace/sdk.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
@arminru arminru requested a review from a team June 24, 2020 09:54
Oberon00 and others added 3 commits June 24, 2020 12:07
Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
@arminru arminru requested a review from a team June 24, 2020 10:18
@Oberon00 Oberon00 requested a review from anuraaga June 24, 2020 10:23
@Oberon00 Oberon00 added area:sdk Related to the SDK spec:trace Related to the specification/trace directory labels Jun 24, 2020
@anuraaga
Copy link
Contributor

I went ahead and spiked a PoC for opentelemetry-java, changing both onStart and onEnd to ReadWriteSpan.

https://github.com/open-telemetry/opentelemetry-java/compare/master...anuraaga:span-processors-can-process-more?expand=1#diff-b4c9e6de11a1250eb4d22d36ddd32ec9R171

@arminru arminru requested a review from a team June 30, 2020 12:27
@Oberon00
Copy link
Member Author

Oberon00 commented Jul 1, 2020

Sounds great to me, but I'd like also to ask @bogdandrutu for his opinion on this ;)

-- #669 (comment)

@carlosalberto @bogdandrutu Anything I should do here?

@Oberon00
Copy link
Member Author

Oberon00 commented Jul 7, 2020

Note that this PR is now linked to #158 which is required-for-ga.

@Oberon00 Oberon00 requested a review from bogdandrutu July 16, 2020 10:22
@Oberon00
Copy link
Member Author

@open-telemetry/specs-approvers @open-telemetry/specs-trace-approvers This PR is waiting for reviews.

specification/trace/sdk.md Show resolved Hide resolved

A readable span interface MUST provide a method called `getInstrumentationLibrary` (or similar),
that returns the `InstrumentationLibrary` information held by the `Tracer` that created the span.
* **Read/write span**: A span interface satisfies this requirement of being a
Copy link
Member

Choose a reason for hiding this comment

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

Is this really needed? This may make user to do hacks. Imagine we have this interface in the OnStart, they know that the object we return implements both, OnEnd we return only read, then they will guess is the same interface and may do a cast to the ReadWrite interface.

My suggestion is that Span is the write interface and ReadableSpan is the read interface, if access required to both we should pass both interfaces. Maybe I am to "evil" and think of possible hacks and abuses, but I've seen all of these happening in my previous life :)

Copy link
Member Author

Choose a reason for hiding this comment

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

You could pass a wrapper object that only implements the readable interface to protect against that.

I think we can mention passing the read-only and write-only interface separately as an allowed implementation option for read/write span though.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Oberon00 suggested I do that hack when I need to mutate the span in OnEnd :) I think there is a need to be able to mutate spans globally before export (usually to use other tags as signals to user-defined domain-specific tags) so hope we can find a way. The issue we were worried about is the ordering between OnEnd and export

Copy link
Member Author

Choose a reason for hiding this comment

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

More importantly, spans are already ended at that point and can't be modified anyway. #669 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

@bogdandrutu I incorporated the "read/write implemented as two separate objects" option in 0b9709d.

specification/trace/sdk.md Show resolved Hide resolved

A readable span interface MUST provide a method called `getInstrumentationLibrary` (or similar),
that returns the `InstrumentationLibrary` information held by the `Tracer` that created the span.
* **Read/write span**: A span interface satisfies this requirement of being a
Copy link
Contributor

Choose a reason for hiding this comment

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

@Oberon00 suggested I do that hack when I need to mutate the span in OnEnd :) I think there is a need to be able to mutate spans globally before export (usually to use other tags as signals to user-defined domain-specific tags) so hope we can find a way. The issue we were worried about is the ordering between OnEnd and export

@iNikem
Copy link
Contributor

iNikem commented Jul 29, 2020

Pinging @open-telemetry/specs-approvers @open-telemetry/specs-trace-approvers as I am also interested in this PR getting merged.

@Oberon00
Copy link
Member Author

@iNikem It would be cool if you had time to submit a review yourself. Grey checkmarks also mean something 😃

specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Show resolved Hide resolved
Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
@iNikem
Copy link
Contributor

iNikem commented Jul 29, 2020

Thinking some more about the original intention of @anuraaga in #663 , @bogdandrutu comment about ReadableSpan vs SpanData about this use-case and how SpanProcessor is currently described here , I think the actual problem is different.

What Anuraag and I want is a composable, external function Read/Write SpanData-> Read/Write SpanData. Which can read all the existing info and add some new info. SpanProcessor is on the critical path of the application. One would argue that doing arbitrary data enrichment on critical path is not a good idea.

Exporters, on the other hand, are off the critical path. If we update spec to make it explicit that there can be a chain/pipeline of exporters, and that they can be a place for data enrichment, that would solve the underlying issue in #663

@Oberon00
Copy link
Member Author

Oberon00 commented Jul 29, 2020

Yeah, the SpanProcessor is not well-suited for computing additional attributes. @anuraaga said he'd create a new issue/PR for this (#669 (comment)). What is more, OnEnd can only get a read-only span (a ended + writeable span is not a thing #669 (comment)).

I think OnStart should be able to write to the Span, so that the SpanProcessor can capture some things from the current context. E.g. a thread name, a current request ID (many web frameworks offer a way to access the current web request via a global function), etc.

@anuraaga
Copy link
Contributor

Yeah I've been waiting to confirm the direction of this one before filing another issue about enriching spans, whether using processor or exporter to avoid confusion as they are related topics. So hoping for a merge :-)

@Oberon00
Copy link
Member Author

Oberon00 commented Jul 31, 2020

I also agree that it is better to get this basic readable vs read+write definitions sorted out before making follow-up changes. I'm also hoping for a merge. 😃

@carlosalberto if you approve of this PR, I think it is ready to be merged. I don't think we need to wait for @bogdandrutu anymore as I think I resolved all his comments and he hasn't responded for 10 days.

I will also post a request for reviews on gitter.

@carlosalberto
Copy link
Contributor

@Oberon00 I think the section describing the option to have a Read/Write Span as (two) separate objects might not be clear enough for newcomers ;) But we can work on it if/as/when needed, so I'm ok with the current PR.

Lets wait till EOD to give a last opportunity for @bogdandrutu to comment.

@Oberon00
Copy link
Member Author

I agree that this section has become rather convoluted. I have an idea in mind where we would not list parameters for callbacks one by one but rather just say which operations they must be able to do. But I'd prefer to do that in a follow up if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:sdk Related to the SDK release:required-for-ga Must be resolved before GA release, or nice to have before GA spec:trace Related to the specification/trace directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for global processing of spans in SpanProcessor
6 participants