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 forceFlush on TracerSdkProvider. #1068

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ public void shutdown() {
sharedState.stop();
}

/**
* Requests the active span processor to process all span events that have not yet been processed.
*
* @see SpanProcessor#forceFlush()
*/
public void forceFlush() {
sharedState.getActiveSpanProcessor().forceFlush();
}

Comment on lines +127 to +130
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this on the SDK? Probably yes, but would like to understand the motivation you had.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

This is also in the Specification ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, makes sense!

Copy link
Member Author

Choose a reason for hiding this comment

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

@carlosalberto Actually it's not, only shutdown is: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/sdk-tracing.md#shutdown-1. Also forceFlush is not on the exporter. I'll try creating a PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reading more carefully, it seems that the spec does not even specify shutdown on the TracerProvider either, only the getTracer method in the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's only in the spec for a SpanProcessor, not for the SDK Tracer implementation, unless I missed that somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right. I misread that one. In any case, I think it makes sense to have in the Tracer SDK section. I don't imagine keeping the processor object around for this specific task.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bogdandrutu any more clarification needed on this?

/**
* Builder class for the TracerSdkFactory. Has fully functional default implementations of all
* three required interfaces.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ public void shutdown() {
Mockito.verify(spanProcessor, Mockito.times(1)).shutdown();
}

@Test
public void forceFlush() {
tracerFactory.forceFlush();
Mockito.verify(spanProcessor, Mockito.times(1)).forceFlush();
}

@Test
public void shutdownTwice_OnlyFlushSpanProcessorOnce() {
tracerFactory.shutdown();
Expand Down