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

set response status code in zipkin spans during exceptions #128

Merged
merged 4 commits into from
Oct 9, 2023

Conversation

acer618
Copy link
Contributor

@acer618 acer618 commented Oct 6, 2023

When request processing has exceptions, the zipkin tween will now catch this exception (and re-raise it). Handling this exception in the zipkin tween lets us set the response_status_code (and error_type). This will be useful as SERVER side spans are using for analysis

Tested:
Code change to simulate the error: https://fluffy.yelpcorp.com/i/BrBMl9576HPCwvJBwPHsD4N6Gw5g8RSw.html
Test endpoint: https://www.amokal-example-happyhour-uwsgi.dev.yelp.com/hours/1234567890/v1?zipkin_email=amokal@yelp.com
Trace: https://fluffy.yelpcorp.com/i/1mFnjTRXmFhMWPz3sSWfnmTVD8Dq6lXx.html
after

@acer618 acer618 changed the title set response status code for unhandled exceptions set response status code in zipkin spans during exceptions Oct 6, 2023
pyramid_zipkin/tween.py Outdated Show resolved Hide resolved
response = handler(request)
except Exception as e:
zipkin_context.update_binary_annotations({
'error_type': type(e).__name__,
Copy link
Member

Choose a reason for hiding this comment

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

to ease any future efforts on adapting to opentelemetry's semantic conventions can we use error.type as the annotation instead?
Source -> http-spans

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call out! made the change

@acer618 acer618 merged commit da35fd6 into master Oct 9, 2023
2 checks passed
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

6 participants