dd-trace 5.67.0 → 5.69.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/LICENSE-3rdparty.csv +6 -4
- package/README.md +0 -2
- package/ci/init.js +52 -54
- package/ext/exporters.d.ts +2 -1
- package/ext/exporters.js +2 -1
- package/index.d.ts +240 -3
- package/initialize.mjs +1 -1
- package/package.json +17 -11
- package/packages/datadog-core/src/storage.js +14 -13
- package/packages/datadog-esbuild/index.js +118 -26
- package/packages/datadog-instrumentations/src/aws-sdk.js +42 -4
- package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
- package/packages/datadog-instrumentations/src/azure-service-bus.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +2 -2
- package/packages/datadog-instrumentations/src/connect.js +6 -2
- package/packages/datadog-instrumentations/src/cucumber.js +31 -6
- package/packages/datadog-instrumentations/src/express.js +5 -6
- package/packages/datadog-instrumentations/src/fastify.js +3 -3
- package/packages/datadog-instrumentations/src/helpers/hook.js +28 -15
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +15 -5
- package/packages/datadog-instrumentations/src/helpers/register.js +10 -3
- package/packages/datadog-instrumentations/src/http2/client.js +1 -0
- package/packages/datadog-instrumentations/src/http2/server.js +0 -1
- package/packages/datadog-instrumentations/src/ioredis.js +12 -1
- package/packages/datadog-instrumentations/src/jest.js +48 -36
- package/packages/datadog-instrumentations/src/limitd-client.js +2 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +15 -7
- package/packages/datadog-instrumentations/src/mocha/utils.js +3 -0
- package/packages/datadog-instrumentations/src/mongoose.js +2 -1
- package/packages/datadog-instrumentations/src/oracledb.js +19 -13
- package/packages/datadog-instrumentations/src/pg.js +9 -5
- package/packages/datadog-instrumentations/src/pino.js +18 -6
- package/packages/datadog-instrumentations/src/playwright.js +15 -1
- package/packages/datadog-instrumentations/src/sequelize.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +155 -62
- package/packages/datadog-plugin-ai/src/tracing.js +3 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +23 -8
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +101 -2
- package/packages/datadog-plugin-aws-sdk/src/util.js +1 -1
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +6 -0
- package/packages/datadog-plugin-cucumber/src/index.js +4 -56
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +6 -3
- package/packages/datadog-plugin-cypress/src/support.js +4 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -2
- package/packages/datadog-plugin-jest/src/index.js +0 -21
- package/packages/datadog-plugin-mocha/src/index.js +3 -57
- package/packages/datadog-plugin-mongodb-core/src/index.js +38 -12
- package/packages/datadog-plugin-playwright/src/index.js +11 -5
- package/packages/datadog-plugin-vitest/src/index.js +5 -1
- package/packages/datadog-plugin-ws/src/close.js +1 -1
- package/packages/datadog-plugin-ws/src/producer.js +6 -1
- package/packages/datadog-plugin-ws/src/receiver.js +6 -1
- package/packages/dd-trace/src/aiguard/client.js +25 -0
- package/packages/dd-trace/src/aiguard/noop.js +9 -0
- package/packages/dd-trace/src/aiguard/sdk.js +173 -0
- package/packages/dd-trace/src/aiguard/tags.js +11 -0
- package/packages/dd-trace/src/appsec/iast/path-line.js +21 -4
- package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +6 -3
- package/packages/dd-trace/src/appsec/stack_trace.js +20 -1
- package/packages/dd-trace/src/appsec/telemetry/waf.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +11 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +10 -1
- package/packages/dd-trace/src/config-helper.js +8 -1
- package/packages/dd-trace/src/config.js +92 -304
- package/packages/dd-trace/src/config_defaults.js +191 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +2 -1
- package/packages/dd-trace/src/datastreams/fnv.js +2 -2
- package/packages/dd-trace/src/datastreams/index.js +23 -1
- package/packages/dd-trace/src/datastreams/writer.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -1
- package/packages/dd-trace/src/dogstatsd.js +4 -3
- package/packages/dd-trace/src/encode/0.4.js +1 -5
- package/packages/dd-trace/src/exporter.js +1 -0
- package/packages/dd-trace/src/exporters/agent/index.js +3 -2
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -1
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +3 -2
- package/packages/dd-trace/src/exporters/common/request.js +2 -1
- package/packages/dd-trace/src/exporters/span-stats/index.js +3 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +15 -4
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +20 -7
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +40 -13
- package/packages/dd-trace/src/llmobs/plugins/openai.js +7 -1
- package/packages/dd-trace/src/llmobs/tagger.js +8 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +2 -1
- package/packages/dd-trace/src/log/index.js +27 -16
- package/packages/dd-trace/src/log/log.js +29 -5
- package/packages/dd-trace/src/log/writer.js +5 -5
- package/packages/dd-trace/src/noop/proxy.js +4 -0
- package/packages/dd-trace/src/noop/span.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span.js +14 -3
- package/packages/dd-trace/src/opentracing/span.js +19 -5
- package/packages/dd-trace/src/payload-tagging/config/index.js +16 -0
- package/packages/dd-trace/src/payload-tagging/index.js +26 -15
- package/packages/dd-trace/src/payload-tagging/tagging.js +17 -8
- package/packages/dd-trace/src/pkg.js +3 -1
- package/packages/dd-trace/src/plugin_manager.js +20 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +97 -3
- package/packages/dd-trace/src/plugins/composite.js +3 -0
- package/packages/dd-trace/src/plugins/index.js +2 -0
- package/packages/dd-trace/src/plugins/plugin.js +67 -0
- package/packages/dd-trace/src/plugins/util/git-cache.js +129 -0
- package/packages/dd-trace/src/plugins/util/git.js +41 -27
- package/packages/dd-trace/src/plugins/util/test.js +56 -27
- package/packages/dd-trace/src/plugins/util/web.js +1 -1
- package/packages/dd-trace/src/priority_sampler.js +70 -46
- package/packages/dd-trace/src/profiler.js +4 -1
- package/packages/dd-trace/src/profiling/config.js +73 -42
- package/packages/dd-trace/src/profiling/profiler.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +3 -8
- package/packages/dd-trace/src/profiling/profilers/space.js +1 -0
- package/packages/dd-trace/src/profiling/profilers/wall.js +196 -117
- package/packages/dd-trace/src/proxy.js +15 -0
- package/packages/dd-trace/src/rate_limiter.js +26 -1
- package/packages/dd-trace/src/remote_config/capabilities.js +5 -0
- package/packages/dd-trace/src/remote_config/manager.js +3 -2
- package/packages/dd-trace/src/sampling_rule.js +124 -2
- package/packages/dd-trace/src/span_sampler.js +19 -0
- package/packages/dd-trace/src/standalone/product.js +9 -0
- package/packages/dd-trace/src/standalone/tracesource.js +16 -1
- package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +13 -0
- package/packages/dd-trace/src/startup-log.js +21 -2
- package/packages/dd-trace/src/supported-configurations.json +9 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +2 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/register.js +1 -1
- package/version.js +4 -2
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const pkg = require('./pkg')
|
|
4
|
+
const { GRPC_CLIENT_ERROR_STATUSES, GRPC_SERVER_ERROR_STATUSES } = require('./constants')
|
|
5
|
+
const { getEnvironmentVariables } = require('./config-helper')
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
8
|
+
const qsRegex = String.raw`(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:(?:\s|%20)*(?:=|%3D)[^&]+|(?:"|%22)(?:\s|%20)*(?::|%3A)(?:\s|%20)*(?:"|%22)(?:%2[^2]|%[^2]|[^"%])+(?:"|%22))|bearer(?:\s|%20)+[a-z0-9\._\-]+|token(?::|%3A)[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L](?:[\w=-]|%3D)+\.ey[I-L](?:[\w=-]|%3D)+(?:\.(?:[\w.+\/=-]|%3D|%2F|%2B)+)?|[\-]{5}BEGIN(?:[a-z\s]|%20)+PRIVATE(?:\s|%20)KEY[\-]{5}[^\-]+[\-]{5}END(?:[a-z\s]|%20)+PRIVATE(?:\s|%20)KEY|ssh-rsa(?:\s|%20)*(?:[a-z0-9\/\.+]|%2F|%5C|%2B){100,}`
|
|
9
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
10
|
+
const defaultWafObfuscatorKeyRegex = String.raw`(?i)pass|pw(?:or)?d|secret|(?:api|private|public|access)[_-]?key|token|consumer[_-]?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization|jsessionid|phpsessid|asp\.net[_-]sessionid|sid|jwt`
|
|
11
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
12
|
+
const defaultWafObfuscatorValueRegex = String.raw`(?i)(?:p(?:ass)?w(?:or)?d|pass(?:[_-]?phrase)?|secret(?:[_-]?key)?|(?:(?:api|private|public|access)[_-]?)key(?:[_-]?id)?|(?:(?:auth|access|id|refresh)[_-]?)?token|consumer[_-]?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?|jsessionid|phpsessid|asp\.net(?:[_-]|-)sessionid|sid|jwt)(?:\s*=([^;&]+)|"\s*:\s*("[^"]+"|\d+))|bearer\s+([a-z0-9\._\-]+)|token\s*:\s*([a-z0-9]{13})|gh[opsu]_([0-9a-zA-Z]{36})|ey[I-L][\w=-]+\.(ey[I-L][\w=-]+(?:\.[\w.+\/=-]+)?)|[\-]{5}BEGIN[a-z\s]+PRIVATE\sKEY[\-]{5}([^\-]+)[\-]{5}END[a-z\s]+PRIVATE\sKEY|ssh-rsa\s*([a-z0-9\/\.+]{100,})`
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
AWS_LAMBDA_FUNCTION_NAME,
|
|
16
|
+
FUNCTION_NAME,
|
|
17
|
+
K_SERVICE,
|
|
18
|
+
WEBSITE_SITE_NAME
|
|
19
|
+
} = getEnvironmentVariables()
|
|
20
|
+
|
|
21
|
+
const service = AWS_LAMBDA_FUNCTION_NAME ||
|
|
22
|
+
FUNCTION_NAME || // Google Cloud Function Name set by deprecated runtimes
|
|
23
|
+
K_SERVICE || // Google Cloud Function Name set by newer runtimes
|
|
24
|
+
WEBSITE_SITE_NAME || // set by Azure Functions
|
|
25
|
+
pkg.name ||
|
|
26
|
+
'node'
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
apmTracingEnabled: true,
|
|
30
|
+
'appsec.apiSecurity.enabled': true,
|
|
31
|
+
'appsec.apiSecurity.sampleDelay': 30,
|
|
32
|
+
'appsec.apiSecurity.endpointCollectionEnabled': true,
|
|
33
|
+
'appsec.apiSecurity.endpointCollectionMessageLimit': 300,
|
|
34
|
+
'appsec.blockedTemplateGraphql': undefined,
|
|
35
|
+
'appsec.blockedTemplateHtml': undefined,
|
|
36
|
+
'appsec.blockedTemplateJson': undefined,
|
|
37
|
+
'appsec.enabled': undefined,
|
|
38
|
+
'appsec.eventTracking.mode': 'identification',
|
|
39
|
+
'appsec.extendedHeadersCollection.enabled': false,
|
|
40
|
+
'appsec.extendedHeadersCollection.redaction': true,
|
|
41
|
+
'appsec.extendedHeadersCollection.maxHeaders': 50,
|
|
42
|
+
'appsec.obfuscatorKeyRegex': defaultWafObfuscatorKeyRegex,
|
|
43
|
+
'appsec.obfuscatorValueRegex': defaultWafObfuscatorValueRegex,
|
|
44
|
+
'appsec.rasp.enabled': true,
|
|
45
|
+
'appsec.rasp.bodyCollection': false,
|
|
46
|
+
'appsec.rateLimit': 100,
|
|
47
|
+
'appsec.rules': undefined,
|
|
48
|
+
'appsec.sca.enabled': null,
|
|
49
|
+
'appsec.stackTrace.enabled': true,
|
|
50
|
+
'appsec.stackTrace.maxDepth': 32,
|
|
51
|
+
'appsec.stackTrace.maxStackTraces': 2,
|
|
52
|
+
'appsec.wafTimeout': 5e3, // µs
|
|
53
|
+
baggageMaxBytes: 8192,
|
|
54
|
+
baggageMaxItems: 64,
|
|
55
|
+
baggageTagKeys: 'user.id,session.id,account.id',
|
|
56
|
+
clientIpEnabled: false,
|
|
57
|
+
clientIpHeader: null,
|
|
58
|
+
'crashtracking.enabled': true,
|
|
59
|
+
'codeOriginForSpans.enabled': true,
|
|
60
|
+
'codeOriginForSpans.experimental.exit_spans.enabled': false,
|
|
61
|
+
dbmPropagationMode: 'disabled',
|
|
62
|
+
'dogstatsd.hostname': '127.0.0.1',
|
|
63
|
+
'dogstatsd.port': '8125',
|
|
64
|
+
dsmEnabled: false,
|
|
65
|
+
'dynamicInstrumentation.enabled': false,
|
|
66
|
+
'dynamicInstrumentation.probeFile': undefined,
|
|
67
|
+
'dynamicInstrumentation.redactedIdentifiers': [],
|
|
68
|
+
'dynamicInstrumentation.redactionExcludedIdentifiers': [],
|
|
69
|
+
'dynamicInstrumentation.uploadIntervalSeconds': 1,
|
|
70
|
+
env: undefined,
|
|
71
|
+
'experimental.aiguard.enabled': false,
|
|
72
|
+
'experimental.aiguard.endpoint': undefined,
|
|
73
|
+
'experimental.aiguard.maxMessagesLength': 16,
|
|
74
|
+
'experimental.aiguard.maxContentSize': 512 * 1024,
|
|
75
|
+
'experimental.aiguard.timeout': 10_000, // ms
|
|
76
|
+
'experimental.enableGetRumData': false,
|
|
77
|
+
'experimental.exporter': undefined,
|
|
78
|
+
flushInterval: 2000,
|
|
79
|
+
flushMinSpans: 1000,
|
|
80
|
+
gitMetadataEnabled: true,
|
|
81
|
+
graphqlErrorExtensions: [],
|
|
82
|
+
'grpc.client.error.statuses': GRPC_CLIENT_ERROR_STATUSES,
|
|
83
|
+
'grpc.server.error.statuses': GRPC_SERVER_ERROR_STATUSES,
|
|
84
|
+
headerTags: [],
|
|
85
|
+
'heapSnapshot.count': 0,
|
|
86
|
+
'heapSnapshot.destination': '',
|
|
87
|
+
'heapSnapshot.interval': 3600,
|
|
88
|
+
hostname: '127.0.0.1',
|
|
89
|
+
'iast.dbRowsToTaint': 1,
|
|
90
|
+
'iast.deduplicationEnabled': true,
|
|
91
|
+
'iast.enabled': false,
|
|
92
|
+
'iast.maxConcurrentRequests': 2,
|
|
93
|
+
'iast.maxContextOperations': 2,
|
|
94
|
+
'iast.redactionEnabled': true,
|
|
95
|
+
'iast.redactionNamePattern': null,
|
|
96
|
+
'iast.redactionValuePattern': null,
|
|
97
|
+
'iast.requestSampling': 30,
|
|
98
|
+
'iast.securityControlsConfiguration': null,
|
|
99
|
+
'iast.telemetryVerbosity': 'INFORMATION',
|
|
100
|
+
'iast.stackTrace.enabled': true,
|
|
101
|
+
injectionEnabled: [],
|
|
102
|
+
instrumentationSource: 'manual',
|
|
103
|
+
injectForce: null,
|
|
104
|
+
isAzureFunction: false,
|
|
105
|
+
isCiVisibility: false,
|
|
106
|
+
isEarlyFlakeDetectionEnabled: false,
|
|
107
|
+
isFlakyTestRetriesEnabled: false,
|
|
108
|
+
flakyTestRetriesCount: 5,
|
|
109
|
+
isGCPFunction: false,
|
|
110
|
+
isGitUploadEnabled: false,
|
|
111
|
+
isIntelligentTestRunnerEnabled: false,
|
|
112
|
+
isManualApiEnabled: false,
|
|
113
|
+
'langchain.spanCharLimit': 128,
|
|
114
|
+
'langchain.spanPromptCompletionSampleRate': 1,
|
|
115
|
+
'llmobs.agentlessEnabled': undefined,
|
|
116
|
+
'llmobs.enabled': false,
|
|
117
|
+
'llmobs.mlApp': undefined,
|
|
118
|
+
ciVisibilityTestSessionName: '',
|
|
119
|
+
ciVisAgentlessLogSubmissionEnabled: false,
|
|
120
|
+
legacyBaggageEnabled: true,
|
|
121
|
+
isTestDynamicInstrumentationEnabled: false,
|
|
122
|
+
isServiceUserProvided: false,
|
|
123
|
+
testManagementAttemptToFixRetries: 20,
|
|
124
|
+
isTestManagementEnabled: false,
|
|
125
|
+
isImpactedTestsEnabled: false,
|
|
126
|
+
logInjection: true,
|
|
127
|
+
lookup: undefined,
|
|
128
|
+
inferredProxyServicesEnabled: false,
|
|
129
|
+
memcachedCommandEnabled: false,
|
|
130
|
+
middlewareTracingEnabled: true,
|
|
131
|
+
openAiLogsEnabled: false,
|
|
132
|
+
'openai.spanCharLimit': 128,
|
|
133
|
+
peerServiceMapping: {},
|
|
134
|
+
plugins: true,
|
|
135
|
+
port: '8126',
|
|
136
|
+
'profiling.enabled': undefined,
|
|
137
|
+
'profiling.exporters': 'agent',
|
|
138
|
+
'profiling.sourceMap': true,
|
|
139
|
+
'profiling.longLivedThreshold': undefined,
|
|
140
|
+
protocolVersion: '0.4',
|
|
141
|
+
queryStringObfuscation: qsRegex,
|
|
142
|
+
'remoteConfig.enabled': true,
|
|
143
|
+
'remoteConfig.pollInterval': 5, // seconds
|
|
144
|
+
reportHostname: false,
|
|
145
|
+
'runtimeMetrics.enabled': false,
|
|
146
|
+
'runtimeMetrics.eventLoop': true,
|
|
147
|
+
'runtimeMetrics.gc': true,
|
|
148
|
+
runtimeMetricsRuntimeId: false,
|
|
149
|
+
sampleRate: undefined,
|
|
150
|
+
'sampler.rateLimit': 100,
|
|
151
|
+
'sampler.rules': [],
|
|
152
|
+
'sampler.spanSamplingRules': [],
|
|
153
|
+
scope: undefined,
|
|
154
|
+
service,
|
|
155
|
+
serviceMapping: {},
|
|
156
|
+
site: 'datadoghq.com',
|
|
157
|
+
spanAttributeSchema: 'v0',
|
|
158
|
+
spanComputePeerService: false,
|
|
159
|
+
spanLeakDebug: 0,
|
|
160
|
+
spanRemoveIntegrationFromService: false,
|
|
161
|
+
startupLogs: false,
|
|
162
|
+
'stats.enabled': false,
|
|
163
|
+
tags: {},
|
|
164
|
+
tagsHeaderMaxLength: 512,
|
|
165
|
+
'telemetry.debug': false,
|
|
166
|
+
'telemetry.dependencyCollection': true,
|
|
167
|
+
'telemetry.enabled': true,
|
|
168
|
+
'telemetry.heartbeatInterval': 60_000,
|
|
169
|
+
'telemetry.logCollection': true,
|
|
170
|
+
'telemetry.metrics': true,
|
|
171
|
+
traceEnabled: true,
|
|
172
|
+
traceId128BitGenerationEnabled: true,
|
|
173
|
+
traceId128BitLoggingEnabled: true,
|
|
174
|
+
tracePropagationExtractFirst: false,
|
|
175
|
+
tracePropagationBehaviorExtract: 'continue',
|
|
176
|
+
'tracePropagationStyle.inject': ['datadog', 'tracecontext', 'baggage'],
|
|
177
|
+
'tracePropagationStyle.extract': ['datadog', 'tracecontext', 'baggage'],
|
|
178
|
+
'tracePropagationStyle.otelPropagators': false,
|
|
179
|
+
traceWebsocketMessagesEnabled: false,
|
|
180
|
+
traceWebsocketMessagesInheritSampling: true,
|
|
181
|
+
traceWebsocketMessagesSeparateTraces: true,
|
|
182
|
+
tracing: true,
|
|
183
|
+
url: undefined,
|
|
184
|
+
version: pkg.version,
|
|
185
|
+
instrumentation_config_id: undefined,
|
|
186
|
+
'vertexai.spanCharLimit': 128,
|
|
187
|
+
'vertexai.spanPromptCompletionSampleRate': 1,
|
|
188
|
+
'trace.aws.addSpanPointers': true,
|
|
189
|
+
'trace.dynamoDb.tablePrimaryKeys': undefined,
|
|
190
|
+
'trace.nativeSpanEvents': false
|
|
191
|
+
}
|
|
@@ -5,6 +5,7 @@ const libdatadog = require('@datadog/libdatadog')
|
|
|
5
5
|
const binding = libdatadog.load('crashtracker')
|
|
6
6
|
|
|
7
7
|
const log = require('../log')
|
|
8
|
+
const defaults = require('../config_defaults')
|
|
8
9
|
const { URL } = require('url')
|
|
9
10
|
const pkg = require('../../../../package.json')
|
|
10
11
|
|
|
@@ -49,7 +50,7 @@ class Crashtracker {
|
|
|
49
50
|
|
|
50
51
|
// TODO: Send only configured values when defaults are fixed.
|
|
51
52
|
#getConfig (config) {
|
|
52
|
-
const { hostname =
|
|
53
|
+
const { hostname = defaults.hostname, port = defaults.port } = config
|
|
53
54
|
const url = config.url || new URL(`http://${hostname}:${port}`)
|
|
54
55
|
|
|
55
56
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const FNV_64_PRIME =
|
|
4
|
-
const FNV1_64_INIT =
|
|
3
|
+
const FNV_64_PRIME = 0x1_00_00_00_01_B3n
|
|
4
|
+
const FNV1_64_INIT = 0xCB_F2_9C_E4_84_22_23_25n
|
|
5
5
|
|
|
6
6
|
function fnv (data, hvalInit, fnvPrime, fnvSize) {
|
|
7
7
|
let hval = hvalInit
|
|
@@ -11,7 +11,14 @@ const {
|
|
|
11
11
|
// plugins instead of having dedicated DSM plugins that are themselves
|
|
12
12
|
// lazy loaded.
|
|
13
13
|
//
|
|
14
|
-
// TODO: Remove this when DSM has been moved to
|
|
14
|
+
// TODO: Remove this when DSM has been moved to dedicated plugins.
|
|
15
|
+
/**
|
|
16
|
+
* @template T extends new (...args: any[]) => any
|
|
17
|
+
* @param {() => T} classGetter
|
|
18
|
+
* @param {string[]} methods
|
|
19
|
+
* @param {string[]} staticMethods
|
|
20
|
+
* @returns {T}
|
|
21
|
+
*/
|
|
15
22
|
function lazyClass (classGetter, methods = [], staticMethods = []) {
|
|
16
23
|
let constructorArgs
|
|
17
24
|
let ActiveClass
|
|
@@ -50,22 +57,34 @@ function lazyClass (classGetter, methods = [], staticMethods = []) {
|
|
|
50
57
|
return LazyClass
|
|
51
58
|
}
|
|
52
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @type {typeof import('./pathway').DsmPathwayCodec}
|
|
62
|
+
*/
|
|
53
63
|
const DsmPathwayCodec = lazyClass(() => require('./pathway').DsmPathwayCodec, [], [
|
|
54
64
|
'encode',
|
|
55
65
|
'decode'
|
|
56
66
|
])
|
|
57
67
|
|
|
68
|
+
/**
|
|
69
|
+
* @type {typeof import('./checkpointer').DataStreamsCheckpointer}
|
|
70
|
+
*/
|
|
58
71
|
const DataStreamsCheckpointer = lazyClass(() => require('./checkpointer').DataStreamsCheckpointer, [
|
|
59
72
|
'setProduceCheckpoint',
|
|
60
73
|
'setConsumeCheckpoint'
|
|
61
74
|
])
|
|
62
75
|
|
|
76
|
+
/**
|
|
77
|
+
* @type {typeof import('./manager').DataStreamsManager}
|
|
78
|
+
*/
|
|
63
79
|
const DataStreamsManager = lazyClass(() => require('./manager').DataStreamsManager, [
|
|
64
80
|
'setCheckpoint',
|
|
65
81
|
'decodeDataStreamsContext'
|
|
66
82
|
])
|
|
67
83
|
|
|
68
84
|
// TODO: Are all those methods actually public?
|
|
85
|
+
/**
|
|
86
|
+
* @type {typeof import('./processor').DataStreamsProcessor}
|
|
87
|
+
*/
|
|
69
88
|
const DataStreamsProcessor = lazyClass(() => require('./processor').DataStreamsProcessor, [
|
|
70
89
|
'onInterval',
|
|
71
90
|
'bucketFromTimestamp',
|
|
@@ -79,6 +98,9 @@ const DataStreamsProcessor = lazyClass(() => require('./processor').DataStreamsP
|
|
|
79
98
|
'getSchema'
|
|
80
99
|
])
|
|
81
100
|
|
|
101
|
+
/**
|
|
102
|
+
* @type {typeof import('./schemas/schema_builder').SchemaBuilder}
|
|
103
|
+
*/
|
|
82
104
|
const SchemaBuilder = lazyClass(() => require('./schemas/schema_builder').SchemaBuilder, [
|
|
83
105
|
'build',
|
|
84
106
|
'addProperty',
|
|
@@ -5,6 +5,7 @@ const log = require('../log')
|
|
|
5
5
|
const request = require('../exporters/common/request')
|
|
6
6
|
const { URL, format } = require('url')
|
|
7
7
|
const { MsgpackEncoder } = require('../msgpack')
|
|
8
|
+
const defaults = require('../config_defaults')
|
|
8
9
|
const zlib = require('zlib')
|
|
9
10
|
|
|
10
11
|
const msgpack = new MsgpackEncoder()
|
|
@@ -31,10 +32,10 @@ function makeRequest (data, url, cb) {
|
|
|
31
32
|
|
|
32
33
|
class DataStreamsWriter {
|
|
33
34
|
constructor (config) {
|
|
34
|
-
const { hostname =
|
|
35
|
+
const { hostname = defaults.hostname, port = defaults.port, url } = config
|
|
35
36
|
this._url = url || new URL(format({
|
|
36
37
|
protocol: 'http:',
|
|
37
|
-
hostname
|
|
38
|
+
hostname,
|
|
38
39
|
port
|
|
39
40
|
}))
|
|
40
41
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { workerData: { config: parentConfig, parentThreadId, configPort } } = require('node:worker_threads')
|
|
4
4
|
const { format } = require('node:url')
|
|
5
5
|
const log = require('./log')
|
|
6
|
+
const defaults = require('../../config_defaults')
|
|
6
7
|
|
|
7
8
|
const config = module.exports = {
|
|
8
9
|
...parentConfig,
|
|
@@ -20,7 +21,7 @@ configPort.on('messageerror', (err) =>
|
|
|
20
21
|
function updateUrl (updates) {
|
|
21
22
|
config.url = updates.url || format({
|
|
22
23
|
protocol: 'http:',
|
|
23
|
-
hostname: updates.hostname ||
|
|
24
|
+
hostname: updates.hostname || defaults.hostname,
|
|
24
25
|
port: updates.port
|
|
25
26
|
})
|
|
26
27
|
}
|
|
@@ -7,6 +7,7 @@ const isIP = require('net').isIP
|
|
|
7
7
|
const log = require('./log')
|
|
8
8
|
const { URL, format } = require('url')
|
|
9
9
|
const Histogram = require('./histogram')
|
|
10
|
+
const defaults = require('./config_defaults')
|
|
10
11
|
|
|
11
12
|
const MAX_BUFFER_SIZE = 1024 // limit from the agent
|
|
12
13
|
|
|
@@ -28,9 +29,9 @@ class DogStatsDClient {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
this._host = options.host || '
|
|
32
|
+
this._host = options.host || defaults['dogstatsd.hostname']
|
|
32
33
|
this._family = isIP(this._host)
|
|
33
|
-
this._port = options.port ||
|
|
34
|
+
this._port = options.port || defaults['dogstatsd.port']
|
|
34
35
|
this._prefix = options.prefix || ''
|
|
35
36
|
this._tags = options.tags || []
|
|
36
37
|
this._queue = []
|
|
@@ -182,7 +183,7 @@ class DogStatsDClient {
|
|
|
182
183
|
} else if (config.port) {
|
|
183
184
|
clientConfig.metricsProxyUrl = new URL(format({
|
|
184
185
|
protocol: 'http:',
|
|
185
|
-
hostname: config.hostname ||
|
|
186
|
+
hostname: config.hostname || defaults.hostname,
|
|
186
187
|
port: config.port
|
|
187
188
|
}))
|
|
188
189
|
}
|
|
@@ -4,7 +4,6 @@ const { truncateSpan, normalizeSpan } = require('./tags-processors')
|
|
|
4
4
|
const { Chunk, MsgpackEncoder } = require('../msgpack')
|
|
5
5
|
const log = require('../log')
|
|
6
6
|
const { isTrue } = require('../util')
|
|
7
|
-
const coalesce = require('koalas')
|
|
8
7
|
const { memoize } = require('../log/utils')
|
|
9
8
|
const { getEnvironmentVariable } = require('../config-helper')
|
|
10
9
|
|
|
@@ -32,10 +31,7 @@ class AgentEncoder {
|
|
|
32
31
|
this._stringBytes = new Chunk()
|
|
33
32
|
this._writer = writer
|
|
34
33
|
this._reset()
|
|
35
|
-
this._debugEncoding = isTrue(
|
|
36
|
-
getEnvironmentVariable('DD_TRACE_ENCODING_DEBUG'),
|
|
37
|
-
false
|
|
38
|
-
))
|
|
34
|
+
this._debugEncoding = isTrue(getEnvironmentVariable('DD_TRACE_ENCODING_DEBUG'))
|
|
39
35
|
this._config = this._writer?._config
|
|
40
36
|
}
|
|
41
37
|
|
|
@@ -19,6 +19,7 @@ module.exports = function getExporter (name) {
|
|
|
19
19
|
case exporters.CUCUMBER_WORKER:
|
|
20
20
|
case exporters.MOCHA_WORKER:
|
|
21
21
|
case exporters.PLAYWRIGHT_WORKER:
|
|
22
|
+
case exporters.VITEST_WORKER:
|
|
22
23
|
return require('./ci-visibility/exporters/test-worker')
|
|
23
24
|
default: {
|
|
24
25
|
const inAWSLambda = getEnvironmentVariable('AWS_LAMBDA_FUNCTION_NAME') !== undefined
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
const { URL, format } = require('url')
|
|
4
4
|
const log = require('../../log')
|
|
5
5
|
const Writer = require('./writer')
|
|
6
|
+
const defaults = require('../../config_defaults')
|
|
6
7
|
|
|
7
8
|
class AgentExporter {
|
|
8
9
|
#timer
|
|
9
10
|
|
|
10
11
|
constructor (config, prioritySampler) {
|
|
11
12
|
this._config = config
|
|
12
|
-
const { url, hostname, port, lookup, protocolVersion, stats = {}, apmTracingEnabled } = config
|
|
13
|
+
const { url, hostname = defaults.hostname, port, lookup, protocolVersion, stats = {}, apmTracingEnabled } = config
|
|
13
14
|
this._url = url || new URL(format({
|
|
14
15
|
protocol: 'http:',
|
|
15
|
-
hostname
|
|
16
|
+
hostname,
|
|
16
17
|
port
|
|
17
18
|
}))
|
|
18
19
|
|
|
@@ -42,7 +42,7 @@ class Writer extends BaseWriter {
|
|
|
42
42
|
startupLog({ agentError: err })
|
|
43
43
|
|
|
44
44
|
if (err) {
|
|
45
|
-
log.
|
|
45
|
+
log.errorWithoutTelemetry('Error sending payload to the agent (status code: %s)', err.status, err)
|
|
46
46
|
done()
|
|
47
47
|
return
|
|
48
48
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { URL, format } = require('url')
|
|
4
4
|
|
|
5
5
|
const request = require('./request')
|
|
6
|
+
const defaults = require('../../config_defaults')
|
|
6
7
|
const { incrementCountMetric, TELEMETRY_EVENTS_ENQUEUED_FOR_SERIALIZATION } = require('../../ci-visibility/telemetry')
|
|
7
8
|
|
|
8
9
|
function fetchAgentInfo (url, callback) {
|
|
@@ -29,10 +30,10 @@ function fetchAgentInfo (url, callback) {
|
|
|
29
30
|
class AgentInfoExporter {
|
|
30
31
|
constructor (tracerConfig) {
|
|
31
32
|
this._config = tracerConfig
|
|
32
|
-
const { url, hostname, port } = this._config
|
|
33
|
+
const { url, hostname = defaults.hostname, port } = this._config
|
|
33
34
|
this._url = url || new URL(format({
|
|
34
35
|
protocol: 'http:',
|
|
35
|
-
hostname
|
|
36
|
+
hostname,
|
|
36
37
|
port
|
|
37
38
|
}))
|
|
38
39
|
this._traceBuffer = []
|
|
@@ -106,11 +106,12 @@ function request (data, options, callback) {
|
|
|
106
106
|
} catch {
|
|
107
107
|
// ignore error
|
|
108
108
|
}
|
|
109
|
+
|
|
109
110
|
const responseData = buffer.toString()
|
|
110
111
|
if (responseData) {
|
|
111
112
|
errorMessage += ` Response from the endpoint: "${responseData}"`
|
|
112
113
|
}
|
|
113
|
-
const error = new
|
|
114
|
+
const error = new log.NoTransmitError(errorMessage)
|
|
114
115
|
error.status = res.statusCode
|
|
115
116
|
|
|
116
117
|
callback(error, null, res.statusCode)
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
const { URL, format } = require('url')
|
|
4
4
|
|
|
5
5
|
const { Writer } = require('./writer')
|
|
6
|
+
const defaults = require('../../config_defaults')
|
|
6
7
|
|
|
7
8
|
class SpanStatsExporter {
|
|
8
9
|
constructor (config) {
|
|
9
|
-
const { hostname =
|
|
10
|
+
const { hostname = defaults.hostname, port = defaults.port, tags, url } = config
|
|
10
11
|
this._url = url || new URL(format({
|
|
11
12
|
protocol: 'http:',
|
|
12
|
-
hostname
|
|
13
|
+
hostname,
|
|
13
14
|
port
|
|
14
15
|
}))
|
|
15
16
|
this._writer = new Writer({ url: this._url, tags })
|
|
@@ -32,6 +32,8 @@ module.exports = {
|
|
|
32
32
|
INPUT_TOKENS_METRIC_KEY: 'input_tokens',
|
|
33
33
|
OUTPUT_TOKENS_METRIC_KEY: 'output_tokens',
|
|
34
34
|
TOTAL_TOKENS_METRIC_KEY: 'total_tokens',
|
|
35
|
+
CACHE_READ_INPUT_TOKENS_METRIC_KEY: 'cache_read_input_tokens',
|
|
36
|
+
CACHE_WRITE_INPUT_TOKENS_METRIC_KEY: 'cache_write_input_tokens',
|
|
35
37
|
|
|
36
38
|
DROPPED_IO_COLLECTION_ERROR: 'dropped_io'
|
|
37
39
|
}
|
|
@@ -17,7 +17,8 @@ const {
|
|
|
17
17
|
getModelMetadata,
|
|
18
18
|
getGenerationMetadata,
|
|
19
19
|
getToolNameFromTags,
|
|
20
|
-
getToolCallResultContent
|
|
20
|
+
getToolCallResultContent,
|
|
21
|
+
getLlmObsSpanName
|
|
21
22
|
} = require('./util')
|
|
22
23
|
|
|
23
24
|
const SPAN_NAME_TO_KIND_MAPPING = {
|
|
@@ -79,26 +80,32 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
|
|
|
79
80
|
* We use the tool description as the next best identifier for a tool.
|
|
80
81
|
*
|
|
81
82
|
* @param {string} toolDescription
|
|
82
|
-
* @returns {string}
|
|
83
|
+
* @returns {string | undefined}
|
|
83
84
|
*/
|
|
84
85
|
findToolName (toolDescription) {
|
|
85
86
|
for (const availableTool of this.#availableTools) {
|
|
86
87
|
const description = availableTool.description
|
|
87
|
-
if (description === toolDescription) {
|
|
88
|
+
if (description === toolDescription && availableTool.id) {
|
|
88
89
|
return availableTool.id
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @override
|
|
96
|
+
*/
|
|
93
97
|
getLLMObsSpanRegisterOptions (ctx) {
|
|
94
98
|
const span = ctx.currentStore?.span
|
|
95
99
|
const operation = getOperation(span)
|
|
96
100
|
const kind = SPAN_NAME_TO_KIND_MAPPING[operation]
|
|
97
101
|
if (!kind) return
|
|
98
102
|
|
|
99
|
-
return { kind, name: operation }
|
|
103
|
+
return { kind, name: getLlmObsSpanName(operation, ctx.attributes['ai.telemetry.functionId']) }
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @override
|
|
108
|
+
*/
|
|
102
109
|
setLLMObsTags (ctx) {
|
|
103
110
|
const span = ctx.currentStore?.span
|
|
104
111
|
if (!span) return
|
|
@@ -211,6 +218,10 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
|
|
|
211
218
|
this._tagger.tagMetadata(span, metadata)
|
|
212
219
|
}
|
|
213
220
|
|
|
221
|
+
/**
|
|
222
|
+
* @param {import('../../../opentracing/span')} span
|
|
223
|
+
* @param {Record<string, unknown>} tags
|
|
224
|
+
*/
|
|
214
225
|
setLLMOperationTags (span, tags) {
|
|
215
226
|
const toolsForModel = tags['ai.prompt.tools']?.map(getJsonStringValue)
|
|
216
227
|
|
|
@@ -34,7 +34,7 @@ function getSpanTags (ctx) {
|
|
|
34
34
|
* getOperation(span) // 'doGenerate'
|
|
35
35
|
*
|
|
36
36
|
* @param {import('../../../opentracing/span')} span
|
|
37
|
-
* @returns {string}
|
|
37
|
+
* @returns {string | undefined}
|
|
38
38
|
*/
|
|
39
39
|
function getOperation (span) {
|
|
40
40
|
const name = span._name
|
|
@@ -45,8 +45,9 @@ function getOperation (span) {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Get the LLM token usage from the span tags
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
48
|
+
* @template T extends {inputTokens: number, outputTokens: number, totalTokens: number}
|
|
49
|
+
* @param {T} tags
|
|
50
|
+
* @returns {Pick<T, 'inputTokens' | 'outputTokens' | 'totalTokens'>}
|
|
50
51
|
*/
|
|
51
52
|
function getUsage (tags) {
|
|
52
53
|
const usage = {}
|
|
@@ -64,9 +65,10 @@ function getUsage (tags) {
|
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Safely JSON parses a string value with a default fallback
|
|
68
|
+
* @template T typeof defaultValue
|
|
67
69
|
* @param {string} str
|
|
68
|
-
* @param {
|
|
69
|
-
* @returns {Record<string,
|
|
70
|
+
* @param {T} defaultValue
|
|
71
|
+
* @returns {Record<string, unknown> | string | Array<unknown> | null | T}
|
|
70
72
|
*/
|
|
71
73
|
function getJsonStringValue (str, defaultValue) {
|
|
72
74
|
let maybeValue = defaultValue
|
|
@@ -81,7 +83,7 @@ function getJsonStringValue (str, defaultValue) {
|
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* Get the model metadata from the span tags (top_p, top_k, temperature, etc.)
|
|
84
|
-
* @param {
|
|
86
|
+
* @param {Record<string, unknown>} tags
|
|
85
87
|
* @returns {Record<string, string> | null}
|
|
86
88
|
*/
|
|
87
89
|
function getModelMetadata (tags) {
|
|
@@ -167,6 +169,16 @@ function getToolCallResultContent (content) {
|
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Computes the LLM Observability `ai` span name
|
|
174
|
+
* @param {string} operation
|
|
175
|
+
* @param {string} functionId
|
|
176
|
+
* @returns {string}
|
|
177
|
+
*/
|
|
178
|
+
function getLlmObsSpanName (operation, functionId) {
|
|
179
|
+
return functionId ? `${functionId}.${operation}` : operation
|
|
180
|
+
}
|
|
181
|
+
|
|
170
182
|
module.exports = {
|
|
171
183
|
getSpanTags,
|
|
172
184
|
getOperation,
|
|
@@ -175,5 +187,6 @@ module.exports = {
|
|
|
175
187
|
getModelMetadata,
|
|
176
188
|
getGenerationMetadata,
|
|
177
189
|
getToolNameFromTags,
|
|
178
|
-
getToolCallResultContent
|
|
190
|
+
getToolCallResultContent,
|
|
191
|
+
getLlmObsSpanName
|
|
179
192
|
}
|