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

Python pytest unit test interaction with ddtrace.tracer.wrap: (port 8126) #11166

Open
jovlinger-numerated opened this issue Oct 24, 2024 · 3 comments

Comments

@jovlinger-numerated
Copy link

jovlinger-numerated commented Oct 24, 2024

(first of all this feels like a faq, but google tells me it isn't. Sorry if indeed it is)

I have happily instrumented some of my code with ddtrace.tracer.wrap.

But when I try to run pytest unit tests against that code, the tests pass, but on tear-down the test-runner complains of not being able to submit traces like below.

How can I inhibit this behavior when running tests?

thanks

-- johan

Traceback (most recent call last):
  File "/Users/johan.ovlinger/.pyenv/versions/3.10.14/lib/python3.10/logging/__init__.py", line 1103, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
  File "/Users/johan.ovlinger/Projects/venvs/opp_python3/lib/python3.10/site-packages/ddtrace/internal/writer/writer.py", line 412, in on_shutdown
    self.periodic()
  File "/Users/johan.ovlinger/Projects/venvs/opp_python3/lib/python3.10/site-packages/ddtrace/internal/writer/writer.py", line 400, in periodic
    self.flush_queue(raise_exc=False)
  File "/Users/johan.ovlinger/Projects/venvs/opp_python3/lib/python3.10/site-packages/ddtrace/internal/writer/writer.py", line 364, in flush_queue
    self._flush_queue_with_client(client, raise_exc=raise_exc)
  File "/Users/johan.ovlinger/Projects/venvs/opp_python3/lib/python3.10/site-packages/ddtrace/internal/writer/writer.py", line 389, in _flush_queue_with_client
    log.error(
  File "/Users/johan.ovlinger/.pyenv/versions/3.10.14/lib/python3.10/logging/__init__.py", line 1506, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/Users/johan.ovlinger/.pyenv/versions/3.10.14/lib/python3.10/logging/__init__.py", line 1624, in _log
    self.handle(record)
  File "/Users/johan.ovlinger/Projects/venvs/opp_python3/lib/python3.10/site-packages/ddtrace/internal/logger.py", line 176, in handle
    super(DDLogger, self).handle(record)
Message: 'failed to send, dropping %d traces to intake at %s after %d retries'
Arguments: (3, 'http://localhost:8126/v0.5/traces', 3)

EDIT python 3.10 as you see and ddtrace 2.14.2

@jovlinger-numerated jovlinger-numerated changed the title Python unit test interaction with pytest: (port 8126) Python pytest unit test interaction with ddtrace.tracer.wrap: (port 8126) Oct 24, 2024
@jovlinger-numerated
Copy link
Author

ping?

@taegyunkim
Copy link
Contributor

Hi Johan,

Looks like your tests are not run with a datadog agent configured.

@jovlinger-numerated
Copy link
Author

jovlinger-numerated commented Nov 5, 2024 via email

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

No branches or pull requests

2 participants