Skip to content

Commit f214673

Browse files
authored
use url if provided from DD_TRACE_AGENT_URL (#5128)
1 parent 015a722 commit f214673

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/dd-trace/src/llmobs/writers/spans/agentProxy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const LLMObsBaseSpanWriter = require('./base')
1010
class LLMObsAgentProxySpanWriter extends LLMObsBaseSpanWriter {
1111
constructor (config) {
1212
super({
13-
intake: config.hostname || 'localhost',
14-
protocol: 'http:',
13+
intake: config.url?.hostname || config.hostname || 'localhost',
14+
protocol: config.url?.protocol || 'http:',
1515
endpoint: EVP_PROXY_AGENT_ENDPOINT,
16-
port: config.port
16+
port: config.url?.port || config.port
1717
})
1818

1919
this._headers[EVP_SUBDOMAIN_HEADER_NAME] = EVP_SUBDOMAIN_HEADER_VALUE

packages/dd-trace/test/llmobs/writers/spans/agentProxy.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ describe('LLMObsAgentProxySpanWriter', () => {
2525

2626
expect(writer._url.href).to.equal('http://localhost:8126/evp_proxy/v2/api/v2/llmobs')
2727
})
28+
29+
it('uses the url property if provided on the config', () => {
30+
writer = new LLMObsAgentProxySpanWriter({
31+
url: new URL('http://test-agent:12345')
32+
})
33+
34+
expect(writer._url.href).to.equal('http://test-agent:12345/evp_proxy/v2/api/v2/llmobs')
35+
})
2836
})

0 commit comments

Comments
 (0)