Skip to content

Commit aa02379

Browse files
committed
fix(openfeature): clarify direct EVP routing
1 parent 3b591e2 commit aa02379

6 files changed

Lines changed: 16 additions & 20 deletions

File tree

packages/dd-trace/src/evp_proxy/direct.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const { format } = require('node:url')
44

55
const { HttpsProxyAgent } = require('https-proxy-agent')
66
const { getProxyForUrl } = require('proxy-from-env')
7+
const log = require('../log')
78

89
/**
910
* @typedef {object} DirectEVPRoute
10-
* @property {'direct'} mode - Route mode
1111
* @property {URL} url - Direct intake URL
1212
* @property {string} basePath - Direct intake base path
1313
* @property {object} headers - Direct intake authentication headers
@@ -36,15 +36,16 @@ function createDirectEVPRoute (config, intake) {
3636
const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined
3737

3838
return {
39-
mode: 'direct',
4039
url,
4140
basePath: '',
4241
headers: {
4342
'DD-API-KEY': apiKey,
4443
},
4544
...(agent && { agent }),
4645
}
47-
} catch {}
46+
} catch (error) {
47+
log.debug('Unable to configure direct EVP intake: %s', error.message)
48+
}
4849
}
4950

5051
module.exports = { createDirectEVPRoute }

packages/dd-trace/src/openfeature/writers/util.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ function setAgentlessStrategy (config, setWriterEnabledValue) {
7171
}, (error, localRoute) => {
7272
if (localRoute) {
7373
const route = {
74-
mode: 'local',
7574
...localRoute,
7675
headers: {
7776
[EVP_SUBDOMAIN_HEADER_NAME]: EVP_EVENT_PLATFORM_SUBDOMAIN,

packages/dd-trace/test/evp_proxy/direct.spec.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ describe('direct EVP route', () => {
1010
let createDirectEVPRoute
1111
let getProxyForUrl
1212
let HttpsProxyAgent
13+
let log
1314

1415
beforeEach(() => {
1516
getProxyForUrl = sinon.stub().returns('')
1617
HttpsProxyAgent = sinon.stub().callsFake(proxyUrl => ({ proxyUrl }))
18+
log = { debug: sinon.spy() }
1719

1820
;({ createDirectEVPRoute } = proxyquire('../../src/evp_proxy/direct', {
1921
'https-proxy-agent': { HttpsProxyAgent },
2022
'proxy-from-env': { getProxyForUrl },
23+
'../log': log,
2124
}))
2225
})
2326

@@ -28,7 +31,6 @@ describe('direct EVP route', () => {
2831
}, 'event-platform-intake')
2932

3033
assert.deepStrictEqual(route, {
31-
mode: 'direct',
3234
url: new URL('https://event-platform-intake.datadoghq.com'),
3335
basePath: '',
3436
headers: {
@@ -71,5 +73,11 @@ describe('direct EVP route', () => {
7173
DD_API_KEY: 'test-api-key',
7274
site: 'not a host',
7375
}, 'event-platform-intake'), undefined)
76+
77+
sinon.assert.calledOnceWithExactly(
78+
log.debug,
79+
'Unable to configure direct EVP intake: %s',
80+
sinon.match.string
81+
)
7482
})
7583
})

packages/dd-trace/test/openfeature/writers/exposures-transport.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ describe('OpenFeature Exposures Writer transport', () => {
6161
setExposureDeliveryStrategy(config, (enabled, route) => {
6262
try {
6363
assert.strictEqual(enabled, true)
64-
assert.strictEqual(route.mode, 'local')
6564
assert.strictEqual(route.basePath, '/evp_proxy/v4')
6665
writer.setEnabled(enabled, route)
6766
resolve()
@@ -118,8 +117,8 @@ describe('OpenFeature Exposures Writer transport', () => {
118117
setExposureDeliveryStrategy(config, (enabled, route) => {
119118
try {
120119
assert.strictEqual(enabled, true)
121-
assert.strictEqual(route.mode, 'local')
122-
assert.strictEqual(route.fallback.mode, 'direct')
120+
assert.strictEqual(route.basePath, '/evp_proxy/v4')
121+
assert.strictEqual(route.fallback.basePath, '')
123122
writer.setEnabled(enabled, route)
124123
resolve()
125124
} catch (error) {
@@ -173,7 +172,7 @@ describe('OpenFeature Exposures Writer transport', () => {
173172
setExposureDeliveryStrategy(config, (enabled, route) => {
174173
try {
175174
assert.strictEqual(enabled, true)
176-
assert.strictEqual(route.mode, 'direct')
175+
assert.strictEqual(route.basePath, '')
177176
writer.setEnabled(enabled, route)
178177
resolve()
179178
} catch (error) {

packages/dd-trace/test/openfeature/writers/exposures.spec.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ describe('OpenFeature Exposures Writer', () => {
410410
it('should flush events through the selected EVP v4 proxy path', () => {
411411
const url = new URL('http://serverless-init:9126')
412412
writer.setEnabled(true, {
413-
mode: 'local',
414413
url,
415414
basePath: '/evp_proxy/v4/',
416415
headers: {
@@ -446,7 +445,6 @@ describe('OpenFeature Exposures Writer', () => {
446445
const url = new URL('https://event-platform-intake.datadoghq.com')
447446
const agent = {}
448447
writer.setEnabled(true, {
449-
mode: 'direct',
450448
url,
451449
basePath: '',
452450
agent,
@@ -478,14 +476,12 @@ describe('OpenFeature Exposures Writer', () => {
478476
const directAgent = {}
479477
request.onFirstCall().yieldsAsync(error, null, statusCode)
480478
writer.setEnabled(true, {
481-
mode: 'local',
482479
url: localUrl,
483480
basePath: '/evp_proxy/v4',
484481
headers: {
485482
'X-Datadog-EVP-Subdomain': 'event-platform-intake',
486483
},
487484
fallback: {
488-
mode: 'direct',
489485
url: directUrl,
490486
basePath: '',
491487
agent: directAgent,
@@ -524,14 +520,12 @@ describe('OpenFeature Exposures Writer', () => {
524520
it(`should not retry ambiguous local ${name} through direct intake`, async () => {
525521
request.yieldsAsync(error, null, statusCode)
526522
writer.setEnabled(true, {
527-
mode: 'local',
528523
url: new URL('http://serverless-init:8126'),
529524
basePath: '/evp_proxy/v4',
530525
headers: {
531526
'X-Datadog-EVP-Subdomain': 'event-platform-intake',
532527
},
533528
fallback: {
534-
mode: 'direct',
535529
url: new URL('https://event-platform-intake.datadoghq.com'),
536530
basePath: '',
537531
headers: {

packages/dd-trace/test/openfeature/writers/util.spec.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ describe('OpenFeature exposure delivery strategy', () => {
7474
basePath: '/evp_proxy/v4',
7575
}
7676
const directRoute = {
77-
mode: 'direct',
7877
url: new URL('https://event-platform-intake.datadoghq.com'),
7978
basePath: '',
8079
headers: { 'DD-API-KEY': 'test-api-key' },
@@ -88,7 +87,6 @@ describe('OpenFeature exposure delivery strategy', () => {
8887
supportedPaths: ['/evp_proxy/v4', '/evp_proxy/v2'],
8988
}, sinon.match.func)
9089
sinon.assert.calledOnceWithExactly(setWriterEnabledValue, true, {
91-
mode: 'local',
9290
...localRoute,
9391
headers: {
9492
'X-Datadog-EVP-Subdomain': 'event-platform-intake',
@@ -113,7 +111,6 @@ describe('OpenFeature exposure delivery strategy', () => {
113111
supportedPaths: ['/evp_proxy/v4', '/evp_proxy/v2'],
114112
}, sinon.match.func)
115113
sinon.assert.calledOnceWithMatch(setWriterEnabledValue, true, {
116-
mode: 'local',
117114
basePath: '/evp_proxy/v2',
118115
})
119116
})
@@ -124,7 +121,6 @@ describe('OpenFeature exposure delivery strategy', () => {
124121
featureFlags: { DD_FEATURE_FLAGS_CONFIGURATION_SOURCE: 'agentless' },
125122
}
126123
const directRoute = {
127-
mode: 'direct',
128124
url: new URL('https://event-platform-intake.datadoghq.com'),
129125
basePath: '',
130126
headers: { 'DD-API-KEY': 'test-api-key' },
@@ -144,7 +140,6 @@ describe('OpenFeature exposure delivery strategy', () => {
144140
featureFlags: { DD_FEATURE_FLAGS_CONFIGURATION_SOURCE: 'agentless' },
145141
}
146142
const directRoute = {
147-
mode: 'direct',
148143
url: new URL('https://event-platform-intake.datadoghq.com'),
149144
basePath: '',
150145
headers: { 'DD-API-KEY': 'test-api-key' },

0 commit comments

Comments
 (0)