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

In process propagation #20

Closed
wants to merge 1 commit into from
Closed

In process propagation #20

wants to merge 1 commit into from

Conversation

jcchavezs
Copy link
Collaborator

This is related to the in_process_propagation.

Ping @beberlei @felixfbecker @yurishkuro @tPl0ch

@tedsuo
Copy link
Member

tedsuo commented Sep 22, 2017

Any reason startActiveSpan can't be called startSpan, rather than deprecate the method?

@jcchavezs
Copy link
Collaborator Author

@tedsuo we are following other implementations like python

@tedsuo
Copy link
Member

tedsuo commented Oct 30, 2017

Fair enough. I'd prefer we hadn't called it StartActiveSpan there either, but perhaps that ship has sailed...

@jcchavezs
Copy link
Collaborator Author

Ping @jonahgeorge

@jcchavezs
Copy link
Collaborator Author

We have two options here:

  • We remove the startSpan method and notify all the implementors about this or
  • We keep the startSpan as deprecated.

Whatever we choose I believe we will be ready to release 1.0.0. Please react with 1️⃣ or 2️⃣ wether you prefer the first one or the second one. Otherwise drop a comment expressing your concerns.

Ping @tPl0ch @tedsuo @felixfbecker @beberlei @yurishkuro @lvht @jonahgeorge @reimertz

@jcchavezs jcchavezs added this to the 1.0.0 milestone Nov 5, 2017
@jcchavezs
Copy link
Collaborator Author

1️⃣

@opentracing opentracing deleted a comment from taoso Nov 5, 2017
@opentracing opentracing deleted a comment from taoso Nov 5, 2017
@opentracing opentracing deleted a comment from taoso Nov 5, 2017
@taoso
Copy link

taoso commented Nov 5, 2017

@jcchavezs In my opinion, only startSpan is really needed.

@taoso
Copy link

taoso commented Nov 5, 2017

I think we should only offer the most essential API. Less is more, and less is better.

The opentracing specific even does not define a trace-id!!! It only defined span, tag, context, and reference. It's enough. How to trace all spans with different references is all about implementation. So should our php interface.

@taoso
Copy link

taoso commented Nov 7, 2017

@jcchavezs Any thing not specified in the OT spec should never be part of our opentracing-php API.

Thank you.

@jonahgeorge
Copy link

jonahgeorge commented Nov 7, 2017

I would also prefer renaming startActiveSpan to startSpan rather than deprecating startSpan or removing it.

@felixfbecker
Copy link
Contributor

I would like to keep a method for manual span creation around as a fallback to use in an environment that needs to rely on manual span propagation. For example, I currently use https://github.com/sabre-io/event as an event loop, which doesn't have hooks to make sure the active span is correctly set for each event loop tick / context. So I have to resort back to passing around the Span objects as parameters, which I have no problem with, so I don't see any harm in keeping this functionality.

Copy link
Contributor

@beberlei beberlei left a comment

Choose a reason for hiding this comment

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

I like the changes so far, really looking forward for this pull request as it will make OT-PHP usable for many more automatically instrumented scenarios.

