From 3b5a75d1b3e2459d93fe285ce4931fdb83587f8a Mon Sep 17 00:00:00 2001 From: Sam Brenner <106700075+sabrenner@users.noreply.github.com> Date: Fri, 17 Jan 2025 14:54:05 -0500 Subject: [PATCH] use url if provided from DD_TRACE_AGENT_URL (#5128) --- packages/dd-trace/src/llmobs/writers/spans/agentProxy.js | 6 +++--- .../dd-trace/test/llmobs/writers/spans/agentProxy.spec.js | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/dd-trace/src/llmobs/writers/spans/agentProxy.js b/packages/dd-trace/src/llmobs/writers/spans/agentProxy.js index 6274f6117e0..62e497f487c 100644 --- a/packages/dd-trace/src/llmobs/writers/spans/agentProxy.js +++ b/packages/dd-trace/src/llmobs/writers/spans/agentProxy.js @@ -10,10 +10,10 @@ const LLMObsBaseSpanWriter = require('./base') class LLMObsAgentProxySpanWriter extends LLMObsBaseSpanWriter { constructor (config) { super({ - intake: config.hostname || 'localhost', - protocol: 'http:', + intake: config.url?.hostname || config.hostname || 'localhost', + protocol: config.url?.protocol || 'http:', endpoint: EVP_PROXY_AGENT_ENDPOINT, - port: config.port + port: config.url?.port || config.port }) this._headers[EVP_SUBDOMAIN_HEADER_NAME] = EVP_SUBDOMAIN_HEADER_VALUE diff --git a/packages/dd-trace/test/llmobs/writers/spans/agentProxy.spec.js b/packages/dd-trace/test/llmobs/writers/spans/agentProxy.spec.js index 6ed0f150885..412b43133a4 100644 --- a/packages/dd-trace/test/llmobs/writers/spans/agentProxy.spec.js +++ b/packages/dd-trace/test/llmobs/writers/spans/agentProxy.spec.js @@ -25,4 +25,12 @@ describe('LLMObsAgentProxySpanWriter', () => { expect(writer._url.href).to.equal('http://localhost:8126/evp_proxy/v2/api/v2/llmobs') }) + + it('uses the url property if provided on the config', () => { + writer = new LLMObsAgentProxySpanWriter({ + url: new URL('http://test-agent:12345') + }) + + expect(writer._url.href).to.equal('http://test-agent:12345/evp_proxy/v2/api/v2/llmobs') + }) })