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

sdk: span parents are now always spancontext #548

Merged

Conversation

toumorokoshi
Copy link
Member

Exporter and span handling complexity was increasing due to the
Span.parent attribute being either a Span or a SpanContext.

As there is no requirement in the specification to have the parent
attribute be a Span, removing this complexity and handling.

Exporter and span handling complexity was increasing due to the
Span.parent attribute being either a Span or a SpanContext.

As there is no requirement in the specification to have the parent
attribute be a Span, removing this complexity and handling.
@toumorokoshi toumorokoshi requested a review from a team April 3, 2020 20:57
Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

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

LGTM. FWIW it looks like we got to the current design because the spec used to require different args for remote (SpanContext) and local (Span) parents: #33 (comment), open-telemetry/opentelemetry-specification#136 (comment).

@toumorokoshi
Copy link
Member Author

toumorokoshi commented Apr 4, 2020

LGTM. FWIW it looks like we got to the current design because the spec used to require different args for remote (SpanContext) and local (Span) parents: #33 (comment), open-telemetry/opentelemetry-specification#136 (comment).

Yeah, that makes sense: there's limited data to construct a full span in the remote scenario.

But just to confirm, there's no rationale for the Span inheriting that complexity, correct? The only caveat I can see here is that exporters will not be able to provide more information around the parent span if it's local, but considering the exporter should have also seen the parent span, I feel like that's not a big issue.

@Oberon00
Copy link
Member

Oberon00 commented Apr 4, 2020

The parent usually ends after the child, so that can be a big issue, if the exporter really relied on that feature.
The complexity can easily be reduced by introducing a getter parent_ctx too.

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

This is a great cleanup! Just added some questions to make sure I understand what this change is doing. There seems to be some parts of the code that still expect either a Span or a SpanContext, but the change name specifically suggests removing that. Is the expectation that in the case of a remote span, the object will still be a Span and not a SpanContext?

opentelemetry-api/src/opentelemetry/trace/__init__.py Outdated Show resolved Hide resolved
opentelemetry-api/src/opentelemetry/trace/__init__.py Outdated Show resolved Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py Outdated Show resolved Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py Outdated Show resolved Hide resolved
@Oberon00
Copy link
Member

Oberon00 commented Apr 9, 2020

I'll ask again: Over a simple (API-implemented) method like:

def get_parent_context(self):
	if isinstance(self.parent, Span): return self.parent.get_context()
    else: return self.parent

does this add any significant improvements to combat

Exporter and span handling complexity was increasing due to the
Span.parent attribute being either a Span or a SpanContext.

? I feel not. There may still be a merit to this PR but IMHO it needs to be justified better.

Exporter and span handling complexity should decrease just the same, but we still give exporters more info about the parent if it is local (I thin we should also recommend passing a local : As said, exporters will often not have the parents available when they process the child. They may be in different batches, or even different export intervals if the child/parent end long before/after one another. There is no guarantee at all here.

This topic is a bit of a pet peeve for me because of open-telemetry/opentelemetry-specification#525 (comment).

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying my questions.

@toumorokoshi
Copy link
Member Author

@Oberon00 regarding your comment about providing a way to extract parent information from the context: I do see the two as providing equal functionality to an exporter. The reason I currently favor this approach is it's still compliant with the current spec as written.

Reading through your links (and thank you for posting them!), I am convinced that your proposal would work fine, and that it would be good to eliminate either Span or SpanContext to do away with this complexity altogether.

Happy to comment and help with moving the spec, but for the time being I feel like this PR is a good way to eliminate some boilerplate complexity that exists now. Thoughts with accepting this as an acceptable current solution?

Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

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

@toumorokoshi I think the approach of this PR is indeed acceptable, and removing the storage of Span as parent does indeed reduce complexity even more than just providing a getter/property while still storing both. I just wanted to be sure that this is well-considered, which I'm now convinced it is. 😃

@c24t
Copy link
Member

c24t commented Apr 24, 2020

It looks like we might have a flaky integration test after #526?

docker-tests run-test-pre: commands[2] | python check_availability.py
2013: Lost connection to MySQL server during query
Traceback (most recent call last):
  File "check_availability.py", line 65, in check_mysql_connection
    connection = mysql.connector.connect(
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/__init__.py", line 219, in connect
    return MySQLConnection(*args, **kwargs)
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/connection.py", line 104, in __init__
    self.connect(**kwargs)
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/abstracts.py", line 960, in connect
    self._open_connection()
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/connection.py", line 289, in _open_connection
    self._do_handshake()
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/connection.py", line 146, in _do_handshake
    packet = self._socket.recv()
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/network.py", line 267, in recv_plain
    raise errors.InterfaceError(errno=2013)
mysql.connector.errors.InterfaceError: 2013: Lost connection to MySQL server during query
2013: Lost connection to MySQL server during query
Traceback (most recent call last):
  File "check_availability.py", line 65, in check_mysql_connection
    connection = mysql.connector.connect(
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/__init__.py", line 219, in connect
    return MySQLConnection(*args, **kwargs)
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/connection.py", line 104, in __init__
    self.connect(**kwargs)
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/abstracts.py", line 960, in connect
    self._open_connection()
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/connection.py", line 289, in _open_connection
    self._do_handshake()
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/connection.py", line 146, in _do_handshake
    packet = self._socket.recv()
  File "/home/travis/build/open-telemetry/opentelemetry-python/.tox/docker-tests/lib/python3.8/site-packages/mysql/connector/network.py", line 267, in recv_plain
    raise errors.InterfaceError(errno=2013)
mysql.connector.errors.InterfaceError: 2013: Lost connection to MySQL server during query

@codeboten
Copy link
Contributor

Those errors are showing up during the startup check of mysql. I made a change to check_availability.py as part of the redis PR to clean up those error messages.

The failing tests should have been fixed in this change: 0740696

@c24t
Copy link
Member

c24t commented Apr 24, 2020

But 0740696 is in this branch already?

@codeboten
Copy link
Contributor

Ah i see, the pymysql tests have the same tests I fixed in the other sql related tests in that change.

@toumorokoshi toumorokoshi merged commit 5f188f7 into open-telemetry:master Apr 25, 2020
@toumorokoshi
Copy link
Member Author

Thanks @codeboten for fixing the branch!

codeboten pushed a commit to codeboten/opentelemetry-python that referenced this pull request Apr 26, 2020
Exporter and span handling complexity was increasing due to the
Span.parent attribute being either a Span or a SpanContext.

As there is no requirement in the specification to have the parent
attribute be a Span, removing this complexity and handling.

Co-authored-by: Chris Kleinknecht <[email protected]>
Co-authored-by: Alex Boten <[email protected]>
@c24t c24t mentioned this pull request May 21, 2020
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
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