dd-trace 6.10.0 → 6.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -17
- package/index.d.ts +108 -3
- package/initialize.mjs +28 -17
- package/openfeature.js +2 -2
- package/package.json +11 -8
- package/packages/datadog-esbuild/index.js +0 -34
- package/packages/datadog-instrumentations/src/anthropic.js +210 -15
- package/packages/datadog-instrumentations/src/aws-sdk.js +9 -1
- package/packages/datadog-instrumentations/src/browser-bunyan.js +11 -0
- package/packages/datadog-instrumentations/src/bunyan.js +3 -16
- package/packages/datadog-instrumentations/src/cucumber.js +26 -11
- package/packages/datadog-instrumentations/src/cypress-config.js +182 -16
- package/packages/datadog-instrumentations/src/cypress-legacy-finalizers.js +30 -0
- package/packages/datadog-instrumentations/src/cypress.js +2 -0
- package/packages/datadog-instrumentations/src/fastify.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/bunyan.js +22 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +9 -4
- package/packages/datadog-instrumentations/src/helpers/register.js +10 -8
- package/packages/datadog-instrumentations/src/jest.js +25 -17
- package/packages/datadog-instrumentations/src/mariadb.js +278 -21
- package/packages/datadog-instrumentations/src/mocha/main.js +539 -55
- package/packages/datadog-instrumentations/src/mocha/utils.js +130 -17
- package/packages/datadog-instrumentations/src/playwright-reporter.js +99 -0
- package/packages/datadog-instrumentations/src/playwright.js +149 -2
- package/packages/datadog-instrumentations/src/router.js +2 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +11 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +163 -44
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +2 -8
- package/packages/datadog-plugin-azure-functions/src/index.js +1 -1
- package/packages/datadog-plugin-browser-bunyan/src/index.js +9 -0
- package/packages/datadog-plugin-bunyan/src/index.js +5 -8
- package/packages/datadog-plugin-cucumber/src/index.js +11 -0
- package/packages/datadog-plugin-cypress/src/after-run.js +5 -1
- package/packages/datadog-plugin-cypress/src/after-spec.js +5 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +81 -29
- package/packages/datadog-plugin-cypress/src/finalization.js +76 -0
- package/packages/datadog-plugin-cypress/src/index.js +12 -6
- package/packages/datadog-plugin-cypress/src/plugin.js +16 -3
- package/packages/datadog-plugin-dd-trace-api/src/index.js +4 -0
- package/packages/datadog-plugin-electron/src/index.js +2 -0
- package/packages/datadog-plugin-fs/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +6 -0
- package/packages/datadog-plugin-mocha/src/index.js +56 -1
- package/packages/datadog-plugin-nats/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/tracing.js +41 -30
- package/packages/datadog-plugin-openai-agents/src/integration.js +1 -0
- package/packages/datadog-plugin-playwright/src/index.js +42 -13
- package/packages/datadog-plugin-vitest/src/index.js +6 -0
- package/packages/datadog-webpack/index.js +0 -11
- package/packages/dd-trace/index.js +0 -1
- package/packages/dd-trace/src/agent/info.js +6 -5
- package/packages/dd-trace/src/aiguard/client.js +100 -1
- package/packages/dd-trace/src/aiguard/errors.js +41 -0
- package/packages/dd-trace/src/aiguard/evaluation.js +357 -0
- package/packages/dd-trace/src/aiguard/integrations/anthropic.js +70 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +4 -0
- package/packages/dd-trace/src/aiguard/messages/anthropic.js +423 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +1 -24
- package/packages/dd-trace/src/aiguard/messages/utils.js +28 -0
- package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +1 -11
- package/packages/dd-trace/src/aiguard/sdk.js +22 -278
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +9 -12
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +1 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +27 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +22 -6
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +21 -5
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/request-tracker.js +164 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +22 -6
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +365 -32
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +201 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +5 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +9 -5
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -1
- package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +39 -0
- package/packages/dd-trace/src/ci-visibility/requests/request.js +3 -6
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +6 -2
- package/packages/dd-trace/src/config/generated-config-types.d.ts +4 -0
- package/packages/dd-trace/src/config/index.js +13 -2
- package/packages/dd-trace/src/config/major-overrides.js +7 -0
- package/packages/dd-trace/src/config/supported-configurations.json +14 -0
- package/packages/dd-trace/src/datastreams/index.js +2 -0
- package/packages/dd-trace/src/datastreams/manager.js +9 -2
- package/packages/dd-trace/src/datastreams/processor.js +15 -13
- package/packages/dd-trace/src/datastreams/size.js +5 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +3 -2
- package/packages/dd-trace/src/exporters/agent/writer.js +49 -9
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +6 -4
- package/packages/dd-trace/src/exporters/common/writer.js +11 -6
- package/packages/dd-trace/src/llmobs/experiments/client.js +163 -5
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +241 -87
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +280 -20
- package/packages/dd-trace/src/llmobs/experiments/index.js +58 -59
- package/packages/dd-trace/src/llmobs/experiments/noop.js +71 -3
- package/packages/dd-trace/src/llmobs/experiments/result.js +1 -0
- package/packages/dd-trace/src/llmobs/experiments/util.js +41 -5
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +12 -3
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -2
- package/packages/dd-trace/src/noop/proxy.js +3 -4
- package/packages/dd-trace/src/openfeature/flagging_provider.js +18 -2
- package/packages/dd-trace/src/openfeature/remote_config.js +1 -1
- package/packages/dd-trace/src/opentelemetry/context_manager.js +7 -7
- package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +2 -1
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +67 -11
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +14 -3
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +25 -12
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +2 -5
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +96 -43
- package/packages/dd-trace/src/opentracing/tracer.js +5 -2
- package/packages/dd-trace/src/otel-thread-ctx.js +387 -0
- package/packages/dd-trace/src/plugin_manager.js +3 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +6 -1
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/util/jest.js +4 -3
- package/packages/dd-trace/src/plugins/util/test.js +9 -9
- package/packages/dd-trace/src/plugins/util/web.js +3 -0
- package/packages/dd-trace/src/profiling/profiler.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/space.js +1 -3
- package/packages/dd-trace/src/profiling/profilers/wall.js +37 -90
- package/packages/dd-trace/src/profiling/webspan-utils.js +45 -0
- package/packages/dd-trace/src/proxy.js +38 -29
- package/packages/dd-trace/src/ritm.js +9 -2
- package/packages/dd-trace/src/serverless.js +37 -0
- package/packages/dd-trace/src/span_format.js +1 -0
- package/packages/dd-trace/src/span_stats.js +30 -3
- package/packages/dd-trace/src/storage-channels.js +86 -0
- package/packages/dd-trace/src/tracer.js +9 -2
- package/packages/dd-trace/src/tracer_metadata.js +14 -1
- package/packages/dd-trace/src/web-tags-cache.js +132 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +201 -0
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +0 -65
- package/packages/datadog-webpack/src/optional-peer-loader.js +0 -17
- package/packages/dd-trace/src/feature-registry.js +0 -29
- package/packages/dd-trace/src/openfeature/register.js +0 -35
- package/packages/dd-trace/src/openfeature/require-provider.js +0 -18
|
@@ -14,8 +14,10 @@ const {
|
|
|
14
14
|
GRPC_STATUS_CODE,
|
|
15
15
|
} = require('../../../ext/tags')
|
|
16
16
|
const { ORIGIN_KEY, TOP_LEVEL_KEY, SVC_SRC_KEY, GRPC_STATUS_NAMES } = require('./constants')
|
|
17
|
+
const id = require('./id')
|
|
17
18
|
|
|
18
19
|
const GRPC_STATUS_CODE_MAP = Object.fromEntries(GRPC_STATUS_NAMES.map((name, i) => [name, String(i)]))
|
|
20
|
+
const ZERO_ID = id('0')
|
|
19
21
|
const { version } = require('./pkg')
|
|
20
22
|
const processTags = require('./process-tags')
|
|
21
23
|
|
|
@@ -150,9 +152,24 @@ class SpanAggKey {
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
class SpanBuckets extends Map {
|
|
155
|
+
#includeTraceRoot
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {boolean} [includeTraceRoot]
|
|
159
|
+
*/
|
|
160
|
+
constructor (includeTraceRoot = false) {
|
|
161
|
+
super()
|
|
162
|
+
this.#includeTraceRoot = includeTraceRoot
|
|
163
|
+
}
|
|
164
|
+
|
|
153
165
|
forSpan (span) {
|
|
154
166
|
const aggKey = new SpanAggKey(span)
|
|
155
|
-
const
|
|
167
|
+
const baseKey = aggKey.toString()
|
|
168
|
+
const parentId = span.parent_id
|
|
169
|
+
if (this.#includeTraceRoot && parentId !== undefined && parentId !== null) {
|
|
170
|
+
aggKey.isTraceRoot = parentId.equals(ZERO_ID)
|
|
171
|
+
}
|
|
172
|
+
const key = this.#includeTraceRoot ? `${baseKey},${aggKey.isTraceRoot}` : baseKey
|
|
156
173
|
|
|
157
174
|
if (!this.has(key)) {
|
|
158
175
|
this.set(key, new SpanAggStats(aggKey))
|
|
@@ -163,9 +180,19 @@ class SpanBuckets extends Map {
|
|
|
163
180
|
}
|
|
164
181
|
|
|
165
182
|
class TimeBuckets extends Map {
|
|
183
|
+
#includeTraceRoot
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @param {boolean} [includeTraceRoot]
|
|
187
|
+
*/
|
|
188
|
+
constructor (includeTraceRoot = false) {
|
|
189
|
+
super()
|
|
190
|
+
this.#includeTraceRoot = includeTraceRoot
|
|
191
|
+
}
|
|
192
|
+
|
|
166
193
|
forTime (time) {
|
|
167
194
|
if (!this.has(time)) {
|
|
168
|
-
this.set(time, new SpanBuckets())
|
|
195
|
+
this.set(time, new SpanBuckets(this.#includeTraceRoot))
|
|
169
196
|
}
|
|
170
197
|
|
|
171
198
|
return this.get(time)
|
|
@@ -192,7 +219,7 @@ class SpanStatsProcessor {
|
|
|
192
219
|
const intervalMs = otlpExporter ? (flushIntervalMs ?? 10_000) : interval * 1e3
|
|
193
220
|
this.interval = intervalMs / 1e3
|
|
194
221
|
this.bucketSizeNs = intervalMs * 1e6
|
|
195
|
-
this.buckets = new TimeBuckets()
|
|
222
|
+
this.buckets = new TimeBuckets(Boolean(otlpExporter))
|
|
196
223
|
this.hostname = os.hostname()
|
|
197
224
|
this.enabled = enabled
|
|
198
225
|
this.otlpExporter = otlpExporter || null
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const dc = require('dc-polyfill')
|
|
4
|
+
const { storage } = require('../../datadog-core')
|
|
5
|
+
|
|
6
|
+
// Channels that surface tracer-storage events to interested consumers
|
|
7
|
+
// (currently the wall profiler and the OTEP-4947 thread context writer).
|
|
8
|
+
//
|
|
9
|
+
// dd-trace:storage:enter — fires when the active legacy-storage store
|
|
10
|
+
// changes. Published by the shimmer installed in ensureChannelsActivated().
|
|
11
|
+
// dd-trace:storage:before — fires from an async_hooks "before" callback in
|
|
12
|
+
// non-AsyncContextFrame mode. Used by the wall profiler to refresh the
|
|
13
|
+
// sample context at the start of each async resource callback. Has no
|
|
14
|
+
// publisher in ACF mode.
|
|
15
|
+
// dd-trace:span:finish, dd-trace:span:tags:update — published by the
|
|
16
|
+
// tracer core (opentracing/span.js). Re-exported here as a convenience
|
|
17
|
+
// so consumers have a single import path for storage-related channels.
|
|
18
|
+
const enterCh = dc.channel('dd-trace:storage:enter')
|
|
19
|
+
const beforeCh = dc.channel('dd-trace:storage:before')
|
|
20
|
+
const spanFinishCh = dc.channel('dd-trace:span:finish')
|
|
21
|
+
const tagsUpdateCh = dc.channel('dd-trace:span:tags:update')
|
|
22
|
+
|
|
23
|
+
function getActiveSpan () {
|
|
24
|
+
const store = storage('legacy').getStore()
|
|
25
|
+
return store && store.span
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let channelsActivated = false
|
|
29
|
+
// Idempotent. The asyncContextFrameEnabled argument from the first caller
|
|
30
|
+
// wins; subsequent calls are no-ops regardless of their argument. In
|
|
31
|
+
// practice all callers observe the same global ACF state.
|
|
32
|
+
function ensureChannelsActivated (asyncContextFrameEnabled) {
|
|
33
|
+
if (channelsActivated) return
|
|
34
|
+
|
|
35
|
+
const shimmer = require('../../datadog-shimmer')
|
|
36
|
+
|
|
37
|
+
// We need to instrument enterWith() on the legacy storage — that's the storage
|
|
38
|
+
// carrying span data and the only one consumers of these channels care about.
|
|
39
|
+
const legacyStorage = storage('legacy')
|
|
40
|
+
let inRun = false
|
|
41
|
+
shimmer.wrap(legacyStorage, 'enterWith', function (original) {
|
|
42
|
+
return function (store) {
|
|
43
|
+
const retVal = original.call(this, store)
|
|
44
|
+
if (!inRun) enterCh.publish()
|
|
45
|
+
return retVal
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// When not using AsyncContextFrame, we need additional instrumentation.
|
|
50
|
+
if (!asyncContextFrameEnabled) {
|
|
51
|
+
// We need async_hooks.createHook to create a "before" callback.
|
|
52
|
+
const { createHook } = require('async_hooks')
|
|
53
|
+
createHook({ before: () => beforeCh.publish() }).enable()
|
|
54
|
+
|
|
55
|
+
// In ACF-based implementation run() delegates to enterWith() so it doesn't
|
|
56
|
+
// need to be separately instrumented. in non-ACF implementation run()
|
|
57
|
+
// doesn't delegate to enterWith(), so separate instrumentation is necessary.
|
|
58
|
+
shimmer.wrap(legacyStorage, 'run', function (original) {
|
|
59
|
+
return function (store, callback, ...args) {
|
|
60
|
+
const wrappedCb = shimmer.wrapFunction(callback, cb => function (...args) {
|
|
61
|
+
inRun = false
|
|
62
|
+
enterCh.publish()
|
|
63
|
+
const retVal = cb.apply(this, args)
|
|
64
|
+
inRun = true
|
|
65
|
+
return retVal
|
|
66
|
+
})
|
|
67
|
+
inRun = true
|
|
68
|
+
const retVal = original.call(this, store, wrappedCb, ...args)
|
|
69
|
+
enterCh.publish()
|
|
70
|
+
inRun = false
|
|
71
|
+
return retVal
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
channelsActivated = true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
enterCh,
|
|
81
|
+
beforeCh,
|
|
82
|
+
spanFinishCh,
|
|
83
|
+
tagsUpdateCh,
|
|
84
|
+
getActiveSpan,
|
|
85
|
+
ensureChannelsActivated,
|
|
86
|
+
}
|
|
@@ -59,8 +59,15 @@ class DatadogTracer extends Tracer {
|
|
|
59
59
|
|
|
60
60
|
// todo[piochelepiotr] These two methods are not related to the tracer, but to data streams monitoring.
|
|
61
61
|
// They should be moved outside of the tracer in the future.
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @param {string[]} edgeTags
|
|
64
|
+
* @param {import('./opentracing/span')|null} span
|
|
65
|
+
* @param {number} [payloadSize]
|
|
66
|
+
* @param {number} [pathwayContextSize] See `DataStreamsProcessor#setCheckpoint`.
|
|
67
|
+
* @returns {object|undefined}
|
|
68
|
+
*/
|
|
69
|
+
setCheckpoint (edgeTags, span, payloadSize = 0, pathwayContextSize) {
|
|
70
|
+
return this._dataStreamsManager.setCheckpoint(edgeTags, span, payloadSize, pathwayContextSize)
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
decodeDataStreamsContext (carrier) {
|
|
@@ -18,6 +18,18 @@ function storeConfig (config) {
|
|
|
18
18
|
? (processTags.serialized || null)
|
|
19
19
|
: null
|
|
20
20
|
|
|
21
|
+
// OTEP-4947 thread-context writer metadata, published as part of the
|
|
22
|
+
// OTel process context so an out-of-process reader can decode the
|
|
23
|
+
// on-wire record: the attribute key map (libdatadog prepends the
|
|
24
|
+
// implicit `datadog.local_root_span_id` at wire index 0, so we only
|
|
25
|
+
// supply our own additional keys), the schema-version string, and
|
|
26
|
+
// the V8 layout constants the reader needs. Gated on the same config
|
|
27
|
+
// flag that activates the writer; undefined when off or when
|
|
28
|
+
// @datadog/pprof isn't installed to provide the values.
|
|
29
|
+
const threadlocalMetadata = config.DD_TRACE_OTEL_CTX_ENABLED
|
|
30
|
+
? require('./otel-thread-ctx').getThreadLocalMetadata()
|
|
31
|
+
: undefined
|
|
32
|
+
|
|
21
33
|
const metadata = new processDiscovery.TracerMetadata(
|
|
22
34
|
config.tags['runtime-id'],
|
|
23
35
|
tracerVersion,
|
|
@@ -26,7 +38,8 @@ function storeConfig (config) {
|
|
|
26
38
|
config.env || null,
|
|
27
39
|
config.version || null,
|
|
28
40
|
processTagsSerialized,
|
|
29
|
-
containerId || null
|
|
41
|
+
containerId || null,
|
|
42
|
+
threadlocalMetadata
|
|
30
43
|
)
|
|
31
44
|
|
|
32
45
|
return processDiscovery.storeMetadata(metadata)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Per-span cache of "which tag bag from the started-spans chain identifies
|
|
4
|
+
// this span (or its nearest web-server ancestor) as a web-server span?"
|
|
5
|
+
// Populated lazily on first `getCachedWebTags(span)`, refreshed
|
|
6
|
+
// automatically when a `dd-trace:span:tags:update` event promotes a
|
|
7
|
+
// previously-empty answer for that span into a real value.
|
|
8
|
+
//
|
|
9
|
+
// Used by the wall profiler (endpoint-collection label on samples) and by
|
|
10
|
+
// the OTEP-4947 thread-context writer (endpoint attribute in the record);
|
|
11
|
+
// having a single cache means the parent-chain walk happens once per span
|
|
12
|
+
// no matter how many consumers ask.
|
|
13
|
+
//
|
|
14
|
+
// Consumers that want to react to late web-server-span discovery
|
|
15
|
+
// subscribe to `resolvedCh` — a diagnostics channel we publish on once
|
|
16
|
+
// per span at the moment its cached webTags transitions from undefined
|
|
17
|
+
// to a real value. Doing it via a channel (rather than exposing a
|
|
18
|
+
// stateful "did the transition happen?" query) means each consumer sees
|
|
19
|
+
// every transition exactly once, regardless of subscription order or
|
|
20
|
+
// how many other consumers are attached.
|
|
21
|
+
//
|
|
22
|
+
// `endpointResolvedCh` is the same idea one field over: published once per
|
|
23
|
+
// web-server span at the moment its endpoint name settles (see finalEndpoint in
|
|
24
|
+
// profiling/webspan-utils.js), i.e. when routing tags stop being interim
|
|
25
|
+
// placeholders. Consumers that must materialize the endpoint eagerly rather
|
|
26
|
+
// than read the tag bag at leisure need that moment; owning it here means the
|
|
27
|
+
// one `dd-trace:span:tags:update` subscription this module already holds serves
|
|
28
|
+
// them too, instead of each consumer adding its own subscriber to that hot
|
|
29
|
+
// channel and re-deriving finality itself.
|
|
30
|
+
//
|
|
31
|
+
// The module-level `dd-trace:span:tags:update` subscription that drives
|
|
32
|
+
// the transition promotion is installed lazily via `activate()` /
|
|
33
|
+
// `deactivate()`, ref-counted across consumers. When no consumer has
|
|
34
|
+
// activated the cache, `dd-trace:span:tags:update` stays subscriber-free
|
|
35
|
+
// so `DatadogSpan#setTag` / `addTags` skip the publish path entirely.
|
|
36
|
+
// Consumers MUST balance every activate() call with a matching
|
|
37
|
+
// deactivate() when they stop caring.
|
|
38
|
+
|
|
39
|
+
const dc = require('dc-polyfill')
|
|
40
|
+
const { finalEndpoint, isWebServerSpan, getStartedSpans } = require('./profiling/webspan-utils')
|
|
41
|
+
|
|
42
|
+
// Fields on the cache entry:
|
|
43
|
+
// resolved: true once the parent-chain walk has run.
|
|
44
|
+
// webTags: the resolved tag bag, or undefined when the walk came up
|
|
45
|
+
// empty (no web-server span found in the started-spans chain).
|
|
46
|
+
// endpointFinal: true once this span is a web-server span whose endpoint name
|
|
47
|
+
// has settled and endpointResolvedCh has been published for it.
|
|
48
|
+
const CachedSym = Symbol('WebTagsCache')
|
|
49
|
+
|
|
50
|
+
const tagsUpdateCh = dc.channel('dd-trace:span:tags:update')
|
|
51
|
+
const resolvedCh = dc.channel('dd-trace:web-tags:resolved')
|
|
52
|
+
const endpointResolvedCh = dc.channel('dd-trace:web-tags:endpoint-resolved')
|
|
53
|
+
|
|
54
|
+
function getCache (span) {
|
|
55
|
+
let cached = span[CachedSym]
|
|
56
|
+
if (cached === undefined) {
|
|
57
|
+
cached = {}
|
|
58
|
+
span[CachedSym] = cached
|
|
59
|
+
}
|
|
60
|
+
return cached
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Returns the web-server tag bag for this span or its nearest web-server
|
|
64
|
+
// ancestor in the started-spans chain, or undefined if none is a
|
|
65
|
+
// web-server span. Lazy: walks the parent chain on the first call, caches
|
|
66
|
+
// the result on the span.
|
|
67
|
+
function getCachedWebTags (span) {
|
|
68
|
+
const cached = getCache(span)
|
|
69
|
+
if (cached.resolved) return cached.webTags
|
|
70
|
+
const spanContext = span.context()
|
|
71
|
+
const tags = spanContext.getTags()
|
|
72
|
+
let webTags
|
|
73
|
+
if (isWebServerSpan(tags)) {
|
|
74
|
+
webTags = tags
|
|
75
|
+
} else {
|
|
76
|
+
const parentId = spanContext._parentId
|
|
77
|
+
const startedSpans = getStartedSpans(spanContext)
|
|
78
|
+
for (let i = startedSpans.length; --i >= 0;) {
|
|
79
|
+
const ispan = startedSpans[i]
|
|
80
|
+
if (ispan.context()._spanId === parentId) {
|
|
81
|
+
webTags = getCachedWebTags(ispan)
|
|
82
|
+
break
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
cached.webTags = webTags
|
|
87
|
+
cached.resolved = true
|
|
88
|
+
return webTags
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Own the tagsUpdate → transition promotion here. The dc subscribe
|
|
92
|
+
// happens lazily via activate(); each active consumer bumps a refcount,
|
|
93
|
+
// the last deactivate() removes the subscription. When idle, this module
|
|
94
|
+
// contributes no subscribers to `dd-trace:span:tags:update`, so
|
|
95
|
+
// `DatadogSpan#setTag` / `addTags` never enter the publish path on our
|
|
96
|
+
// behalf.
|
|
97
|
+
function onTagsUpdate (span) {
|
|
98
|
+
const cached = span[CachedSym]
|
|
99
|
+
if (cached === undefined || !cached.resolved) return
|
|
100
|
+
const tags = span.context().getTags()
|
|
101
|
+
if (cached.webTags === undefined) {
|
|
102
|
+
if (!isWebServerSpan(tags)) return
|
|
103
|
+
cached.webTags = tags
|
|
104
|
+
resolvedCh.publish(span)
|
|
105
|
+
}
|
|
106
|
+
// Endpoint finality is a property of the web-server span itself: for a
|
|
107
|
+
// descendant, cached.webTags is an ancestor's bag rather than these tags, and
|
|
108
|
+
// the ancestor's own update is what settles the endpoint. Skipped entirely
|
|
109
|
+
// when nobody is listening, keeping this the same early return it used to be
|
|
110
|
+
// for consumers that only care about web-tag discovery.
|
|
111
|
+
if (!endpointResolvedCh.hasSubscribers || cached.endpointFinal || cached.webTags !== tags) return
|
|
112
|
+
if (finalEndpoint(tags) === undefined) return
|
|
113
|
+
cached.endpointFinal = true
|
|
114
|
+
endpointResolvedCh.publish(span)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let activeCount = 0
|
|
118
|
+
|
|
119
|
+
function activate () {
|
|
120
|
+
if (activeCount++ === 0) {
|
|
121
|
+
tagsUpdateCh.subscribe(onTagsUpdate)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function deactivate () {
|
|
126
|
+
if (activeCount === 0) return
|
|
127
|
+
if (--activeCount === 0) {
|
|
128
|
+
tagsUpdateCh.unsubscribe(onTagsUpdate)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = { getCachedWebTags, resolvedCh, endpointResolvedCh, activate, deactivate }
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025-present Datadog, Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var e={"./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractAssignmentCache=void 0,t.assignmentCacheKeyToString=assignmentCacheKeyToString,t.assignmentCacheValueToString=assignmentCacheValueToString;let r=a("./@datadog/flagging-core/cjs/obfuscation.js");function assignmentCacheKeyToString(e){let t={flag:{key:e.flag.key},subject:{id:e.subject.id,attributes:e.subject.attributes}};return(0,r.getMD5Hash)(JSON.stringify(t))}function assignmentCacheValueToString(e){return(0,r.getMD5Hash)(JSON.stringify(e))}let AbstractAssignmentCache=class AbstractAssignmentCache{constructor(e){this.delegate=e}init(){return Promise.resolve()}has(e){return this.get(e)===assignmentCacheValueToString(e)}get(e){return this.delegate.get(assignmentCacheKeyToString(e))}set(e){this.delegate.set(assignmentCacheKeyToString(e),assignmentCacheValueToString(e))}entries(){return this.delegate.entries()}clear(){this.delegate.clear()}};t.AbstractAssignmentCache=AbstractAssignmentCache},"./@datadog/flagging-core/cjs/cache/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js"),t),n(a("./@datadog/flagging-core/cjs/cache/lru-in-memory-assignment-cache.js"),t),n(a("./@datadog/flagging-core/cjs/cache/non-expiring-in-memory-cache-assignment.js"),t)},"./@datadog/flagging-core/cjs/cache/lru-cache.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LRUCache=void 0;let LRUCache=class LRUCache{constructor(e){this.capacity=e,this.cache=new Map}entries(){return this.cache.entries()}clear(){this.cache.clear()}delete(e){return this.cache.delete(e)}keys(){return this.cache.keys()}values(){return this.cache.values()}has(e){return this.cache.has(e)}get(e){if(!this.has(e))return;let t=this.cache.get(e);return void 0!==t&&(this.delete(e),this.cache.set(e,t)),t}set(e,t){if(0===this.capacity)return this;if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){let e=this.cache.keys().next().value;e&&this.delete(e)}return this.cache.set(e,t),this}};t.LRUCache=LRUCache},"./@datadog/flagging-core/cjs/cache/lru-in-memory-assignment-cache.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LRUInMemoryAssignmentCache=void 0;let r=a("./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js"),n=a("./@datadog/flagging-core/cjs/cache/lru-cache.js");let LRUInMemoryAssignmentCache=class LRUInMemoryAssignmentCache extends r.AbstractAssignmentCache{constructor(e){super(new n.LRUCache(e))}};t.LRUInMemoryAssignmentCache=LRUInMemoryAssignmentCache},"./@datadog/flagging-core/cjs/cache/non-expiring-in-memory-cache-assignment.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NonExpiringInMemoryAssignmentCache=void 0;let r=a("./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js");let NonExpiringInMemoryAssignmentCache=class NonExpiringInMemoryAssignmentCache extends r.AbstractAssignmentCache{constructor(e=new Map){super(e)}};t.NonExpiringInMemoryAssignmentCache=NonExpiringInMemoryAssignmentCache},"./@datadog/flagging-core/cjs/configuration/configuration.js"(e,t){"use strict";function configMatchesContext(e,t){if(!(null==e?void 0:e.precomputed))return!1;let a=e.precomputed.context;return!a||contextsEqual(a,t)}function contextsEqual(e,t){return objectsEqual(e,t)}function objectsEqual(e,t){let a=Object.keys(e).sort(),r=Object.keys(t).sort();if(a.length!==r.length)return!1;for(let n=0;n<a.length;n++)if(a[n]!==r[n]||!valuesEqual(e[a[n]],t[r[n]]))return!1;return!0}function isRecord(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function valuesEqual(e,t){return e===t||null!=e&&null!=t&&typeof e==typeof t&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,a)=>valuesEqual(e,t[a])):!!(isRecord(e)&&isRecord(t))&&objectsEqual(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.configMatchesContext=configMatchesContext},"./@datadog/flagging-core/cjs/configuration/exposureEvent.js"(e,t){"use strict";function createExposureEvent(e,t){var a,r;if(!(null==(a=t.flagMetadata)?void 0:a.doLog))return;let n=null==(r=t.flagMetadata)?void 0:r.allocationKey,i=t.variant;if(!n||!i)return;let{targetingKey:o="",...s}=e;return{allocation:{key:n},flag:{key:t.flagKey},variant:{key:i},subject:{id:o,attributes:s}}}Object.defineProperty(t,"__esModule",{value:!0}),t.createExposureEvent=createExposureEvent},"./@datadog/flagging-core/cjs/configuration/exposureEvent.types.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},"./@datadog/flagging-core/cjs/configuration/flagEvaluationAggregator.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlagEvaluationAggregator=void 0;let r=a("./@datadog/flagging-core/cjs/obfuscation.js"),n=a("./@datadog/flagging-core/cjs/time.js"),i=a("./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.js");let FlagEvaluationAggregator=class FlagEvaluationAggregator{constructor(e,t){this.aggregatedData=new Map,this.flushInterval=e,this.onFlush=t}start(){this.intervalId=setInterval(()=>{this.flush()},this.flushInterval)}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.flush()}addEvaluation(e,t,a){var r,n;let i=this.createAggregationKeyString(e,t,a),o=getEvaluationTimestamp(t),s=this.aggregatedData.get(i);if(s)s.count++,s.lastEvaluation=o,a&&(s.error=a);else{let s=isRuntimeDefaultUsed(t),l=null==(r=t.flagMetadata)?void 0:r.allocationKey,u=null==(n=t.flagMetadata)?void 0:n.targetingRuleKey,{targetingKey:c,...g}=e;this.aggregatedData.set(i,{flagKey:t.flagKey,variantKey:t.variant,allocationKey:l,targetingRuleKey:u,targetingKey:c,targetingContext:g,count:1,firstEvaluation:o,lastEvaluation:o,runtimeDefaultUsed:s,error:a})}}flush(){if(0===this.aggregatedData.size)return;let e=(0,n.timeStampNow)(),t=Array.from(this.aggregatedData.values()).map(t=>(0,i.createFlagEvaluationEvent)(t,e));this.aggregatedData.clear(),this.onFlush(t)}createAggregationKeyString(e,t,a){var n,i;let o=null==(n=t.flagMetadata)?void 0:n.allocationKey,s=null==(i=t.flagMetadata)?void 0:i.targetingRuleKey,{targetingKey:l,...u}=e;return(0,r.getMD5Hash)(JSON.stringify({flagKey:t.flagKey,variant:t.variant||"",allocationKey:o||"",targetingRuleKey:s||"",targetingKey:l||"",targetingContext:u,error:a||""}))}};function getEvaluationTimestamp(e){var t;let a=null==(t=e.flagMetadata)?void 0:t.__dd_eval_timestamp_ms;return Number.isFinite(a)?a:(0,n.timeStampNow)()}function isRuntimeDefaultUsed(e){return null==e.variant}t.FlagEvaluationAggregator=FlagEvaluationAggregator},"./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.js"(e,t){"use strict";function createFlagEvaluationEvent(e,t){let a={flag:{key:e.flagKey},first_evaluation:e.firstEvaluation,last_evaluation:e.lastEvaluation,evaluation_count:e.count,runtime_default_used:e.runtimeDefaultUsed,timestamp:t};return null!=e.targetingKey&&(a.targeting_key=e.targetingKey),e.error&&(a.error={message:e.error}),e.variantKey&&(a.variant={key:e.variantKey}),e.allocationKey&&(a.allocation={key:e.allocationKey}),e.targetingRuleKey&&(a.targeting_rule={key:e.targetingRuleKey}),e.targetingContext&&Object.keys(e.targetingContext).length>0&&(a.context={evaluation:e.targetingContext}),a}Object.defineProperty(t,"__esModule",{value:!0}),t.createFlagEvaluationEvent=createFlagEvaluationEvent},"./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.types.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},"./@datadog/flagging-core/cjs/configuration/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/configuration/configuration.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/exposureEvent.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/exposureEvent.types.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/flagEvaluationAggregator.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.types.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/wire.js"),t)},"./@datadog/flagging-core/cjs/configuration/wire.js"(e,t){"use strict";function configurationFromString(e){try{let t=JSON.parse(e);if(1!==t.version)return{};let a={};return t.precomputed&&(a.precomputed={...t.precomputed,response:JSON.parse(t.precomputed.response)}),a}catch(e){return{}}}function configurationToString(e){let t={version:1};return e.precomputed&&(t.precomputed={...e.precomputed,response:JSON.stringify(e.precomputed.response)}),JSON.stringify(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.configurationFromString=configurationFromString,t.configurationToString=configurationToString},"./@datadog/flagging-core/cjs/evaluation/errors.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TargetingKeyMissingError=void 0;let TargetingKeyMissingError=class TargetingKeyMissingError extends Error{constructor(){super("Targeting key is required for split evaluation"),this.name="TargetingKeyMissingError"}};t.TargetingKeyMissingError=TargetingKeyMissingError},"./@datadog/flagging-core/cjs/evaluation/evaluateForSubject.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateForSubject=evaluateForSubject,t.containsMatchingRule=containsMatchingRule;let r=a("./@datadog/flagging-core/cjs/time.js"),n=a("./@datadog/flagging-core/cjs/evaluation/errors.js"),i=a("./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js"),o=a("./@datadog/flagging-core/cjs/evaluation/matchesShard.js"),s=a("./@datadog/flagging-core/cjs/evaluation/rules.js"),l=a("./@datadog/flagging-core/cjs/evaluation/ufc-v1.js");function evaluateForSubject(e,t,a,n,o,s,u=(0,r.timeStampNow)()){var c;if(!e.enabled)return s.debug("returning default assignment because flag is disabled",{flagKey:e.key,subjectKey:a}),{value:o,reason:"DISABLED",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)};if(!isValidFlag(e))return s.debug("returning default assignment because flag configuration is invalid",{flagKey:e.key,subjectKey:a}),{value:o,reason:"DEFAULT",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)};if(!validateTypeMatch(t,e.variationType))return s.debug("variant value type mismatch, returning default value",{flagKey:e.key,subjectKey:a,expectedType:t,variantType:e.variationType}),{value:o,reason:"ERROR",errorCode:"TYPE_MISMATCH",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)};let g=new Date(u);for(let t of e.allocations){if(t.startAt&&g<new Date(t.startAt)){s.debug("allocation before start date",{flagKey:e.key,subjectKey:a,allocationKey:t.key,startAt:t.startAt});continue}if(t.endAt&&g>=new Date(t.endAt)){s.debug("allocation after end date",{flagKey:e.key,subjectKey:a,allocationKey:t.key,endAt:t.endAt});continue}if(!containsMatchingRule(t.rules,n,s))continue;let r=selectSplitUsingSharding(t.splits,a,e.key,s);if(r){let n=e.variations[r.variationKey];if(n){s.debug("evaluated a flag",{flagKey:e.key,subjectKey:a,assignment:n.value});let o=(null==(c=t.rules)?void 0:c.length)?"TARGETING_MATCH":r.shards.length?"SPLIT":t.startAt||t.endAt?"DEFAULT":"STATIC";return{value:n.value,reason:o,variant:n.key,flagMetadata:{...(0,i.createEvaluationTimestampMetadata)(u),__dd_allocation_key:t.key,__dd_do_log:!!t.doLog,__dd_split_serial_id:r.serialId,allocationKey:t.key,variationType:(0,l.variantTypeToFlagValueType)(e.variationType),doLog:!!t.doLog}}}}else s.debug("no matching split found for subject",{flagKey:e.key,subjectKey:a,allocationKey:t.key})}return s.debug("returning default assignment because no allocation matched",{flagKey:e.key,subjectKey:a}),{value:o,reason:"DEFAULT",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)}}function validateTypeMatch(e,t){if("boolean"===e)return"BOOLEAN"===t;if("string"===e)return"STRING"===t;if("number"===e)return"INTEGER"===t||"NUMERIC"===t;if("object"===e)return"JSON"===t;throw Error(`Invalid expected type: ${e}`)}function isValidFlag(e){return Array.isArray(e.allocations)&&e.allocations.every(e=>Array.isArray(e.splits)&&e.splits.every(e=>Array.isArray(e.shards))&&(void 0===e.rules||Array.isArray(e.rules)&&e.rules.every(e=>(0,s.isValidRule)(e))))}function containsMatchingRule(e,t,a){return null==e||!e.length||(a.debug("evaluating rules",{rules:JSON.stringify(e),subjectAttributes:t}),e.some(e=>(0,s.matchesRule)(e,t)))}function selectSplitUsingSharding(e,t,a,r){if(!e||0===e.length)return null;for(let i of e)if(r.debug("evaluating split sharding",{flagKey:a,subjectKey:t,variationKey:i.variationKey,shards:i.shards}),i.shards.every(e=>{if(null==t)throw new n.TargetingKeyMissingError;let s=(0,o.matchesShard)(e,t);return r.debug("shard match result",{flagKey:a,subjectKey:t,variationKey:i.variationKey,shard:e,matches:s}),s}))return r.debug("subject matches split",{flagKey:a,subjectKey:t,variationKey:i.variationKey}),i;return r.debug("subject matches no splits",{flagKey:a,subjectKey:t}),null}},"./@datadog/flagging-core/cjs/evaluation/evaluation.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateRulesBasedConfiguration=evaluateRulesBasedConfiguration;let r=a("./@datadog/flagging-core/cjs/time.js"),n=a("./@datadog/flagging-core/cjs/evaluation/errors.js"),i=a("./@datadog/flagging-core/cjs/evaluation/evaluateForSubject.js"),o=a("./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js");function evaluateRulesBasedConfiguration(e,t,a,s,l,u){let c=(0,r.timeStampNow)();if(!e)return{value:s,reason:"ERROR",errorCode:"PROVIDER_NOT_READY",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)};let{targetingKey:g,...d}=l,f={...null!=g?{id:g}:{},...d},h=e.flags[a];if(!h)return u.debug("returning default value because flag is not found",{flagKey:a,subjectKey:g}),{value:s,reason:"ERROR",errorCode:"FLAG_NOT_FOUND",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)};try{return(0,i.evaluateForSubject)(h,t,g,f,s,u,c)}catch(e){if(e instanceof n.TargetingKeyMissingError)return{value:s,reason:"ERROR",errorCode:"TARGETING_KEY_MISSING",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)};return u.error("Error evaluating flag",{error:e}),{value:s,reason:"ERROR",errorCode:"GENERAL",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)}}}},"./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js"(e,t){"use strict";function createEvaluationTimestampMetadata(e){return{__dd_eval_timestamp_ms:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createEvaluationTimestampMetadata=createEvaluationTimestampMetadata},"./@datadog/flagging-core/cjs/evaluation/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/evaluation/errors.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/evaluateForSubject.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/evaluation.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/matchesShard.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/rules.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/sharders.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/ufc-v1.js"),t)},"./@datadog/flagging-core/cjs/evaluation/matchesShard.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchesShard=matchesShard;let r=a("./@datadog/flagging-core/cjs/evaluation/sharders.js");function matchesShard(e,t,a){let n=(null!=a?a:new r.MD5Sharder).getShard(hashKey(e.salt,t),e.totalShards);return e.ranges.some(e=>isInShardRange(n,e))}function isInShardRange(e,t){return t.start<=e&&e<t.end}function hashKey(e,t){return`${e}-${t}`}},"./@datadog/flagging-core/cjs/evaluation/rules.js"(e,t){"use strict";var a,r;Object.defineProperty(t,"__esModule",{value:!0}),t.OperatorType=void 0,t.isValidRule=isValidRule,t.matchesRule=matchesRule,(r=a||(t.OperatorType=a={})).MATCHES="MATCHES",r.NOT_MATCHES="NOT_MATCHES",r.GTE="GTE",r.GT="GT",r.LTE="LTE",r.LT="LT",r.ONE_OF="ONE_OF",r.NOT_ONE_OF="NOT_ONE_OF",r.IS_NULL="IS_NULL";let n=new Set(Object.values(a));function isValidRule(e){return!!Array.isArray(e.conditions)&&e.conditions.every(e=>{if(!n.has(e.operator))return!1;if(e.operator!==a.MATCHES&&e.operator!==a.NOT_MATCHES)return!0;try{return compileRegex(e.value),!0}catch(e){return!1}})}function matchesRule(e,t){return!evaluateRuleConditions(t,e.conditions).includes(!1)}function evaluateRuleConditions(e,t){return t.map(t=>evaluateCondition(e,t))}function evaluateCondition(e,t){let r=e[t.attribute];if(t.operator===a.IS_NULL)return t.value?null==r:null!=r;if(null!=r)switch(t.operator){case a.GTE:case a.GT:case a.LTE:case a.LT:return compareNumber(r,t.value,(e,r)=>t.operator===a.GTE?e>=r:t.operator===a.GT?e>r:t.operator===a.LTE?e<=r:e<r);case a.MATCHES:return compileRegex(t.value).test(String(r));case a.NOT_MATCHES:return!compileRegex(t.value).test(String(r));case a.ONE_OF:var n;return n=r.toString(),t.value.includes(n);case a.NOT_ONE_OF:return isNotOneOf(r.toString(),t.value)}return!1}function compileRegex(e){let t=e.match(/^\(\?([imsu]+)\)/),a=t?[...new Set(t[1])].join(""):"";return new RegExp((t?e.slice(t[0].length):e).split("[:alnum:]").join("A-Za-z0-9"),a)}function isNotOneOf(e,t){return!t.includes(e)}function compareNumber(e,t,a){return a(Number(e),Number(t))}},"./@datadog/flagging-core/cjs/evaluation/sharders.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeterministicSharder=t.MD5Sharder=t.Sharder=void 0;let r=a("./@datadog/flagging-core/cjs/obfuscation.js");let Sharder=class Sharder{};t.Sharder=Sharder;let MD5Sharder=class MD5Sharder extends Sharder{getShard(e,t){return parseInt((0,r.getMD5Hash)(e).slice(0,8),16)%t}};t.MD5Sharder=MD5Sharder;let DeterministicSharder=class DeterministicSharder extends Sharder{constructor(e){super(),this.lookup=e}getShard(e,t){var a;return null!=(a=this.lookup[e])?a:0}};t.DeterministicSharder=DeterministicSharder},"./@datadog/flagging-core/cjs/evaluation/ufc-v1.js"(e,t){"use strict";function variantTypeToFlagValueType(e){if("BOOLEAN"===e)return"boolean";if("STRING"===e)return"string";if("INTEGER"===e||"NUMERIC"===e)return"number";if("JSON"===e)return"object";throw Error(`Cannot convert variant type to flag value type: ${e}`)}Object.defineProperty(t,"__esModule",{value:!0}),t.variantTypeToFlagValueType=variantTypeToFlagValueType},"./@datadog/flagging-core/cjs/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/cache/index.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/index.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/index.js"),t),n(a("./@datadog/flagging-core/cjs/obfuscation.js"),t),n(a("./@datadog/flagging-core/cjs/time.js"),t)},"./@datadog/flagging-core/cjs/obfuscation.js"(e,t,a){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getMD5Hash=getMD5Hash,t.buildStorageKeySuffix=buildStorageKeySuffix;let n=r(a("./spark-md5/spark-md5.js"));function getMD5Hash(e,t=""){return new n.default().append(t).append(e).end()}function buildStorageKeySuffix(e){return getMD5Hash(e).slice(0,16)}},"./@datadog/flagging-core/cjs/time.js"(e,t){"use strict";function timeStampNow(){return new Date().getTime()}Object.defineProperty(t,"__esModule",{value:!0}),t.timeStampNow=timeStampNow},"./@datadog/openfeature-node-server/cjs/configuration/evaluation.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluate=void 0;var r=a("./@datadog/flagging-core/cjs/index.js");Object.defineProperty(t,"evaluate",{enumerable:!0,get:function(){return r.evaluateRulesBasedConfiguration}})},"./@datadog/openfeature-node-server/cjs/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/openfeature-node-server/cjs/provider.js"),t)},"./@datadog/openfeature-node-server/cjs/initialization-controller.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InitializationController=void 0;let InitializationController=class InitializationController{constructor(e,t){this.promise=Promise.race([new Promise((e,t)=>{this.resolve=()=>{this.cleanup(),e()},this.reject=e=>{this.cleanup(),t(e)}}),new Promise(()=>{this.timeoutId=setTimeout(()=>{t()},e)})])}async wait(){try{await this.promise}finally{this.cleanup()}}complete(){this.resolve&&this.resolve()}fail(e){this.reject&&this.reject(e)}isInitializing(){return void 0!==this.resolve}cleanup(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.resolve=void 0,this.reject=void 0}};t.InitializationController=InitializationController},"./@datadog/openfeature-node-server/cjs/provider-event-emitter.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NodeProviderEventEmitter=void 0;let r=a("node:events");let NodeProviderEventEmitter=class NodeProviderEventEmitter{constructor(){this.eventEmitter=new r.EventEmitter,this.handlers=new Map}emit(e,t){this.eventEmitter.emit(e,t)}addHandler(e,t){var a,r;let asyncHandler=async e=>{try{await t(e)}catch(e){this.logHandlerError(e)}},n=null!=(a=this.handlers.get(e))?a:new Map,i=null!=(r=n.get(t))?r:[];i.push(asyncHandler),n.set(t,i),this.handlers.set(e,n),this.eventEmitter.on(e,asyncHandler)}removeHandler(e,t){let a=this.handlers.get(e),r=null==a?void 0:a.get(t),n=null==r?void 0:r.pop();n&&this.eventEmitter.removeListener(e,n),(null==r?void 0:r.length)===0&&(null==a||a.delete(t)),(null==a?void 0:a.size)===0&&this.handlers.delete(e)}removeAllHandlers(e){if(e){this.eventEmitter.removeAllListeners(e),this.handlers.delete(e);return}this.eventEmitter.removeAllListeners(),this.handlers.clear()}getHandlers(e){return this.eventEmitter.listeners(e)}setLogger(e){return this.logger=e,this}logHandlerError(e){var t;try{null==(t=this.logger)||t.error("Error running event handler:",e)}catch(e){}}};t.NodeProviderEventEmitter=NodeProviderEventEmitter},"./@datadog/openfeature-node-server/cjs/provider.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DatadogNodeServerProvider=void 0;let r=a("./@datadog/flagging-core/cjs/index.js"),n=a("./@datadog/openfeature-node-server/cjs/configuration/evaluation.js"),i=a("./@datadog/openfeature-node-server/cjs/initialization-controller.js"),o=a("./@datadog/openfeature-node-server/cjs/provider-event-emitter.js");let DatadogNodeServerProvider=class DatadogNodeServerProvider{constructor(e){this.options=e,this.metadata={name:"datadog-node-server"},this.runsOn="server",this.hooks=[],this.events=new o.NodeProviderEventEmitter,this.exposureCache=new r.LRUInMemoryAssignmentCache(5e4)}getConfiguration(){return this.configuration}setConfiguration(e){var t,a,r;let n=null==(t=this.configuration)?void 0:t.createdAt,i=!!this.configuration;if(i&&this.configuration!==e){this.events.emit("PROVIDER_CONFIGURATION_CHANGED"),n!==(null==e?void 0:e.createdAt)&&(null==(a=this.exposureCache)||a.clear()),this.configuration=e;return}this.configuration=e,(null==(r=this.initController)?void 0:r.isInitializing())?this.initController.complete():i||this.events.emit("PROVIDER_READY")}setError(e){var t;(null==(t=this.initController)?void 0:t.isInitializing())?this.initController.fail(e):this.events.emit("PROVIDER_ERROR",{error:e})}async initialize(){var e,t;if(this.configuration)return;let a=null!=(e=this.options.initializationTimeoutMs)?e:3e4;this.initController=new i.InitializationController(a,()=>this.setError(Error(`Initialization timeout after ${a}ms`))),await this.initController.wait(),await (null==(t=this.exposureCache)?void 0:t.init())}async resolveBooleanEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"boolean",e,t,a,r);return this.handleExposure(e,a,i),i}async resolveStringEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"string",e,t,a,r);return this.handleExposure(e,a,i),i}async resolveNumberEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"number",e,t,a,r);return this.handleExposure(e,a,i),i}async resolveObjectEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"object",e,t,a,r);return this.handleExposure(e,a,i),i}handleExposure(e,t,a){var n,i,o;let s=(0,r.timeStampNow)(),l={...a,flagKey:e,flagMetadata:null!=(n=a.flagMetadata)?n:{}},u=(0,r.createExposureEvent)(t,l);!u||(null==(i=this.exposureCache)?void 0:i.has(u))||this.options.exposureChannel.hasSubscribers&&(this.options.exposureChannel.publish({...u,timestamp:s}),null==(o=this.exposureCache)||o.set(u))}};t.DatadogNodeServerProvider=DatadogNodeServerProvider},"./spark-md5/spark-md5.js"(e){e.exports=function(){"use strict";var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function md5cycle(e,t){var a=e[0],r=e[1],n=e[2],i=e[3];a+=(r&n|~r&i)+t[0]-0x28955b88|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[1]-0x173848aa|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[2]+0x242070db|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[3]-0x3e423112|0,a+=((r=(r<<22|r>>>10)+n|0)&n|~r&i)+t[4]-0xa83f051|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[5]+0x4787c62a|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[6]-0x57cfb9ed|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[7]-0x2b96aff|0,a+=((r=(r<<22|r>>>10)+n|0)&n|~r&i)+t[8]+0x698098d8|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[9]-0x74bb0851|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[10]-42063|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[11]-0x76a32842|0,a+=((r=(r<<22|r>>>10)+n|0)&n|~r&i)+t[12]+0x6b901122|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[13]-0x2678e6d|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[14]-0x5986bc72|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[15]+0x49b40821|0,a+=((r=(r<<22|r>>>10)+n|0)&i|n&~i)+t[1]-0x9e1da9e|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[6]-0x3fbf4cc0|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[11]+0x265e5a51|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[0]-0x16493856|0,a+=((r=(r<<20|r>>>12)+n|0)&i|n&~i)+t[5]-0x29d0efa3|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[10]+0x2441453|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[15]-0x275e197f|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[4]-0x182c0438|0,a+=((r=(r<<20|r>>>12)+n|0)&i|n&~i)+t[9]+0x21e1cde6|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[14]-0x3cc8f82a|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[3]-0xb2af279|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[8]+0x455a14ed|0,a+=((r=(r<<20|r>>>12)+n|0)&i|n&~i)+t[13]-0x561c16fb|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[2]-0x3105c08|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[7]+0x676f02d9|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[12]-0x72d5b376|0,a+=((r=(r<<20|r>>>12)+n|0)^n^i)+t[5]-378558|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[8]-0x788e097f|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[11]+0x6d9d6122|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[14]-0x21ac7f4|0,a+=((r=(r<<23|r>>>9)+n|0)^n^i)+t[1]-0x5b4115bc|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[4]+0x4bdecfa9|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[7]-0x944b4a0|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[10]-0x41404390|0,a+=((r=(r<<23|r>>>9)+n|0)^n^i)+t[13]+0x289b7ec6|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[0]-0x155ed806|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[3]-0x2b10cf7b|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[6]+0x4881d05|0,a+=((r=(r<<23|r>>>9)+n|0)^n^i)+t[9]-0x262b2fc7|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[12]-0x1924661b|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[15]+0x1fa27cf8|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[2]-0x3b53a99b|0,r=(r<<23|r>>>9)+n|0,a+=(n^(r|~i))+t[0]-0xbd6ddbc|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[7]+0x432aff97|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[14]-0x546bdc59|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[5]-0x36c5fc7|0,r=(r<<21|r>>>11)+n|0,a+=(n^(r|~i))+t[12]+0x655b59c3|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[3]-0x70f3336e|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[10]-1051523|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[1]-0x7a7ba22f|0,r=(r<<21|r>>>11)+n|0,a+=(n^(r|~i))+t[8]+0x6fa87e4f|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[15]-0x1d31920|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[6]-0x5cfebcec|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[13]+0x4e0811a1|0,r=(r<<21|r>>>11)+n|0,a+=(n^(r|~i))+t[4]-0x8ac817e|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[11]-0x42c50dcb|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[2]+0x2ad7d2bb|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[9]-0x14792c6f|0,r=(r<<21|r>>>11)+n|0,e[0]=a+e[0]|0,e[1]=r+e[1]|0,e[2]=n+e[2]|0,e[3]=i+e[3]|0}function md5blk(e){var t,a=[];for(t=0;t<64;t+=4)a[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return a}function md5blk_array(e){var t,a=[];for(t=0;t<64;t+=4)a[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return a}function md51(e){var t,a,r,n,i,o,s=e.length,l=[0x67452301,-0x10325477,-0x67452302,0x10325476];for(t=64;t<=s;t+=64)md5cycle(l,md5blk(e.substring(t-64,t)));for(a=(e=e.substring(t-64)).length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)r[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(md5cycle(l,r),t=0;t<16;t+=1)r[t]=0;return i=parseInt((n=(n=8*s).toString(16).match(/(.*?)(.{0,8})$/))[2],16),o=parseInt(n[1],16)||0,r[14]=i,r[15]=o,md5cycle(l,r),l}function md51_array(e){var t,a,r,n,i,o,s=e.length,l=[0x67452301,-0x10325477,-0x67452302,0x10325476];for(t=64;t<=s;t+=64)md5cycle(l,md5blk_array(e.subarray(t-64,t)));for(a=(e=t-64<s?e.subarray(t-64):new Uint8Array(0)).length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)r[t>>2]|=e[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(md5cycle(l,r),t=0;t<16;t+=1)r[t]=0;return i=parseInt((n=(n=8*s).toString(16).match(/(.*?)(.{0,8})$/))[2],16),o=parseInt(n[1],16)||0,r[14]=i,r[15]=o,md5cycle(l,r),l}function rhex(t){var a,r="";for(a=0;a<4;a+=1)r+=e[t>>8*a+4&15]+e[t>>8*a&15];return r}function hex(e){var t;for(t=0;t<e.length;t+=1)e[t]=rhex(e[t]);return e.join("")}function toUtf8(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function utf8Str2ArrayBuffer(e,t){var a,r=e.length,n=new ArrayBuffer(r),i=new Uint8Array(n);for(a=0;a<r;a+=1)i[a]=e.charCodeAt(a);return t?i:n}function arrayBuffer2Utf8Str(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function concatenateArrayBuffers(e,t,a){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),a?r:r.buffer}function hexToBinaryString(e){var t,a=[],r=e.length;for(t=0;t<r-1;t+=2)a.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,a)}function SparkMD5(){this.reset()}return hex(md51("hello")),"u">typeof ArrayBuffer&&!ArrayBuffer.prototype.slice&&function(){function clamp(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(e,t){var a,r,n,i,o=this.byteLength,s=clamp(e,o),l=o;return(void 0!==t&&(l=clamp(t,o)),s>l)?new ArrayBuffer(0):(n=new Uint8Array(r=new ArrayBuffer(a=l-s)),i=new Uint8Array(this,s,a),n.set(i),r)}}(),SparkMD5.prototype.append=function(e){return this.appendBinary(toUtf8(e)),this},SparkMD5.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,a=this._buff.length;for(t=64;t<=a;t+=64)md5cycle(this._hash,md5blk(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},SparkMD5.prototype.end=function(e){var t,a,r=this._buff,n=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<n;t+=1)i[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(i,n),a=hex(this._hash),e&&(a=hexToBinaryString(a)),this.reset(),a},SparkMD5.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[0x67452301,-0x10325477,-0x67452302,0x10325476],this},SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},SparkMD5.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},SparkMD5.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},SparkMD5.prototype._finish=function(e,t){var a,r,n,i=t;if(e[i>>2]|=128<<(i%4<<3),i>55)for(md5cycle(this._hash,e),i=0;i<16;i+=1)e[i]=0;r=parseInt((a=(a=8*this._length).toString(16).match(/(.*?)(.{0,8})$/))[2],16),n=parseInt(a[1],16)||0,e[14]=r,e[15]=n,md5cycle(this._hash,e)},SparkMD5.hash=function(e,t){return SparkMD5.hashBinary(toUtf8(e),t)},SparkMD5.hashBinary=function(e,t){var a=hex(md51(e));return t?hexToBinaryString(a):a},SparkMD5.ArrayBuffer=function(){this.reset()},SparkMD5.ArrayBuffer.prototype.append=function(e){var t,a=concatenateArrayBuffers(this._buff.buffer,e,!0),r=a.length;for(this._length+=e.byteLength,t=64;t<=r;t+=64)md5cycle(this._hash,md5blk_array(a.subarray(t-64,t)));return this._buff=new Uint8Array(t-64<r?a.buffer.slice(t-64):0),this},SparkMD5.ArrayBuffer.prototype.end=function(e){var t,a,r=this._buff,n=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<n;t+=1)i[t>>2]|=r[t]<<(t%4<<3);return this._finish(i,n),a=hex(this._hash),e&&(a=hexToBinaryString(a)),this.reset(),a},SparkMD5.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[0x67452301,-0x10325477,-0x67452302,0x10325476],this},SparkMD5.ArrayBuffer.prototype.getState=function(){var e=SparkMD5.prototype.getState.call(this);return e.buff=arrayBuffer2Utf8Str(e.buff),e},SparkMD5.ArrayBuffer.prototype.setState=function(e){return e.buff=utf8Str2ArrayBuffer(e.buff,!0),SparkMD5.prototype.setState.call(this,e)},SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy,SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish,SparkMD5.ArrayBuffer.hash=function(e,t){var a=hex(md51_array(new Uint8Array(e)));return t?hexToBinaryString(a):a},SparkMD5}()},"node:events"(e){"use strict";e.exports=require("node:events")}},t={};function __webpack_require__(a){var r=t[a];if(void 0!==r)return r.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,__webpack_require__),n.exports}var a=__webpack_require__("./@datadog/openfeature-node-server/cjs/index.js");module.exports=a})();
|