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

Stronger tracing tests with inline-snapshot #25

Merged
merged 7 commits into from
Mar 17, 2025

Conversation

alexmojaki
Copy link
Contributor

@alexmojaki alexmojaki commented Mar 11, 2025

assert len(spans) == 12 is a very weak assertion. This PR asserts the exported traces and spans more precisely in a readable tree format. And when the format of an exported trace/span changes (e.g. a new key is added to every span), you can use pytest --inline-snapshot=fix to update all relevant tests automatically. See https://15r10nk.github.io/inline-snapshot/latest/ for more info.

@alexmojaki
Copy link
Contributor Author

There are more places where this can be done (I just did a find and replace on spans = fetch_ordered_spans()), and the simpler testing logic can be cleaned up, but this demonstrates the idea.

@rm-openai
Copy link
Collaborator

This is a great PR, thank you - hadn't seen this library before. Looks like there are some test failures/typecheck failures. I'm happy to take over and send out an updated PR, or let me know if you feel like updating things.

@rm-openai rm-openai merged commit 3a97b15 into openai:main Mar 17, 2025
5 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.

2 participants