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

Django sync middleware test broken #2336

Closed
xrmx opened this issue Mar 7, 2024 · 1 comment · Fixed by #2338
Closed

Django sync middleware test broken #2336

xrmx opened this issue Mar 7, 2024 · 1 comment · Fixed by #2338
Assignees
Labels
bug Something isn't working

Comments

@xrmx
Copy link
Contributor

xrmx commented Mar 7, 2024

Describe your environment

broken test for Django middleware

Steps to reproduce

first you have to remove a spurious async before the test to have run it :)

diff --git a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py
index d7bb1e54..44273113 100644
--- a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py
+++ b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py
@@ -390,7 +390,7 @@ class TestMiddleware(WsgiTestBase):
         self.assertIsInstance(response_hook_args[2], HttpResponse)
         self.assertEqual(response_hook_args[2], response)
 
-    async def test_trace_parent(self):
+    def test_trace_parent(self):
         id_generator = RandomIdGenerator()
         trace_id = format_trace_id(id_generator.generate_trace_id())
         span_id = format_span_id(id_generator.generate_span_id())

And then:

tox -e py311-test-instrumentation-django-4

What is the expected behavior?

test pass

What is the actual behavior?

test fails

________________________________________ TestMiddleware.test_trace_parent _________________________________________

self = <tests.test_middleware.TestMiddleware testMethod=test_trace_parent>

    def test_trace_parent(self):
        id_generator = RandomIdGenerator()
        trace_id = format_trace_id(id_generator.generate_trace_id())
        span_id = format_span_id(id_generator.generate_span_id())
        traceparent_value = f"00-{trace_id}-{span_id}-01"
    
        Client().get(
            "/span_name/1234/",
            traceparent=traceparent_value,
        )
        span = self.memory_exporter.get_finished_spans()[0]
    
>       self.assertEqual(
            trace_id,
            format_trace_id(span.get_span_context().trace_id),
        )
E       AssertionError: 'f46f1247628f554b587aadce9790c731' != 'ab9bda20154106be406c2314bed448f7'
E       - f46f1247628f554b587aadce9790c731
E       + ab9bda20154106be406c2314bed448f7

instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py:405: AssertionError

Additional context

@xrmx xrmx added the bug Something isn't working label Mar 7, 2024
@xrmx
Copy link
Contributor Author

xrmx commented Mar 7, 2024

I'll try to fix it

xrmx added a commit to xrmx/opentelemetry-python-contrib that referenced this issue Mar 8, 2024
Remove async keyword that did not make the test run and then fix tests
to send the traceparent as header instead of query string.

Fix open-telemetry#2336
xrmx added a commit to xrmx/opentelemetry-python-contrib that referenced this issue Mar 18, 2024
Remove async keyword that did not make the test run and then fix tests
to send the traceparent as header instead of query string.

Fix open-telemetry#2336
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant