Skip to content

statsd logging does not work in UvicornWorker and does not throw any error #846

@tim-gb

Description

@tim-gb

Describe the bug
In my application, I deploy a FastAPI app to my kubernetes pod, and I have a datadog agent set up in the cluster.
When I exec into my pod and start a REPL, I can do statsd.set no problem, and find my metric on datadog metric explorer.
My app has the following structure:

  • main.py -- the main application code
  • start.py -- pre-setup before launching application, then launching application by running
launch_cmd = f"""gunicornmain:app -k uvicorn.workers.UvicornWorker \
    --bind 0.0.0.0:8006 \
    --workers 4 \
    --access-logfile - --access-logformat '%(t)s %(p)s %(m)s %(U)s' \
    --timeout 600"""
subprocess.call(launch_cmd, shell=True)

When I run statsd.set("example_metric", 1) in start.py, I can see metrics successfully logged.
When I run statsd.set("example_metric", 1) in main.py, I don't see my metric showing up, and there are no errors.

Label the issue properly.

  • Add severity/ label.
  • Add documentation label if this issue is related to documentation changes.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
Metrics should show up on metrics explorer, or stastd should throw error when it fails.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • version for this project in use.
  • services, libraries, languages and tools list and versions.

datadog==0.49.0
fastapi==0.111.1
uvicorn==0.30.3
gunicorn==20.1.0

Additional context
I tried comparing all my environment variables by dumping them in start.py and in main.py, and they are the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugBug related issuestaleStale - Bot reminder

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions