-
Notifications
You must be signed in to change notification settings - Fork 56
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
[#60] Changes the API for the In process context propagation #61
Conversation
…and makes the span not aware of the scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks reasoanable
README.md
Outdated
@@ -112,10 +112,11 @@ $root = $tracer->startActiveSpan('php'); | |||
|
|||
$http = $tracer->startActiveSpan('http'); | |||
file_get_contents('http://php.net'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this example is promoting bad naming practice. root
and http
should really be called scope
, and they should be in different syntax scopes (not sure if php allows that - if not, best to introduce a function in the example)
README.md
Outdated
@@ -246,6 +247,8 @@ SpanOptions wrapper object. The following keys are valid: | |||
- `child_of` is an object of type `OpenTracing\SpanContext` or `OpenTracing\Span`. | |||
- `references` is an array of `OpenTracing\Reference`. | |||
- `tags` is an array with string keys and scalar values that represent OpenTracing tags. | |||
- `finish_span_on_close` is a boolean that determines whether a span should be finished when the | |||
scope is closed or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move "or not" after "finished"
{ | ||
$this->scopes[] = new MockScope($this, $span); | ||
$scope = new MockScope($this, $span, $finishSpanOnClose); | ||
$this->scopes[] = $scope; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not familiar with php syntax - what does this mean? looks like assigning scalar to array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means to append entry to an array
src/OpenTracing/Tracer.php
Outdated
@@ -20,7 +20,7 @@ public function getScopeManager(); | |||
* Tracer::getScopeManager()->getActive()->getSpan(), | |||
* and null will be returned if {@link Scope#active()} is null. | |||
* | |||
* @return Span|null | |||
* @return ScopedSpan|null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScopedSpan class does not exist. It should return a Span.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally. I was playing around with the idea of having such a thing but I decided to not to in the end.
@yurishkuro @ellisv I fixed your comments. |
Sorry for commenting so late. I actually proposed the previous API, because i feel returning the scope makes for a bad API. You always grab the span from it to call additional stuff and its a constant law of demeter violation with complicated code. PHP is single threaded, request based shared nothing. This is different to all other OT languages so far. So i felt it warranted a different API. In addition PHP doesn't have a with keyword like python/java, making the scope so weird, and The default, 90% use case for clients of this library would be the API: $span = $tracer->startActiveSpan(...);
$span->annotate(...);
//..
$span->annotate(...);
$span->finish($closeOnFinish = true); now its going to be: $scope = $tracer->startActiveSpan(...);
$scope->getSpan()->annotate(...);
//..
$scope->getSpan()->annotate(...);
$scope->close($finishOnClose = true); |
In previous case having a scope was unecessary at all in my opinion as it was never exposed to the user and may confuse implementors. That is why I opened #55. Instead we could have removed scope concept at all and left interface SpanManager
{
public function activate(Span $span): void;
public function getActive(): Span;
} Or put So in my opinion we can turn two ways:
|
So I did this implementation three times under three different vendors (mock tracer, datadog and zipkin) I can share my experiences with this:
In the other hand, I agree with most of @beberlei's points as returning a At some point I came up with this approach of having a $scopedSpan = $tracer->getScopeManager()->activate($span);
$scopedSpan->tag(....) So I backed off. To be honest this is not an inconvenience because I would go for the Thoughts @beberlei @yurishkuro @ellisv |
I just opened this issue as it was on my mind recently. If it's decided in favor of |
Read #61 for more context
Short description of what this PR does:
Tracer::startActiveSpan
signature to return a scope.ScopeManager
to not to be aware of spansThis is a breaking change but since we are still in beta, it is OK.
Checklist
Fixes #61
Ping @beberlei @yurishkuro @ellisv @tedsuo