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

Add flush interface to span processor #370

Merged

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Dec 4, 2019

Fixes #351

Some cases like AWS lambda can suspend a process before span processors export the completed spans. In these cases, it is desirable to flush the span processor to the exporter before the process suspends so that no spans are lost.

Alternatives considered

call shutdown

  • Shutdown is not required by the specification to flush spans
  • In many FaaS services, the same process will be used for multiple requests. In these cases it is desirable to only initialize span processors and exporters a single time per process, not per request.

use simple span processor

The simple span processor does not batch, so will export spans as soon as they are completed. While this solves the flushing problem, it can be inefficient in many cases. It is a common use case for a lambda function to make many async calls and return as soon as they are all complete. With a simple span processor, the function may call the export function many times just as the function completes. Since it is specified that Export may not be called concurrently, these exports will happen serially. In these cases it is preferable to batch spans and export them in a single call.

tedsuo
tedsuo previously requested changes Dec 4, 2019
Copy link
Contributor

@tedsuo tedsuo left a comment

Choose a reason for hiding this comment

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

Hi @dyladan. This does seem simple on the surface, but please review my requests here: #351 (comment)

specification/sdk-tracing.md Outdated Show resolved Hide resolved
@jmacd
Copy link
Contributor

jmacd commented Dec 4, 2019

@tedsuo This is a SDK-facing API, and I believe the problems you allude to stem from letting this API face the user in OpenTracing APIs.

There is always a question of what-to-do when Flush calls fail. The additional complication here is that it's not a very good idea to use OpenTelemetry APIs to report the failure, but since this is a SDK-facing API the SDK or the main function that installed it should have a good idea of what to do (it is, after all, a special circumstance).

@bogdandrutu
Copy link
Member

This is not a property of the SpanProcessor interface. You probably need this just for the processors that talk to the exporter pipeline.

@dyladan
Copy link
Member Author

dyladan commented Dec 4, 2019

This is not a property of the SpanProcessor interface. You probably need this just for the processors that talk to the exporter pipeline.

@bogdandrutu right now export is the only use-case I can think of, but the specification is specific that batching should be done at the span processor and not at the exporter. For that reason, that's where the flush needs to be. For span processors that don't need to flush, it will be a simple no-op.

@@ -328,7 +336,7 @@ return FailedNotRetryable error.

`Shutdown` should not block indefinitely (e.g. if it attempts to flush the data
Copy link
Member

Choose a reason for hiding this comment

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

maybe make flush a link to the newly added flush method?

@bogdandrutu
Copy link
Member

@dyladan please make sure you address all @tedsuo 's concerns

@jmacd
Copy link
Contributor

jmacd commented Jan 22, 2020

Discussed in triage meeting: Can we close this?

@Oberon00
Copy link
Member

My understanding was that we just need a better "dangerously sounding" name and then we can merge this?

@dyladan
Copy link
Member Author

dyladan commented Jan 22, 2020

My understanding of the most recent conversations was that we decided to call it flush because that is an accurate representation of what is happening.

@jmacd
Copy link
Contributor

jmacd commented Jan 22, 2020

I am OK with calling it flush and don't think it matters that we choose a dangerous-sounding name because this is an SDK-facing API, not a user-facing API.

@carlosalberto
Copy link
Contributor

It sounds like actually "ForceFlush" was the chosen name, no? Other than that, I'm approving.

@carlosalberto
Copy link
Contributor

It looks like we cannot merge this PR as @tedsuo didn't resolve his request. Wondering if there's something we can do to get that out of the way ;)

@jmacd jmacd dismissed tedsuo’s stale review January 23, 2020 00:02

Dismissed. The presenter has given good justification, and this is not a function on the a user-facing API.

@carlosalberto
Copy link
Contributor

Ok, we got @tedsuo changes request dismissed, merging ;)

@carlosalberto carlosalberto merged commit 586b03f into open-telemetry:master Jan 23, 2020
mauriciovasquezbernal added a commit to kinvolk/opentelemetry-python that referenced this pull request Jan 29, 2020
open-telemetry/opentelemetry-specification#370 added
the requirement to have a "force_flush" method in the span processors.

This commit exposes an already existing internal method on the batch span
processor that does exactly the same, it also adds it to the span processor
interface and as a no-op to the simple span processor.
toumorokoshi pushed a commit to open-telemetry/opentelemetry-python that referenced this pull request Feb 4, 2020
open-telemetry/opentelemetry-specification#370 added
the requirement to have a "force_flush" method in the span processors.

This commit exposes an already existing internal method on the batch span
processor that does exactly the same, it also adds it to the span processor
interface and as a no-op to the simple span processor.
toumorokoshi pushed a commit to toumorokoshi/opentelemetry-python that referenced this pull request Feb 17, 2020
open-telemetry/opentelemetry-specification#370 added
the requirement to have a "force_flush" method in the span processors.

This commit exposes an already existing internal method on the batch span
processor that does exactly the same, it also adds it to the span processor
interface and as a no-op to the simple span processor.
SergeyKanzhelev pushed a commit to SergeyKanzhelev/opentelemetry-specification that referenced this pull request Feb 18, 2020
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
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.

Add flush API to processor/exporter
7 participants