fix(agentex): only bracket IPv6 literals when building the OTLP metrics URL#323
Open
parveshsaini wants to merge 2 commits into
Open
fix(agentex): only bracket IPv6 literals when building the OTLP metrics URL#323parveshsaini wants to merge 2 commits into
parveshsaini wants to merge 2 commits into
Conversation
Author
|
Hey Team! If the proposed changes looks right, can we have a quick review here please? Thanks! @danielmillerp @RoxyFarhad @smoreinis @MichaelSun48 @declan-scale |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
run_workerbuilt the worker's OTLP metrics endpoint by unconditionally wrappingDD_AGENT_HOSTin IPv6 literal brackets:This change extracts a small
build_metrics_urlhelper that brackets the host only when it is an IPv6 literal (i.e. it contains a colon), and uses the host as-is otherwise.Why
Per RFC 3986, brackets are only valid around an IPv6 literal. For the common cases, a hostname (
localhost), a Kubernetes service name (datadog-agent), or an IPv4 literal (10.0.0.5) - the old code produced a malformed URL likehttp://[localhost]:4317.That
metrics_urlflows intoTemporalClientFactory.create_client_from_env(...)→create_client(...)→OpenTelemetryConfig(url=metrics_url). The Temporal SDK validates the URL eagerly when building theRuntime, raisingInvalid OTel URL: invalid IPv6 address. Because that construction is inside thetryblock increate_client, it is re-raised asTemporalConnectionError, so the worker fails to start entirely wheneverDD_AGENT_HOSTis set to anything other than a bare IPv6 literal.This also matches how
DD_AGENT_HOSTis already used elsewhere in the repo without brackets (e.g.app.py'sstatsd_host=os.getenv("DD_AGENT_HOST", "localhost")).How it was verified
Reproduced on Linux (WSL Ubuntu, Python 3.12,
temporalio1.23.0 peruv.lock): feedinghttp://[localhost]:4317/http://[datadog-agent]:4317/http://[10.0.0.5]:4317toOpenTelemetryConfigraisesInvalid OTel URL: invalid IPv6 address; the bracket-less forms are accepted.Added
tests/unit/temporal/test_run_worker_metrics_url.pycovering hostname / IPv4 (not bracketed), IPv6 literal (bracketed), and the unset case (None). The hostname/IPv4 assertions fail against the previous always-bracket behavior and pass with this change.Closes #313
Greptile Summary
build_metrics_urlhelper for constructing the worker OTLP metrics endpoint fromDD_AGENT_HOST.Confidence Score: 5/5
The change is narrowly scoped to OTLP metrics URL construction and is covered by focused unit tests for the relevant host forms.
The helper behavior matches the described URL requirements, and the tests exercise unset, hostname, IPv4, IPv6, explicit port, and already-bracketed IPv6 cases.
What T-Rex did
Reviews (2): Last reviewed commit: "fix(agentex): handle host:port and brack..." | Re-trigger Greptile