Skip to content

fix: strips URI scheme prefixes from DD_DOGSTATSD_URL - #556

Merged
hshree-cs merged 4 commits into
mainfrom
GSRE3388/gunicorn
Aug 19, 2026
Merged

fix: strips URI scheme prefixes from DD_DOGSTATSD_URL#556
hshree-cs merged 4 commits into
mainfrom
GSRE3388/gunicorn

Conversation

@hshree-cs

Copy link
Copy Markdown
Contributor

Fixes metrics error by stripping protocol prefixes (unix://) from DD_DOGSTATSD_URL.

Merge checklist:
Check off if complete or not applicable:

  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

Post-merge:

@hshree-cs
hshree-cs requested a review from a team as a code owner August 12, 2026 09:59
Copilot AI lite review requested due to automatic review settings August 12, 2026 09:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Gunicorn configuration used in containerized deployments to normalize DD_DOGSTATSD_URL into a value suitable for Gunicorn’s StatsD/DogStatsD configuration, aiming to prevent metrics initialization errors when the environment variable includes a URI scheme.

Changes:

  • Adds scheme-stripping/normalization logic for DD_DOGSTATSD_URL before assigning statsd_host.
  • Adds startup logging to record the configured statsd_host.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread commerce_coordinator/docker_gunicorn_configuration.py Outdated
Comment thread commerce_coordinator/docker_gunicorn_configuration.py Outdated
Copilot AI review requested due to automatic review settings August 18, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

Copilot AI review requested due to automatic review settings August 19, 2026 04:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

commerce_coordinator/docker_gunicorn_configuration.py:29

  • PR title/description say this change strips the unix:// scheme from DD_DOGSTATSD_URL, but this implementation preserves unix:// (and normalizes unixgram:// -> unix://) when configuring statsd_host. Please update the PR title/description to reflect the actual behavior (normalization + udp:// stripping) so the change is not misrepresented in release notes/backports.
    if _dogstatsd_url.startswith(("unix://", "unixgram://")):
        # Normalize unixgram:// -> unix:// (Gunicorn's validator expects unix://)
        _socket_path = _dogstatsd_url.split("://", 1)[1]
        if _socket_path:
            # Pass as a string; Gunicorn validator detects this and sets address_family = AF_UNIX

Copilot AI review requested due to automatic review settings August 19, 2026 05:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

commerce_coordinator/docker_gunicorn_configuration.py:28

  • PR title/description says it "strips protocol prefixes (unix://) from DD_DOGSTATSD_URL", but this code path keeps/normalizes the unix socket scheme (it rebuilds statsd_host as unix://{path} and only strips udp://). This is a discrepancy that can confuse reviewers/operators trying to reason about the expected env var format.
# Gunicorn's statsd_host validator (validate_statsd_address) accepts a STRING:
#   "HOST:PORT"     -> Gunicorn parses into (host, port) tuple -> AF_INET UDP
#   "unix://PATH"   -> Gunicorn parses into a bare string path -> AF_UNIX SOCK_DGRAM
_dogstatsd_url = os.environ.get("DD_DOGSTATSD_URL", "").strip()

if _dogstatsd_url:
    if _dogstatsd_url.startswith(("unix://", "unixgram://")):
        # Normalize unixgram:// -> unix:// (Gunicorn's validator expects unix://)
        _socket_path = _dogstatsd_url.split("://", 1)[1]
        if _socket_path:  # guard against bare "unix://" with no path
            statsd_host = f"unix://{_socket_path}"
            statsd_prefix = "commerce-coordinator"
    else:
        # Strip udp:// if present; pass plain HOST:PORT string to Gunicorn

@nkhaleelulla-sonata-byte nkhaleelulla-sonata-byte left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@hshree-cs
hshree-cs merged commit 5b50353 into main Aug 19, 2026
9 checks passed
@hshree-cs
hshree-cs deleted the GSRE3388/gunicorn branch August 19, 2026 06:34
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.

4 participants