@@ -14,6 +14,39 @@
interface Tracer
{
/**
* @deprecated use either startActiveSpan or startManualSpan instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not yet 1.0, so I would just go and remove this instead of deprecating.

Copy link
Collaborator Author

@jcchavezs jcchavezs Nov 8, 2017

Choose a reason for hiding this comment

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

So you think we should use startActiveSpan or startSpan making the active condition by default @beberlei?

In my opinion it makes it consistent with other language APIs.

cc @felixfbecker

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice. I just changed it.

* must not be changed (idempotency).
*
* Do not confuse it with the finish concept:
* - $span->deactivate() the span is not active but still "running"
Copy link
Contributor

Choose a reason for hiding this comment

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

You mention Span#deactivate here but this method does not exist. Should it? I don't think so, the comment must probably be adjusted to:

- $tracer->getActiveSpanSource()->deactivate($span); the span is not active anymore but still "running"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice one. I just fixed it.

@@ -25,7 +58,26 @@
* @throws InvalidSpanOption for invalid option
* @throws InvalidReferencesSet for invalid references set
*/
public function startSpan($operationName, $options = []);
public function startActiveSpan($operationName, $options = []);
Copy link

Choose a reason for hiding this comment

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

What's the reference type between the new created active span and the current active span?

Copy link

Choose a reason for hiding this comment

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

Ping @jcchavezs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When creating a new activeSpan it becomes automatically the child of the existing one: https://github.com/opentracing/opentracing-php/pull/45/files#diff-bd85a3792bd64b152939e0b1b78086e2R19

Copy link
Contributor

Choose a reason for hiding this comment

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

What about other span relations than child_of?

Copy link
Contributor

Choose a reason for hiding this comment

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

@felixfbecker that is what startManualSpan is for.

/**
* @return ActiveSpanSource
*/
public function getActiveSpanSource();
Copy link

Choose a reason for hiding this comment

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

The introduction of ActiveSpanSource is not bad. Because, I implemented the same function in my company's php framework yesterday.

However, the opentracing specification only defines the references. And how to trace the reference is all business of user.

/**
* Keeps track of the current active `Span`.
*/
interface ActiveSpanSource
Copy link

Choose a reason for hiding this comment

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

If we shift the ActiveSpanSource interface, why not shift a ActiveSpanSource implementation?

In my opinion, the ActiveSpanSource is only like a container. And only one implementation is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand it this interface would be important to implement for event loops

Copy link
Contributor

Choose a reason for hiding this comment

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

@jcchavezs is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I simplified this piece in #45

@taoso
Copy link

taoso commented Nov 16, 2017

I need to make a summary of my consideration. @beberlei @felixfbecker @yurishkuro @tPl0ch @jcchavezs @tedsuo @jonahgeorge

My Opinion

I think we should only offer the most essential API. Less is more, and less is better.
Any thing not specified in the OT spec should never be part of our opentracing-php API.

I have said these words again and again.

In my opinion, the job to maintain the reference between span should leave to the user, even not the OT vendor.

However, if we really like to shift this feature, there still some issue in this PR.

The current issues

startSpan API name

The current startSpan is the very startManualSpan. Why introduce another startManualSpan and rename the current startSpan to startActiveSpan?

I propose to introduce the startActiveSpan API only.

The finish behavior of the finish API of the active span

With the startActiveSpan API, we get a span that has a parent of the current span and then become the new current span. It sounds great. However, what will happen if we call the new generated span's finish method?

In my opinion, the tracer should finish the span normally, and restore the current span with the stoped span's parent span. But I can not see any requirements in the API's doc.

The getActiveSpanSource API

Why people use the startManualSpan API? I think they use the API because they have their own infrastructure to maintain the reference of there span. It seems no need to use the getActiveSpanSource API to get the shifted ActiveSpanSouce for them. If they can use our ActiveSpanSource, why not use the getActiveSpanSource directly?

So I propose leave the ActiveSpanSource for internal use only, and drop the getActiveSpanSource API. As a result, the ActiveSpanSource interface can be dropped as well.

The getActiveSpan API

Please offer more detail about the getActiveSpan API.

If user use the startActiveSpan API, the Tracer will trace span automatically. If they trace span themselves, the will use the startSpan(or your startManualSpan), and the getActiveSpan will return nothing.

I can not see any need to use this API.

@taoso
Copy link

taoso commented Nov 16, 2017

@tedsuo we are following other implementations like python

@jcchavezs Please following the OT spec.

@jcchavezs
Copy link
Collaborator Author

Unfortunately the implementation details changed and the Python PR (which is the one I based this PR on) has been closed in favour of opentracing/opentracing-python#63.

I am closing this PR for now. I created an issue for this matter and I will open a new PR by this week.

@jcchavezs jcchavezs closed this Nov 16, 2017
@beberlei
Copy link
Contributor

@jcchavezs the only thing that changed in the new python implementation is this weird with something as scope change, which PHP doesn't have in the language (blocks), so we should keep this PR.

@jcchavezs
Copy link
Collaborator Author

jcchavezs commented Jan 9, 2018

@lvht, thanks for the feedback. Please let's follow up further questions in #45

startSpan API name
The current startSpan is the very startManualSpan. Why introduce another startManualSpan and rename the current startSpan to startActiveSpan?
I propose to introduce the startActiveSpan API only.

In some cases you don't want to create a scope for in-process context propagation. For example in concurrency situations, after pcntl_fork you don't want to open a scope for internal spans created in both parent and child process.

The finish behavior of the finish API of the active span
With the startActiveSpan API, we get a span that has a parent of the current span and then become the new current span. It sounds great. However, what will happen if we call the new generated span's finish method?
In my opinion, the tracer should finish the span normally, and restore the current span with the stoped span's parent span. But I can not see any requirements in the API's doc.

This is a valid concern an a good question. We discussed this a long time ago and we decided to decouple the behaviour, that is why we added this note: https://github.com/opentracing/opentracing-php/pull/45/files#diff-e01221a8e1fafbccea47b6bc2f5f9f28R33

The getActiveSpanSource API
Why people use the startManualSpan API? I think they use the API because they have their own infrastructure to maintain the reference of there span. It seems no need to use the getActiveSpanSource API to get the shifted ActiveSpanSouce for them. If they can use our ActiveSpanSource, why not use the getActiveSpanSource directly?
So I propose leave the ActiveSpanSource for internal use only, and drop the getActiveSpanSource API. As a result, the ActiveSpanSource interface can be dropped as well.

I did a change in this direction. To be honest having the scope control inside the tracer make things more understandable. I had the opportunity to try the separated objects approach and it was quite inconvinient.

The getActiveSpan API
Please offer more detail about the getActiveSpan API.
If user use the startActiveSpan API, the Tracer will trace span automatically. If they trace span themselves, the will use the startSpan(or your startManualSpan), and the getActiveSpan will return nothing.
I can not see any need to use this API.

You might want to add specific tags or logs to the current span and that is not possible without accessing the currentSpan.

@@ -42,7 +42,7 @@ The simplest starting point is to set the global tracer. As early as possible, d

### Creating a Span given an existing Request

To start a new `Span`, you can use the `StartSpanFromContext` method.
To start a new `Span`, you can use the `startActiveSpan` method.
Copy link
Contributor

Choose a reason for hiding this comment

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

You name it startActiveSpan here and then the example uses startManualSpan though. Is this right?

@@ -25,7 +58,26 @@
* @throws InvalidSpanOption for invalid option
* @throws InvalidReferencesSet for invalid references set
*/
public function startSpan($operationName, $options = []);
public function startActiveSpan($operationName, $options = []);
Copy link
Contributor

Choose a reason for hiding this comment

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

@felixfbecker that is what startManualSpan is for.

* or use the call to fastcgi_finish_request in order to not to delay the end
* of the request to the client.
* As an implementor, a good idea would be to use register_shutdown_function
* or fastcgi_finish_request in order to not to delay the end of the request to the client.
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 not an "or" imho, since you can use both. register_shutdown_function is still waiting to finish the communication with the Webserver if you don't use fastcgi_finish_request.

@jcchavezs
Copy link
Collaborator Author

Closing in favor of #47

@jcchavezs jcchavezs closed this Feb 6, 2018
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.

6 participants