Skip to content

Commit c12cfd7

Browse files
authored
chore(llmobs): add url origin env var (#6286)
* implementation * test
1 parent bf13fa7 commit c12cfd7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/dd-trace/src/llmobs/writers/base.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ class BaseLLMObsWriter {
120120
}
121121

122122
const { hostname, port } = this._config
123-
const base = this._config.url || new URL(format({
123+
124+
const overrideOriginEnv = getEnvironmentVariable('_DD_LLMOBS_OVERRIDE_ORIGIN')
125+
const overrideOriginUrl = overrideOriginEnv && new URL(overrideOriginEnv)
126+
127+
const base = overrideOriginUrl ?? this._config.url ?? new URL(format({
124128
protocol: 'http:',
125129
hostname,
126130
port

packages/dd-trace/test/llmobs/writers/base.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22
const { expect } = require('chai')
33
const proxyquire = require('proxyquire')
4+
const { useEnv } = require('../../../../../integration-tests/helpers')
45

56
describe('BaseLLMObsWriter', () => {
67
let BaseLLMObsWriter
@@ -60,6 +61,19 @@ describe('BaseLLMObsWriter', () => {
6061
expect(writer.url).to.equal('http://localhost:8126/evp_proxy/v2/endpoint')
6162
})
6263

64+
describe('with override origin', () => {
65+
useEnv({
66+
_DD_LLMOBS_OVERRIDE_ORIGIN: 'http://override-origin:12345'
67+
})
68+
69+
it('constructs a writer with the correct url', () => {
70+
writer = new BaseLLMObsWriter(options)
71+
writer.setAgentless(false)
72+
73+
expect(writer.url).to.equal('http://override-origin:12345/evp_proxy/v2/endpoint')
74+
})
75+
})
76+
6377
describe('with config url', () => {
6478
beforeEach(() => {
6579
options.config.url = new URL('http://test-agent:12345')

0 commit comments

Comments
 (0)