-
Notifications
You must be signed in to change notification settings - Fork 628
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
OpenTelemetry Spans exported during async code execution yield varying number of spans when asserting in pytest #4210
Comments
@mukund-ananthu let me know if this solve your problem Environment Description
Issue OverviewFrom the description provided, the issue you encountered relates to the non-deterministic behavior of spans exported during the execution of the unit tests, particularly in the context of asynchronous function calls. This can lead to inconsistencies between local test runs and CI (Continuous Integration) presubmits on GitHub. What Happened?You are dealing with an asynchronous scenario where:
The expectation is that spans 1 and 2 are finished and appear in the exported spans, while spans 3 and 4 should not. However, in the presubmit runs, you're observing that sometimes spans 3 and 4 appear, and the order of spans might change. Why This Could Be Happening
Recommended Ways to Handle/Test This Scenario
Steps to Reproduce
Expected ResultYou expect the spans exported to be consistent across all runs. Specifically, spans 1 and 2 should always be present and finished, while spans 3 and 4 should not appear in the assertions. Actual ResultThe spans exported show non-deterministic behavior, with spans 3 and 4 occasionally appearing and the order of spans varying between runs. By following these recommendations and adjustments, you should be able to achieve deterministic results in your tests, enhancing the reliability of the span assertions. |
To start off with, your response mentions the following details:
which were never mentioned in my issue description
|
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
* TO mitigate failures occurring due to non-deterministic order and number of OpenTelemetry spans being exported: open-telemetry/opentelemetry-python#4210
Describe your environment
OS: (e.g, Ubuntu)
Python version: (e.g., Python 3.8.10)
SDK version: (e.g., 1.25.0)
API version: (e.g., 1.25.0)
What happened?
https://github.com/googleapis/python-pubsub/pull/1254/files -> This was an interim fix I put in for the time being. But the issue that was observed was that both the number and order of spans exported to the pytests would differ across runs. This was not reproducible locally when run on several hundred runs, but would show up in the presubmits occasionally. The exact code could be looked at in the linked issue above, but at a high level:
What I expected in the pytest unit tests for a() is that spans 1 and 2 show up as finished spans. And spans 3 and 4 don't show up. This was the case in every local execution of the test. But when the presubmits run on Github, I see that some times, the asserted spans also include spans 3 and 4, and the ordering of spans 1,2,3,4 also vary.
Steps to Reproduce
Mentioned above
Expected Result
Spans exported and hence assertable in the pytest should be deterministic
Actual Result
Spans exported are non-deterministic.
Additional context
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: