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

Span processor clarifications #1135

Conversation

rachelleahklein
Copy link

@rachelleahklein rachelleahklein commented Oct 23, 2020

Changes

This PR attempts to clarify information about span processors in the Trace SDK spec. It contains:

  • More information about when one might want to use a simple vs. batching span processor
  • More information about scenarios in which span processors may be used without exporters
  • Minor grammatical fixes

Related issues

The need for clarification in the spec came to my attention when it was mentioned in this ticket: open-telemetry/opentelemetry-ruby#397.

@rachelleahklein rachelleahklein requested review from a team October 23, 2020 00:20
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 23, 2020

CLA Check
The committers are authorized under a signed CLA.

and the export-friendly span data representation to the configured
`SpanExporter` as soon as they are finished.

Typically, the simple processor will be most suitable for use in testing and/or
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

In Java this has become the most common span processor as exporters use async functions to send data instead of relying on a background thread. Not how the spec was designed probably, but if it works.
CC @anuraaga

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your valuable feedback on this section as well as the batch processor one, @Oberon00. Do you think more should be added to clarify that while these statements may "typically" be true, it also depends on language implementation? I'm not sure how much detail to get into here.

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

thank you for PR. I added comment on one more scenario for processor. Current edit may mislead

@rachelleahklein
Copy link
Author

Thanks for the quick response! I will add that further clarification.

