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

Having no tracing headers should not be an error. #43

Merged
merged 1 commit into from
Aug 17, 2020

Conversation

lcapaldo
Copy link
Contributor

It is quite typical for services at the edge to receive requests with no
tracing headers. This case shouldn't throw an exception but rather return
None, as we are starting the root span. This is consistent with the
documented behavior of extract on Tracer:
https://github.com/opentracing/opentracing-python/blob/946f763510a8c26a66d5c53a9c4d0c6027cb9129/opentracing/tracer.py#L214

def extract(self, carrier):
return self._extract(carrier)

def _extract(self, carrier, allow_zero_count=False): # noqa
Copy link
Member

Choose a reason for hiding this comment

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

I agree with your PR description - no incoming trace context should result in None. I don't think allow_zero_count customization is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my original thought but there is a test that explicitly checks this case, which is when I went for the HTTP specific approach. I'm happy either way.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, I think it's ok to change that test. I think what it should be checking is if N of fields is 0 < N < 3, then we expect an error because the headers are malformed, but if it's ==0 then it's ok.

Copy link
Member

Choose a reason for hiding this comment

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

btw, please add a test for ==0 case.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Thanks!

@lcapaldo
Copy link
Contributor Author

@yurishkuro Thanks for looking at this. Not sure what is going on with Python 3.5 in the CI, it seems related to setting up the environment and not the change.

@yurishkuro
Copy link
Member

I just removed 3.5, can you rebase?

It is quite typical for services at the edge to receive requests with no
tracing headers. This case shouldn't throw an exception but rather return
None, as we are starting the root span. This is consistent with the
documented behavior of extract on Tracer:
https://github.com/opentracing/opentracing-python/blob/946f763510a8c26a66d5c53a9c4d0c6027cb9129/opentracing/tracer.py#L214
@lcapaldo
Copy link
Contributor Author

I just removed 3.5, can you rebase?

Rebased.

@yurishkuro
Copy link
Member

Thanks!

@yurishkuro yurishkuro merged commit e1a3c83 into opentracing:master Aug 17, 2020
@lcapaldo lcapaldo mentioned this pull request Apr 12, 2021
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.

None yet

2 participants