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

Adds $closeSpanOnFinish as second parameter for activate #60

Closed
jcchavezs opened this issue Apr 9, 2018 · 5 comments
Closed

Adds $closeSpanOnFinish as second parameter for activate #60

jcchavezs opened this issue Apr 9, 2018 · 5 comments

Comments

@jcchavezs
Copy link
Collaborator

Background

Tracer::startActiveSpan starts and span that is captured in a scope and one of the SpanOptions allows you to determine whether the Scope will be closed when finishing the span by passing ['close_span_on_finish' => true].

Problem

For usability matters, $closeSpanOnFinish should allow you to be passed when doing ScopeManager::activate. Those cases occur when starting an Span not as an active one and in such a case it is impossible to pass a value for close_span_on_finish.

Proposal

Changes ScopeManager::activate(OpenTracingSpan $span) into ScopeManager::activate(OpenTracingSpan $span, $closeSpanOnFinish) so you can also decide to pass the $closeSpanOnFinish when activating a span in a Scope.

Java already does this: https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/ScopeManager.java#L36

Ping @yurishkuro @tedsuo @beberlei @ellisv

@jcchavezs
Copy link
Collaborator Author

@ellisv
Copy link
Contributor

ellisv commented Apr 10, 2018

Because of 3010347 commit we have inverted so that Span finish is able to close Scope (thought I am personally not a fan of as we leak Scope concept to Spans). But current option name is misleading. Spans we finish, Scopes we close. So currently an option should be named something like close_scope_on_finish.

Now that a Span has to be aware of a Scope in order to close it this might be problematic as inside of ScopeManager::activate() we accept Span interface which does not have any methods so that we can pass the scope to it.

Ideally for me I would rather go back to concept of startActiveSpan() returning a Scope to not leak Scopes to Spans as it is done in other OT libs.

But in order to keep everything as it is now you would also need to introduce a method in Span interface named something like setScopeToClose()

@yurishkuro
Copy link
Member

If span is aware of the scope, then I think there was a mistake in the design. Java has finishOnClose ie "finish underlying span on scope close". I think this API needs that as well.

jcchavezs added a commit that referenced this issue Apr 12, 2018
@jcchavezs
Copy link
Collaborator Author

@ellisv @yurishkuro I opened a PR to address this issue: https://github.com/opentracing/opentracing-php/pull/61/files

jcchavezs added a commit that referenced this issue Apr 13, 2018
[#60] Changes the API for the In process context propagation
@jcchavezs
Copy link
Collaborator Author

Closed by #61

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

No branches or pull requests

3 participants