@@ -287,16 +287,17 @@ invocations. The span processors are invoked only when
[`IsRecording`](api.md#isrecording) is true.

Built-in span processors are responsible for batching and conversion of spans to
exportable representation and passing batches to exporters.
exportable representation and passing batches to exporters or alternatives to
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if a GA spec should point to an experimental spec, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think zPages are implemented as a span processor, not something that receives data through a span processor.

Copy link
Author

Choose a reason for hiding this comment

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

Would it be true then to say "and passing batches to exporters or other span processors," or are there still other alternatives?

Copy link
Author

@rachelleahklein rachelleahklein Oct 23, 2020

Choose a reason for hiding this comment

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

Also, to @reyang's point, I am not even sure referring to zPages specifically makes sense here. My only goal is to have a clear and universal definition of span processors in this sentence. Reading this section, I was confused by the fact that span processors were defined as "responsible for... passing batches to exporters" but then a few lines down, exporters were described as optional.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a problem referring to experimental feature as it makes the point that this is an extensibility point in SDK that can be useful for purposes including experimentation with the new features.

and the export-friendly span data representation to the configured
`SpanExporter` as soon as they are finished.

Typically, the simple processor will be most suitable for use in testing and/or
Copy link
Member

Choose a reason for hiding this comment

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

In Java this has become the most common span processor as exporters use async functions to send data instead of relying on a background thread. Not how the spec was designed probably, but if it works.
CC @anuraaga

@@ -287,16 +287,17 @@ invocations. The span processors are invoked only when
[`IsRecording`](api.md#isrecording) is true.

Built-in span processors are responsible for batching and conversion of spans to
exportable representation and passing batches to exporters.
exportable representation and passing batches to exporters or alternatives to
Copy link
Member

Choose a reason for hiding this comment

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

I think zPages are implemented as a span processor, not something that receives data through a span processor.

specification/trace/sdk.md Outdated Show resolved Hide resolved
Comment on lines +418 to +419
Typically, the batching processor will be more suitable for production environments
than the simple processor.
Copy link
Member

Choose a reason for hiding this comment

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

Depends on the language, e.g. in Java exporters do batching themselves sometimes. But typically, I think that BatchSpanProcessor should be the expected scenario, yes.

Copy link
Member

Choose a reason for hiding this comment

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

I like how it's written. Wdyt @Oberon00?

Copy link
Member

Choose a reason for hiding this comment

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

I think the PR's wording is fine here 👍

specification/trace/sdk.md Outdated Show resolved Hide resolved
Comment on lines +296 to 299
Each processor registered on `TracerProvider` is a start of a pipeline that consists
of one or more span processors and, optionally, one or more exporters. The SDK MUST
allow ending each pipeline with an individual exporter.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove this paragraph. Or do you know what is meant by it? AFAIK the TracerProvider must allow the registration of multiple SpanProcessors, but each built-in span processor only supports a single exporter.

Suggested change
Each processor registered on `TracerProvider` is a start of a pipeline that consists
of one or more span processors and, optionally, one or more exporters. The SDK MUST
allow ending each pipeline with an individual exporter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we definitely need some better description of the possible compositions of SpanProcessors and SpanExporters. E.g. we MUST indicate somewhere that there should be a SpanProcessor before each SpanExporter (purely from methods signatures point of view). We also MUST stress and clearly describe that multiple registered SpanProcessor are "siblings" and do NOT call each other. All this has already created some confusion in the past.

Copy link
Contributor

Choose a reason for hiding this comment

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

I support removing this paragraph. We don't need to specify that pipelines end in exporters, just that the two builtin span processors end in exporters. The metric SDK hasn't thus far mentioned support for multiple processors, and why should we? It's possible to define a multi-processor that calls a series of individual processors. Should the default trace SDK include a builtin multi-processor? I suppose they should if it's common to implement multiple trace exporters with different processor settings, but that does not sound common. Wouldn't you prefer to have a single processor call multiple exporters? Why do we need to specify these things?

multiple registered SpanProcessor are "siblings" and do NOT call each other

If you only specify SDK support for a single processor, this problem vanishes. Potentially you can also specify a multi-processor and/or a multi-exporter, but are you sure these are commonly needed?

Copy link
Author

@rachelleahklein rachelleahklein Oct 28, 2020

Choose a reason for hiding this comment

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

For what it's worth, as someone relatively new to OpenTelemetry concepts, it was helpful to me to have a textual description of the span processor pipeline in addition to the diagram that also exists in this section. There may be some additional nuance that needs to be added, but having some form of this paragraph seems like a good idea to me.

Rachel Klein and others added 2 commits October 23, 2020 10:22
Copy link
Contributor

@iNikem iNikem left a comment

Choose a reason for hiding this comment

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

This PR does not solve existing problems with the current description, but it is a nice cleanup. Thank you! :)

@rachelleahklein
Copy link
Author

I have attempted to address @SergeyKanzhelev's requested change. Please let me know if more clarification is needed there.

Thanks to all who have submitted feedback. I think there are a few things that are potentially outside the scope of this PR, but I have tried to incorporate fixes that are straightforward.

One outstanding question I have: does the overall definition of span processors (see discussion on ln. 290) need to be further fixed?

@SergeyKanzhelev
Copy link
Member

@rachelleahklein thanks again for the PR. The only outstanding feedback from me is to position simple span processor scenarios as dangerous, but valid for production (not as exceptions).

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

This is an improvement to the wording without semantical change. Thank you!

Copy link
Member

@justinfoote justinfoote left a comment

Choose a reason for hiding this comment

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

Thank's for the clarifications @rachelleahklein!

and the export-friendly span data representation to the configured
`SpanExporter` as soon as they are finished.

Typically, the simple processor will be most suitable for use in testing; it should be used with
Copy link
Member

Choose a reason for hiding this comment

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

Not sure this should be mentioned here.
We have production systems running using SimpleProcessors. In those systems, the OpenTelemetry SDK uses SimpleProcessor and exports the span as they arrive, without any batching.
The export may be done to some agent, which in turn may do batching.
Or Export could be done to the actual backend, to enable scenarios like "Live telemetry". Eg in Azure: https://docs.microsoft.com/azure/azure-monitor/app/live-stream

Copy link
Member

Choose a reason for hiding this comment

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

Added couple suggestions. @anuraaga, @cijothomas are these suggestions looks OK for you?

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for adding more suggestions, @SergeyKanzhelev. I have incorporated the first (though happy to revert or refine if there are further comments).

The second is still open and I'm hoping @Oberon00 or others can help clarify a more accurate version.

Thank you all!

@github-actions
Copy link

github-actions bot commented Nov 7, 2020

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 7, 2020
Comment on lines +406 to 407
custom attributes should be added to individual spans based on code scopes.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
custom attributes should be added to individual spans based on code scopes.
custom attributes should be added to individual spans based on code scopes. Simple processors
might also be used for scenarios where the callback needs to be called before sampling. For
example, z-pages can be implemented this way.

Copy link
Member

Choose a reason for hiding this comment

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

This is wrong though. The simple processor is also not invoked for DROPped spans.

Copy link
Member

Choose a reason for hiding this comment

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

hm, I'm referring to the sampled flag as oppose to the recorded flag. Recorded, but sampled out spans should not make it to the batch processor, correct? Recorded will be processed by simple processors. dropped will not reach either

@github-actions
Copy link

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Nov 17, 2020
@rachelleahklein
Copy link
Author

I don't seem to be able to reopen this PR, but I still do hope to work on it and get it approved. It sounds like there are some clarifications that people have found helpful. Please let me know if there is any further feedback I can address. Thank you.

Comment on lines 289 to +290
Built-in span processors are responsible for batching and conversion of spans to
exportable representation and passing batches to exporters.
exportable representation and passing batches to exporters or alternatives to
Copy link
Member

Choose a reason for hiding this comment

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

I think we are mixing 2 different things in this sentence:

  1. What is a SpanProcessor, and how can this be used to interact with the SDK.
  • The SpanProcessor in general does not need to batch or talk to the exporter, it is a simple "hook" that allows custom processors to interact with the Span lifetime events (on start and on end). For example somebody can implement a processor that tracks all the active requests (one of the functionality that we want to offer in the zPages). Others can implement different other functionality.
  1. What are the "built-in" SpanProcessors.
  • We will provide 2 flavors of SpanProcessors (Simple/Batch) that are able to batch (or not in case of simple), transform the Spans in an "exportable" format, and call the "exporter".

@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 25, 2020
@github-actions
Copy link

github-actions bot commented Dec 2, 2020

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants