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

allow for empty X-Parent #820

Merged
merged 3 commits into from
Jan 3, 2024
Merged

Conversation

carldunham
Copy link
Contributor

@carldunham carldunham commented Dec 29, 2023

also tighten up optionality of params

πŸ’Έ TL;DR

The X-Parent header could be empty, and will be for the root span. This PR allows for that.

πŸ“œ Details

πŸ§ͺ Testing Steps / Validation

βœ… Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@carldunham carldunham requested a review from a team as a code owner December 29, 2023 01:04
also tighten up optionality of params
Copy link
Contributor

@KTAtkinson KTAtkinson 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 putting this together! It looks good. Can you describe the impact this issue is having?

Comment on lines 349 to 352

def test_from_upstream_handles_no_parent(self):
span = TraceInfo.from_upstream(1, None, 3, None, None)
self.assertIsNone(span.parent_id)
Copy link
Member

@chriskuehl chriskuehl Jan 2, 2024

Choose a reason for hiding this comment

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

Just a suggestion: it might be nice to include a bit of context here with a brief comment.

In my experience this is the kind of test that people come back to later on and think "why are we testing this? can this even happen in real code? of course there's always a parent span because of [xyz reason that doesn't apply in your case]" and end up breaking things. Since this is testing a non-obvious but important scenario, you could add a line like

def test_from_upstream_handles_no_parent(self):
    # Ensure that TraceInfo can be constructed with no parent span. This can happen when
    # the root span is created by this service.
    ...

(adjust to match the actual reason)

@carldunham
Copy link
Contributor Author

Thanks for putting this together! It looks good. Can you describe the impact this issue is having?

You bet! So this is coming up where we have bp.go services and a bp.py service. We can see the X-Trace header being passed among the Go services, but the Python service seemed to be ignoring it.

In debugging the cause of this, it was noticed that the code would silently fail when no X-Parent header was found, which is a normal operating case. The impact was that none of the tracing headers would be honored.

So this PR aligns what is required and what is optional, so that it will work as expected.

Comment on lines 351 to 353
"""
Verify that `parent_id` can be left out without raising an exception.
"""
Copy link
Member

Choose a reason for hiding this comment

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

nit (no need to fix): I would suggest following PEP257 when possible since it produces better output from pydoc (and other tools that parse docstrings): https://peps.python.org/pep-0257/#one-line-docstrings

@KTAtkinson KTAtkinson merged commit 1d9d09f into develop Jan 3, 2024
3 checks passed
@KTAtkinson KTAtkinson deleted the cd/GQL-3068/accept-passed-trace-ids branch January 3, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants