-
Notifications
You must be signed in to change notification settings - Fork 0
Harden QLC CLI and smoke wiring #5
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||
| from __future__ import annotations | ||||||||||
|
|
||||||||||
| import os | ||||||||||
| import re | ||||||||||
| import socket | ||||||||||
| from typing import Any, Mapping | ||||||||||
|
|
||||||||||
|
|
@@ -16,11 +17,19 @@ | |||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def _sanitize(value: str, *, limit: int = 120) -> str: | ||||||||||
| cleaned = re.sub(r"[^A-Za-z0-9_.\-/]", "_", str(value)).strip("_.-/") | ||||||||||
| cleaned = re.sub(r"_+", "_", cleaned) | ||||||||||
| return (cleaned[:limit] or "unknown") | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def emit_dogstatsd_counter(name: str, value: int = 1, tags: tuple[str, ...] = ()) -> None: | ||||||||||
| host = os.environ.get("DD_DOGSTATSD_HOST", "127.0.0.1") | ||||||||||
| port = int(os.environ.get("DD_DOGSTATSD_PORT", "8125")) | ||||||||||
| tag_suffix = f"|#{','.join(tags)}" if tags else "" | ||||||||||
| payload = f"{name}:{value}|c{tag_suffix}".encode("utf-8") | ||||||||||
| safe_name = _sanitize(name, limit=200) | ||||||||||
| safe_tags = [_sanitize(t) for t in tags] | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For callers that use standard DogStatsD tags ( Useful? React with 👍 / 👎.
Comment on lines
+29
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass
Suggested change
|
||||||||||
| tag_suffix = f"|#{','.join(safe_tags)}" if safe_tags else "" | ||||||||||
| payload = f"{safe_name}:{value}|c{tag_suffix}".encode("utf-8") | ||||||||||
|
|
||||||||||
| with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: | ||||||||||
| sock.sendto(payload, (host, port)) | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
_sanitizefunction strips out the colon:character by replacing it with an underscore_. This will break DogStatsD key-value tag formatting (e.g.,qlc_schema:valuebecomesqlc_schema_value). We should allow colons in tags while keeping them sanitized for metric names.