@depup/dd-trace 5.97.0-depup.0 → 6.4.0-depup.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 +89 -104
- package/README.md +9 -3
- package/changes.json +8 -3
- package/ci/init.js +25 -5
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/exporters.js +1 -0
- package/ext/tags.js +3 -0
- package/index.d.ts +315 -244
- package/index.electron.js +3 -0
- package/initialize.mjs +9 -8
- package/loader-hook.mjs +154 -47
- package/package.json +118 -78
- package/packages/datadog-core/src/storage.js +47 -48
- package/packages/datadog-esbuild/index.js +32 -1
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/aerospike.js +3 -3
- package/packages/datadog-instrumentations/src/ai.js +131 -76
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +10 -18
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +172 -72
- package/packages/datadog-instrumentations/src/azure-cosmos.js +7 -0
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +5 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +12 -9
- package/packages/datadog-instrumentations/src/child_process.js +15 -15
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +587 -0
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
- package/packages/datadog-instrumentations/src/connect.js +14 -12
- package/packages/datadog-instrumentations/src/cookie-parser.js +5 -4
- package/packages/datadog-instrumentations/src/cookie.js +9 -3
- package/packages/datadog-instrumentations/src/couchbase.js +73 -238
- package/packages/datadog-instrumentations/src/crypto.js +49 -4
- package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +19 -0
- package/packages/datadog-instrumentations/src/cucumber.js +747 -187
- package/packages/datadog-instrumentations/src/cypress-config.js +164 -56
- package/packages/datadog-instrumentations/src/cypress.js +5 -3
- package/packages/datadog-instrumentations/src/dns.js +60 -59
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -12
- package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
- package/packages/datadog-instrumentations/src/electron.js +240 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +11 -9
- package/packages/datadog-instrumentations/src/express-session.js +14 -13
- package/packages/datadog-instrumentations/src/express.js +52 -30
- package/packages/datadog-instrumentations/src/fastify.js +169 -86
- package/packages/datadog-instrumentations/src/fetch.js +5 -5
- package/packages/datadog-instrumentations/src/fs.js +22 -20
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/graphql.js +26 -362
- package/packages/datadog-instrumentations/src/grpc/client.js +48 -32
- package/packages/datadog-instrumentations/src/grpc/server.js +20 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +85 -9
- package/packages/datadog-instrumentations/src/helpers/hook.js +4 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +36 -3
- package/packages/datadog-instrumentations/src/helpers/kafka.js +58 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/promise-instrumentor.js +42 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -5
- package/packages/datadog-instrumentations/src/helpers/require-optional-peer.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +13 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +24 -7
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +6 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-cosmos.js +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/claude-agent-sdk.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +35 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +85 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +49 -224
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +8 -8
- package/packages/datadog-instrumentations/src/hono.js +71 -9
- package/packages/datadog-instrumentations/src/http/client.js +48 -24
- package/packages/datadog-instrumentations/src/http/server.js +75 -29
- package/packages/datadog-instrumentations/src/http2/client.js +15 -12
- package/packages/datadog-instrumentations/src/http2/server.js +156 -23
- package/packages/datadog-instrumentations/src/ioredis.js +17 -14
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
- package/packages/datadog-instrumentations/src/jest/bail-reporter.js +42 -0
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +163 -0
- package/packages/datadog-instrumentations/src/jest.js +1783 -401
- package/packages/datadog-instrumentations/src/kafkajs.js +284 -170
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +15 -14
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +18 -16
- package/packages/datadog-instrumentations/src/memcached.js +4 -3
- package/packages/datadog-instrumentations/src/mercurius.js +11 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +557 -118
- package/packages/datadog-instrumentations/src/mocha/utils.js +531 -131
- package/packages/datadog-instrumentations/src/mocha/worker.js +27 -9
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +254 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +43 -31
- package/packages/datadog-instrumentations/src/mongodb.js +79 -5
- package/packages/datadog-instrumentations/src/mongoose.js +43 -34
- package/packages/datadog-instrumentations/src/mquery.js +5 -5
- package/packages/datadog-instrumentations/src/multer.js +5 -4
- package/packages/datadog-instrumentations/src/mysql.js +17 -17
- package/packages/datadog-instrumentations/src/mysql2.js +39 -5
- package/packages/datadog-instrumentations/src/nats.js +182 -0
- package/packages/datadog-instrumentations/src/net.js +19 -11
- package/packages/datadog-instrumentations/src/next.js +44 -10
- package/packages/datadog-instrumentations/src/nyc.js +43 -6
- package/packages/datadog-instrumentations/src/openai.js +124 -38
- package/packages/datadog-instrumentations/src/oracledb.js +12 -7
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +27 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/path-to-regexp.js +44 -0
- package/packages/datadog-instrumentations/src/pg.js +58 -25
- package/packages/datadog-instrumentations/src/pino.js +25 -41
- package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
- package/packages/datadog-instrumentations/src/playwright.js +1086 -350
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +28 -15
- package/packages/datadog-instrumentations/src/restify.js +6 -5
- package/packages/datadog-instrumentations/src/router.js +243 -87
- package/packages/datadog-instrumentations/src/selenium.js +1 -2
- package/packages/datadog-instrumentations/src/stripe.js +47 -33
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1297 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +1592 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +251 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +822 -0
- package/packages/datadog-instrumentations/src/vitest.js +11 -1262
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +7 -7
- package/packages/datadog-instrumentations/src/zlib.js +29 -0
- package/packages/datadog-plugin-ai/src/index.js +1 -1
- package/packages/datadog-plugin-ai/src/tracing.js +66 -3
- package/packages/datadog-plugin-ai/src/utils.js +17 -4
- package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +123 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +129 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +79 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +86 -50
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +218 -4
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +59 -14
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +174 -75
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +26 -26
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +187 -101
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
- package/packages/datadog-plugin-azure-cosmos/src/index.js +144 -0
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
- package/packages/datadog-plugin-azure-functions/src/index.js +7 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -10
- package/packages/datadog-plugin-bullmq/src/consumer.js +5 -4
- package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +121 -33
- package/packages/datadog-plugin-bunyan/src/index.js +28 -0
- package/packages/datadog-plugin-child_process/src/index.js +13 -2
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-claude-agent-sdk/src/index.js +31 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/tracing.js +107 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/util.js +15 -0
- package/packages/datadog-plugin-couchbase/src/index.js +58 -52
- package/packages/datadog-plugin-cucumber/src/index.js +46 -28
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +961 -92
- package/packages/datadog-plugin-cypress/src/index.js +104 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +6 -14
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
- package/packages/datadog-plugin-cypress/src/support.js +180 -25
- package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +8 -6
- package/packages/datadog-plugin-elasticsearch/src/index.js +28 -8
- package/packages/datadog-plugin-electron/src/index.js +17 -0
- package/packages/datadog-plugin-electron/src/ipc.js +143 -0
- package/packages/datadog-plugin-electron/src/net.js +82 -0
- package/packages/datadog-plugin-express/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +2 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +5 -8
- package/packages/datadog-plugin-graphql/src/execute.js +706 -34
- package/packages/datadog-plugin-graphql/src/index.js +43 -9
- package/packages/datadog-plugin-graphql/src/parse.js +45 -4
- package/packages/datadog-plugin-graphql/src/request.js +135 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
- package/packages/datadog-plugin-graphql/src/utils.js +261 -3
- package/packages/datadog-plugin-graphql/src/validate.js +53 -7
- package/packages/datadog-plugin-grpc/src/client.js +7 -8
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-grpc/src/util.js +57 -22
- package/packages/datadog-plugin-http/src/client.js +12 -14
- package/packages/datadog-plugin-http/src/index.js +6 -8
- package/packages/datadog-plugin-http/src/server.js +63 -20
- package/packages/datadog-plugin-http2/src/client.js +6 -3
- package/packages/datadog-plugin-http2/src/server.js +48 -8
- package/packages/datadog-plugin-jest/src/index.js +133 -67
- package/packages/datadog-plugin-jest/src/util.js +37 -16
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +37 -8
- package/packages/datadog-plugin-langgraph/src/stream.js +1 -1
- package/packages/datadog-plugin-memcached/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +66 -20
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +173 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
- package/packages/datadog-plugin-mongodb-core/src/bulk-write.js +43 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -206
- package/packages/datadog-plugin-mongodb-core/src/query.js +452 -0
- package/packages/datadog-plugin-mysql/src/index.js +9 -4
- package/packages/datadog-plugin-nats/src/consumer.js +43 -0
- package/packages/datadog-plugin-nats/src/index.js +20 -0
- package/packages/datadog-plugin-nats/src/producer.js +62 -0
- package/packages/datadog-plugin-nats/src/util.js +33 -0
- package/packages/datadog-plugin-next/src/index.js +12 -4
- package/packages/datadog-plugin-openai/src/services.js +4 -3
- package/packages/datadog-plugin-openai/src/tracing.js +27 -25
- package/packages/datadog-plugin-oracledb/src/index.js +13 -2
- package/packages/datadog-plugin-pg/src/index.js +13 -3
- package/packages/datadog-plugin-pino/src/index.js +42 -0
- package/packages/datadog-plugin-playwright/src/index.js +21 -11
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-redis/src/index.js +54 -25
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-router/src/index.js +46 -44
- package/packages/datadog-plugin-selenium/src/index.js +1 -1
- package/packages/datadog-plugin-tedious/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +24 -2
- package/packages/datadog-plugin-vitest/src/index.js +160 -90
- package/packages/datadog-plugin-winston/src/index.js +30 -0
- package/packages/datadog-plugin-ws/src/close.js +3 -1
- package/packages/datadog-plugin-ws/src/producer.js +2 -0
- package/packages/datadog-plugin-ws/src/receiver.js +2 -1
- package/packages/datadog-shimmer/src/shimmer.js +101 -39
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/index.electron.js +3 -0
- package/packages/dd-trace/index.js +2 -36
- package/packages/dd-trace/src/aiguard/channels.js +7 -0
- package/packages/dd-trace/src/aiguard/index.js +16 -34
- package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +34 -0
- package/packages/dd-trace/src/aiguard/integrations/openai.js +80 -0
- package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +92 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +382 -0
- package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/vercel-ai.js} +30 -27
- package/packages/dd-trace/src/aiguard/sdk.js +147 -54
- package/packages/dd-trace/src/aiguard/tags.js +26 -10
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
- package/packages/dd-trace/src/appsec/blocking.js +82 -42
- package/packages/dd-trace/src/appsec/channels.js +5 -1
- package/packages/dd-trace/src/appsec/downstream_requests.js +116 -62
- package/packages/dd-trace/src/appsec/graphql.js +20 -17
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +23 -23
- package/packages/dd-trace/src/appsec/iast/index.js +3 -2
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +31 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +65 -47
- package/packages/dd-trace/src/appsec/lambda.js +135 -0
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +26 -18
- package/packages/dd-trace/src/appsec/recommended.json +2438 -13
- package/packages/dd-trace/src/appsec/reporter.js +87 -28
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +7 -11
- package/packages/dd-trace/src/appsec/sdk/utils.js +5 -3
- package/packages/dd-trace/src/appsec/store.js +50 -0
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +5 -4
- package/packages/dd-trace/src/appsec/waf/index.js +19 -9
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +35 -20
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/azure_metadata.js +17 -6
- package/packages/dd-trace/src/baggage.js +32 -13
- package/packages/dd-trace/src/bootstrap.js +39 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +30 -5
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +122 -24
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +22 -7
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +5 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +6 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +148 -25
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +28 -10
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +22 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +105 -22
- package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +73 -55
- package/packages/dd-trace/src/ci-visibility/requests/request.js +14 -50
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +4 -4
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +5 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +24 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +70 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +128 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +291 -0
- package/packages/dd-trace/src/config/config-types.d.ts +8 -6
- package/packages/dd-trace/src/config/defaults.js +71 -44
- package/packages/dd-trace/src/config/generated-config-types.d.ts +676 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +139 -33
- package/packages/dd-trace/src/config/index.js +117 -131
- package/packages/dd-trace/src/config/major-overrides.js +100 -0
- package/packages/dd-trace/src/config/normalize-service.js +31 -0
- package/packages/dd-trace/src/config/parsers.js +138 -10
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +394 -203
- package/packages/dd-trace/src/constants.js +15 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +18 -6
- package/packages/dd-trace/src/datastreams/checkpointer.js +6 -12
- package/packages/dd-trace/src/datastreams/context.js +4 -2
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/manager.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +35 -30
- package/packages/dd-trace/src/datastreams/processor.js +31 -22
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/datastreams/writer.js +15 -6
- package/packages/dd-trace/src/debugger/config.js +9 -4
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -8
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +33 -71
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +27 -6
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/index.js +13 -9
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/dogstatsd.js +34 -28
- package/packages/dd-trace/src/encode/0.4.js +829 -268
- package/packages/dd-trace/src/encode/0.5.js +158 -22
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +141 -65
- package/packages/dd-trace/src/encode/agentless-json.js +12 -6
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +52 -15
- package/packages/dd-trace/src/encode/span-stats.js +19 -16
- package/packages/dd-trace/src/encode/tags-processors.js +30 -25
- package/packages/dd-trace/src/exporter.js +3 -1
- package/packages/dd-trace/src/exporters/agent/index.js +4 -5
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
- package/packages/dd-trace/src/exporters/agentless/index.js +12 -13
- package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +12 -11
- package/packages/dd-trace/src/exporters/common/agents.js +3 -1
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +3 -3
- package/packages/dd-trace/src/exporters/common/request.js +48 -28
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/exporters/common/url.js +34 -0
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +17 -1
- package/packages/dd-trace/src/exporters/electron/index.js +49 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -2
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/external-logger/src/index.js +2 -1
- package/packages/dd-trace/src/feature-registry.js +22 -0
- package/packages/dd-trace/src/git_metadata.js +68 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/guardrails/index.js +11 -6
- package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
- package/packages/dd-trace/src/heap_snapshots.js +4 -4
- package/packages/dd-trace/src/id.js +46 -27
- package/packages/dd-trace/src/index.js +7 -8
- package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
- package/packages/dd-trace/src/lambda/handler.js +2 -6
- package/packages/dd-trace/src/lambda/index.js +62 -14
- package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
- package/packages/dd-trace/src/llmobs/constants/tags.js +13 -0
- package/packages/dd-trace/src/llmobs/index.js +37 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -395
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +119 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +363 -0
- package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +32 -79
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +109 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +89 -37
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +270 -0
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +81 -16
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -50
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +14 -8
- package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
- package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +3 -28
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +21 -51
- package/packages/dd-trace/src/llmobs/sdk.js +56 -35
- package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
- package/packages/dd-trace/src/llmobs/tagger.js +129 -4
- package/packages/dd-trace/src/llmobs/telemetry.js +31 -1
- package/packages/dd-trace/src/llmobs/util.js +202 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +11 -5
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/index.js +19 -31
- package/packages/dd-trace/src/log/writer.js +3 -1
- package/packages/dd-trace/src/msgpack/chunk.js +430 -11
- package/packages/dd-trace/src/msgpack/index.js +101 -2
- package/packages/dd-trace/src/noop/proxy.js +5 -4
- package/packages/dd-trace/src/noop/span.js +3 -1
- package/packages/dd-trace/src/openfeature/encoding.js +70 -0
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +26 -1
- package/packages/dd-trace/src/openfeature/noop.js +40 -36
- package/packages/dd-trace/src/openfeature/register.js +46 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +6 -1
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +143 -0
- package/packages/dd-trace/src/openfeature/span-enrichment.js +149 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +3 -11
- package/packages/dd-trace/src/openfeature/writers/exposures.js +82 -70
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -2
- package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +107 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +27 -13
- package/packages/dd-trace/src/opentelemetry/logs/index.js +6 -6
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +61 -12
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +28 -14
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +7 -10
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +99 -5
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +56 -82
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
- package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
- package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
- package/packages/dd-trace/src/opentelemetry/span.js +59 -109
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
- package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +375 -0
- package/packages/dd-trace/src/opentelemetry/tracer.js +20 -69
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +33 -17
- package/packages/dd-trace/src/opentracing/propagation/log.js +28 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +278 -148
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +11 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +98 -32
- package/packages/dd-trace/src/opentracing/span.js +127 -73
- package/packages/dd-trace/src/opentracing/span_context.js +68 -3
- package/packages/dd-trace/src/opentracing/tracer.js +46 -19
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +36 -14
- package/packages/dd-trace/src/plugins/apollo.js +3 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +387 -85
- package/packages/dd-trace/src/plugins/database.js +61 -18
- package/packages/dd-trace/src/plugins/index.js +14 -0
- package/packages/dd-trace/src/plugins/log_injection.js +56 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +4 -44
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/plugin.js +19 -28
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/tracing.js +70 -13
- package/packages/dd-trace/src/plugins/util/ci.js +127 -40
- package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
- package/packages/dd-trace/src/plugins/util/git.js +3 -1
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/llm.js +6 -1
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
- package/packages/dd-trace/src/plugins/util/test.js +894 -65
- package/packages/dd-trace/src/plugins/util/url.js +71 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
- package/packages/dd-trace/src/plugins/util/web.js +116 -180
- package/packages/dd-trace/src/priority_sampler.js +12 -21
- package/packages/dd-trace/src/profiling/config.js +132 -212
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +84 -105
- package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +57 -13
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
- package/packages/dd-trace/src/profiling/profilers/wall.js +49 -35
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -3
- package/packages/dd-trace/src/propagation-hash/index.js +1 -1
- package/packages/dd-trace/src/proxy.js +50 -36
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +6 -5
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/ritm.js +6 -3
- package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +14 -4
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +42 -41
- package/packages/dd-trace/src/sampling_rule.js +7 -7
- package/packages/dd-trace/src/scope.js +10 -15
- package/packages/dd-trace/src/serverless.js +6 -7
- package/packages/dd-trace/src/service-naming/extra-services.js +14 -0
- package/packages/dd-trace/src/service-naming/index.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +48 -3
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +61 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +25 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +32 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
- package/packages/dd-trace/src/service-naming/source-resolver.js +50 -0
- package/packages/dd-trace/src/span_format.js +269 -81
- package/packages/dd-trace/src/span_processor.js +13 -13
- package/packages/dd-trace/src/span_stats.js +101 -79
- package/packages/dd-trace/src/spanleak.js +1 -2
- package/packages/dd-trace/src/standalone/index.js +3 -25
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/tagger.js +2 -4
- package/packages/dd-trace/src/telemetry/dependencies.js +2 -2
- package/packages/dd-trace/src/telemetry/endpoints.js +7 -5
- package/packages/dd-trace/src/telemetry/index.js +2 -2
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +20 -20
- package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +16 -14
- package/packages/dd-trace/src/tracer.js +23 -9
- package/packages/dd-trace/src/tracer_metadata.js +1 -1
- package/packages/dd-trace/src/util.js +31 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +94 -42
- package/vendor/dist/@datadog/sketches-js/LICENSE +10 -36
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +0 -178
- package/packages/dd-trace/src/agent/url.js +0 -28
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
- package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
- package/packages/dd-trace/src/log/utils.js +0 -16
- package/packages/dd-trace/src/msgpack/encoder.js +0 -308
- package/packages/dd-trace/src/plugins/structured_log_plugin.js +0 -9
- package/scripts/preinstall.js +0 -34
- package/vendor/dist/ignore/LICENSE +0 -21
- package/vendor/dist/ignore/index.js +0 -1
- package/vendor/dist/opentracing/LICENSE +0 -201
- package/vendor/dist/opentracing/binary_carrier.d.ts +0 -11
- package/vendor/dist/opentracing/constants.d.ts +0 -61
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +0 -2
- package/vendor/dist/opentracing/ext/tags.d.ts +0 -90
- package/vendor/dist/opentracing/functions.d.ts +0 -20
- package/vendor/dist/opentracing/global_tracer.d.ts +0 -14
- package/vendor/dist/opentracing/index.d.ts +0 -12
- package/vendor/dist/opentracing/index.js +0 -1
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +0 -5
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +0 -13
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +0 -16
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +0 -50
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +0 -26
- package/vendor/dist/opentracing/noop.d.ts +0 -8
- package/vendor/dist/opentracing/reference.d.ts +0 -33
- package/vendor/dist/opentracing/span.d.ts +0 -147
- package/vendor/dist/opentracing/span_context.d.ts +0 -26
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +0 -16
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +0 -3
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +0 -4
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +0 -3
- package/vendor/dist/opentracing/test/unittest.d.ts +0 -2
- package/vendor/dist/opentracing/tracer.d.ts +0 -127
- package/vendor/dist/path-to-regexp/LICENSE +0 -21
- package/vendor/dist/path-to-regexp/index.js +0 -1
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const { readFileSync, readdirSync, existsSync } = require('fs')
|
|
4
4
|
const path = require('path')
|
|
5
|
-
const
|
|
5
|
+
const getConfig = require('../../config')
|
|
6
|
+
const { getEnvironmentVariable, getEnvironmentVariables } = require('../../config/helper')
|
|
6
7
|
const {
|
|
7
8
|
GIT_BRANCH,
|
|
8
9
|
GIT_COMMIT_SHA,
|
|
@@ -103,42 +104,129 @@ function getGitHubEventPayload () {
|
|
|
103
104
|
return JSON.parse(readFileSync(path, 'utf8'))
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
const uniq = (items) => [...new Set(items)]
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* GitHub runner diagnostic logs live under the runner installation directory in `_diag`.
|
|
111
|
+
* On many runners, we can derive the installation directory from RUNNER_TEMP:
|
|
112
|
+
* <runnerRoot>/_work/_temp -> <runnerRoot>/_diag
|
|
113
|
+
*
|
|
114
|
+
* This is much more robust than relying on hardcoded paths, especially on self-hosted runners
|
|
115
|
+
* and GHES environments where the runner may be installed under arbitrary directories/users.
|
|
116
|
+
*/
|
|
117
|
+
function getGithubDiagnosticDirsFromEnv (runnerTemp) {
|
|
118
|
+
const dirs = []
|
|
119
|
+
|
|
120
|
+
if (runnerTemp) {
|
|
121
|
+
// RUNNER_TEMP is typically: <runnerRoot>/_work/_temp
|
|
122
|
+
const runnerRoot = path.resolve(runnerTemp, '..', '..').replaceAll(path.sep, '/')
|
|
123
|
+
// Bounded-depth patterns cover every runner layout we've observed
|
|
124
|
+
// (including cached/<version>/_diag) without assuming a `cached` wrapper
|
|
125
|
+
// and without walking the whole tree.
|
|
126
|
+
dirs.push(
|
|
127
|
+
path.posix.join(runnerRoot, 'actions-runner', '_diag'),
|
|
128
|
+
`${runnerRoot}/actions-runner/*/_diag`,
|
|
129
|
+
`${runnerRoot}/actions-runner/*/*/_diag`,
|
|
130
|
+
path.posix.join(runnerRoot, '_diag'),
|
|
131
|
+
`${runnerRoot}/*/_diag`,
|
|
132
|
+
`${runnerRoot}/*/*/_diag`
|
|
133
|
+
)
|
|
134
|
+
}
|
|
108
135
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// Windows hosted: C:\actions-runner\_work\_temp
|
|
112
|
-
// Self-hosted (unix): /opt/actions-runner/_work/_temp
|
|
136
|
+
return uniq(dirs.filter(Boolean))
|
|
137
|
+
}
|
|
113
138
|
|
|
114
|
-
|
|
115
|
-
|
|
139
|
+
function hasMagicChars (str) {
|
|
140
|
+
return str.includes('*') || str.includes('?')
|
|
141
|
+
}
|
|
116
142
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
]
|
|
143
|
+
// Expands a glob pattern with only `*`/`?` at path-segment boundaries (no `**`)
|
|
144
|
+
// into matching concrete paths using readdirSync — no external dependency needed.
|
|
145
|
+
function expandGlobPattern (pattern) {
|
|
146
|
+
const parts = pattern.split(/[/\\]/)
|
|
147
|
+
const wildcardIdx = parts.findIndex(p => hasMagicChars(p))
|
|
148
|
+
if (wildcardIdx === -1) return [pattern]
|
|
123
149
|
|
|
124
|
-
const
|
|
150
|
+
const prefix = parts.slice(0, wildcardIdx).join('/')
|
|
151
|
+
const results = []
|
|
125
152
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
153
|
+
function walk (dir, segIdx) {
|
|
154
|
+
if (segIdx === parts.length) {
|
|
155
|
+
results.push(dir)
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
const seg = parts[segIdx]
|
|
159
|
+
if (!hasMagicChars(seg)) {
|
|
160
|
+
walk(`${dir}/${seg}`, segIdx + 1)
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const re = new RegExp(
|
|
165
|
+
'^' + seg.replaceAll(/[.+^${}()|[\]\\]/g, String.raw`\$&`).replaceAll('*', String.raw`[^/\\]*`).replaceAll('?', String.raw`[^/\\]`) + '$'
|
|
166
|
+
)
|
|
167
|
+
for (const entry of readdirSync(dir)) {
|
|
168
|
+
if (re.test(entry)) {
|
|
169
|
+
walk(`${dir}/${entry}`, segIdx + 1)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} catch {
|
|
173
|
+
// directory doesn't exist or isn't accessible
|
|
174
|
+
}
|
|
138
175
|
}
|
|
139
176
|
|
|
140
|
-
|
|
141
|
-
|
|
177
|
+
walk(prefix, wildcardIdx)
|
|
178
|
+
return results
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Expands a mixed list of literal directories and glob patterns into concrete
|
|
183
|
+
* directories. Literals pass through unchanged (existence is checked later).
|
|
184
|
+
*/
|
|
185
|
+
function expandDiagnosticDirCandidates (candidates) {
|
|
186
|
+
const expanded = []
|
|
187
|
+
for (const candidate of candidates) {
|
|
188
|
+
if (hasMagicChars(candidate)) {
|
|
189
|
+
expanded.push(...expandGlobPattern(candidate))
|
|
190
|
+
} else {
|
|
191
|
+
expanded.push(candidate)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return uniq(expanded)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const githubWellKnownDiagnosticDirsUnix = [
|
|
199
|
+
'/home/runner/actions-runner/_diag',
|
|
200
|
+
'/opt/actions-runner/_diag',
|
|
201
|
+
]
|
|
202
|
+
const githubWellKnownDiagnosticDirsWin = [
|
|
203
|
+
'C:/actions-runner/_diag',
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
// Glob patterns covering layouts that namespace `_diag` under one or two
|
|
207
|
+
// intermediate directories. This includes both observed SaaS layouts
|
|
208
|
+
// (<runnerRoot>/cached/_diag pre-2.334.0, <runnerRoot>/cached/<version>/_diag
|
|
209
|
+
// since v2.334.0) and hypothetical future layouts that follow the same shape
|
|
210
|
+
// without a `cached` wrapper (e.g. <runnerRoot>/<version>/_diag). Depth is
|
|
211
|
+
// bounded on purpose: `*` matches a single segment, so no filesystem walk.
|
|
212
|
+
const githubWellKnownDiagnosticDirPatternsUnix = [
|
|
213
|
+
'/home/runner/actions-runner/*/_diag',
|
|
214
|
+
'/home/runner/actions-runner/*/*/_diag',
|
|
215
|
+
]
|
|
216
|
+
const githubWellKnownDiagnosticDirPatternsWin = ['C:/actions-runner/*/_diag', 'C:/actions-runner/*/*/_diag']
|
|
217
|
+
|
|
218
|
+
const githubJobIDRegex = /"job":\s*{[\s\S]*?"v"\s*:\s*(\d+)(?:\.0)?/
|
|
219
|
+
|
|
220
|
+
function getJobIDFromDiagFile () {
|
|
221
|
+
const runnerTemp = getEnvironmentVariable('RUNNER_TEMP')
|
|
222
|
+
if (!runnerTemp || !existsSync(runnerTemp)) { return null }
|
|
223
|
+
|
|
224
|
+
const isWin = process.platform === 'win32'
|
|
225
|
+
const patterns = isWin ? githubWellKnownDiagnosticDirPatternsWin : githubWellKnownDiagnosticDirPatternsUnix
|
|
226
|
+
const literals = isWin ? githubWellKnownDiagnosticDirsWin : githubWellKnownDiagnosticDirsUnix
|
|
227
|
+
const possibleDiagsPaths = expandDiagnosticDirCandidates([
|
|
228
|
+
...getGithubDiagnosticDirsFromEnv(runnerTemp), ...patterns, ...literals,
|
|
229
|
+
])
|
|
142
230
|
|
|
143
231
|
// This will hold the names of the worker log files that (potentially) contain the Job ID
|
|
144
232
|
let workerLogFiles = []
|
|
@@ -177,7 +265,7 @@ function getJobIDFromDiagFile (runnerTemp) {
|
|
|
177
265
|
const filePath = path.posix.join(chosenDiagPath, logFile)
|
|
178
266
|
const content = readFileSync(filePath, 'utf8')
|
|
179
267
|
|
|
180
|
-
const match = content.match(
|
|
268
|
+
const match = content.match(githubJobIDRegex)
|
|
181
269
|
|
|
182
270
|
// match[1] is the captured group with the display name
|
|
183
271
|
if (match && match[1]) { return match[1] }
|
|
@@ -188,6 +276,7 @@ function getJobIDFromDiagFile (runnerTemp) {
|
|
|
188
276
|
|
|
189
277
|
module.exports = {
|
|
190
278
|
normalizeRef,
|
|
279
|
+
expandGlobPattern,
|
|
191
280
|
getJobIDFromDiagFile,
|
|
192
281
|
getCIMetadata () {
|
|
193
282
|
const env = getEnvironmentVariables()
|
|
@@ -210,7 +299,7 @@ module.exports = {
|
|
|
210
299
|
CHANGE_ID,
|
|
211
300
|
CHANGE_TARGET,
|
|
212
301
|
} = env
|
|
213
|
-
const DD_CUSTOM_TRACE_ID =
|
|
302
|
+
const { DD_CUSTOM_TRACE_ID, DD_CUSTOM_PARENT_ID } = getConfig()
|
|
214
303
|
|
|
215
304
|
tags = {
|
|
216
305
|
[CI_PIPELINE_ID]: BUILD_TAG,
|
|
@@ -220,7 +309,7 @@ module.exports = {
|
|
|
220
309
|
[GIT_COMMIT_SHA]: JENKINS_GIT_COMMIT,
|
|
221
310
|
[GIT_REPOSITORY_URL]: JENKINS_GIT_REPOSITORY_URL || JENKINS_GIT_REPOSITORY_URL_1,
|
|
222
311
|
[CI_WORKSPACE_PATH]: WORKSPACE,
|
|
223
|
-
[CI_ENV_VARS]: JSON.stringify({ DD_CUSTOM_TRACE_ID }),
|
|
312
|
+
[CI_ENV_VARS]: JSON.stringify({ DD_CUSTOM_TRACE_ID, DD_CUSTOM_PARENT_ID }),
|
|
224
313
|
[CI_NODE_NAME]: NODE_NAME,
|
|
225
314
|
[PR_NUMBER]: CHANGE_ID,
|
|
226
315
|
[GIT_PULL_REQUEST_BASE_BRANCH]: CHANGE_TARGET,
|
|
@@ -366,7 +455,6 @@ module.exports = {
|
|
|
366
455
|
GITHUB_RUN_ATTEMPT,
|
|
367
456
|
GITHUB_JOB,
|
|
368
457
|
GITHUB_BASE_REF,
|
|
369
|
-
RUNNER_TEMP,
|
|
370
458
|
JOB_CHECK_RUN_ID,
|
|
371
459
|
} = env
|
|
372
460
|
|
|
@@ -378,7 +466,7 @@ module.exports = {
|
|
|
378
466
|
}
|
|
379
467
|
|
|
380
468
|
// Build the job url extracting the job ID. If extraction fails, job url is constructed as a generalized url
|
|
381
|
-
const GITHUB_JOB_ID = JOB_CHECK_RUN_ID ?? getJobIDFromDiagFile(
|
|
469
|
+
const GITHUB_JOB_ID = JOB_CHECK_RUN_ID ?? getJobIDFromDiagFile()
|
|
382
470
|
const jobUrl =
|
|
383
471
|
GITHUB_JOB_ID === null
|
|
384
472
|
? `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}/checks`
|
|
@@ -563,7 +651,7 @@ module.exports = {
|
|
|
563
651
|
[GIT_TAG]: BITBUCKET_TAG,
|
|
564
652
|
[GIT_REPOSITORY_URL]: BITBUCKET_GIT_SSH_ORIGIN || BITBUCKET_GIT_HTTP_ORIGIN,
|
|
565
653
|
[CI_WORKSPACE_PATH]: BITBUCKET_CLONE_DIR,
|
|
566
|
-
[CI_PIPELINE_ID]: BITBUCKET_PIPELINE_UUID && BITBUCKET_PIPELINE_UUID.replaceAll(/{
|
|
654
|
+
[CI_PIPELINE_ID]: BITBUCKET_PIPELINE_UUID && BITBUCKET_PIPELINE_UUID.replaceAll(/[{}]/gm, ''),
|
|
567
655
|
[GIT_PULL_REQUEST_BASE_BRANCH]: BITBUCKET_PR_DESTINATION_BRANCH,
|
|
568
656
|
[PR_NUMBER]: BITBUCKET_PR_ID,
|
|
569
657
|
}
|
|
@@ -651,11 +739,11 @@ module.exports = {
|
|
|
651
739
|
}),
|
|
652
740
|
[CI_NODE_NAME]: BUILDKITE_AGENT_ID,
|
|
653
741
|
[CI_NODE_LABELS]: JSON.stringify(extraTags),
|
|
654
|
-
[PR_NUMBER]: BUILDKITE_PULL_REQUEST,
|
|
655
742
|
[CI_JOB_ID]: BUILDKITE_JOB_ID,
|
|
656
743
|
}
|
|
657
744
|
|
|
658
|
-
if (BUILDKITE_PULL_REQUEST) {
|
|
745
|
+
if (BUILDKITE_PULL_REQUEST && BUILDKITE_PULL_REQUEST !== 'false') {
|
|
746
|
+
tags[PR_NUMBER] = BUILDKITE_PULL_REQUEST
|
|
659
747
|
tags[GIT_PULL_REQUEST_BASE_BRANCH] = BUILDKITE_PULL_REQUEST_BASE_BRANCH
|
|
660
748
|
}
|
|
661
749
|
}
|
|
@@ -781,8 +869,7 @@ module.exports = {
|
|
|
781
869
|
}
|
|
782
870
|
|
|
783
871
|
if (env.CODEBUILD_INITIATOR?.startsWith('codepipeline/')) {
|
|
784
|
-
const DD_ACTION_EXECUTION_ID =
|
|
785
|
-
const DD_PIPELINE_EXECUTION_ID = getValueFromEnvSources('DD_PIPELINE_EXECUTION_ID')
|
|
872
|
+
const { DD_ACTION_EXECUTION_ID, DD_PIPELINE_EXECUTION_ID } = getConfig()
|
|
786
873
|
tags = {
|
|
787
874
|
[CI_PROVIDER_NAME]: 'awscodepipeline',
|
|
788
875
|
[CI_PIPELINE_ID]: DD_PIPELINE_EXECUTION_ID,
|
|
@@ -7,24 +7,31 @@ const crypto = require('crypto')
|
|
|
7
7
|
const cp = require('child_process')
|
|
8
8
|
|
|
9
9
|
const log = require('../../log')
|
|
10
|
-
const
|
|
11
|
-
const { isTrue } = require('../../util')
|
|
10
|
+
const getConfig = require('../../config')
|
|
12
11
|
|
|
13
|
-
let isGitEnabled
|
|
14
|
-
|
|
15
|
-
path.join(os.tmpdir(), 'dd-trace-git-cache')
|
|
12
|
+
let isGitEnabled
|
|
13
|
+
let gitCacheDir
|
|
16
14
|
|
|
17
15
|
function ensureCacheDir () {
|
|
16
|
+
if (isGitEnabled === undefined) {
|
|
17
|
+
const config = getConfig()
|
|
18
|
+
isGitEnabled = config.DD_EXPERIMENTAL_TEST_OPT_GIT_CACHE_ENABLED
|
|
19
|
+
// TODO: Move the default to config/index.js applyCalculated
|
|
20
|
+
// when using the config singleton.
|
|
21
|
+
gitCacheDir = config.DD_EXPERIMENTAL_TEST_OPT_GIT_CACHE_DIR ||
|
|
22
|
+
path.join(os.tmpdir(), 'dd-trace-git-cache')
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
if (!isGitEnabled) return false
|
|
19
26
|
|
|
20
27
|
try {
|
|
21
|
-
if (fs.existsSync(
|
|
22
|
-
const stats = fs.statSync(
|
|
28
|
+
if (fs.existsSync(gitCacheDir)) {
|
|
29
|
+
const stats = fs.statSync(gitCacheDir)
|
|
23
30
|
if (!stats.isDirectory()) {
|
|
24
|
-
throw new Error(`Cache directory path exists but is not a directory: ${
|
|
31
|
+
throw new Error(`Cache directory path exists but is not a directory: ${gitCacheDir}`)
|
|
25
32
|
}
|
|
26
33
|
} else {
|
|
27
|
-
fs.mkdirSync(
|
|
34
|
+
fs.mkdirSync(gitCacheDir, { recursive: true })
|
|
28
35
|
}
|
|
29
36
|
return true
|
|
30
37
|
} catch (err) {
|
|
@@ -34,9 +41,6 @@ function ensureCacheDir () {
|
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
// Initialize cache directory at module load time
|
|
38
|
-
ensureCacheDir()
|
|
39
|
-
|
|
40
44
|
function getCacheKey (cmd, flags) {
|
|
41
45
|
// Create a hash of the command and flags to use as cache key
|
|
42
46
|
const commandString = `${cmd} ${flags.join(' ')}`
|
|
@@ -44,30 +48,26 @@ function getCacheKey (cmd, flags) {
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
function getCacheFilePath (cacheKey) {
|
|
47
|
-
|
|
51
|
+
ensureCacheDir()
|
|
52
|
+
return path.join(gitCacheDir, `${cacheKey}.cache`)
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
function getCache (cacheKey) {
|
|
51
|
-
if (!
|
|
56
|
+
if (!ensureCacheDir()) return null
|
|
52
57
|
|
|
53
58
|
try {
|
|
54
59
|
const cacheFilePath = getCacheFilePath(cacheKey)
|
|
55
60
|
if (!fs.existsSync(cacheFilePath)) {
|
|
56
|
-
return
|
|
61
|
+
return
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
return content
|
|
64
|
+
return fs.readFileSync(cacheFilePath, 'utf8')
|
|
61
65
|
} catch (err) {
|
|
62
66
|
log.error('Failed to read git cache', err)
|
|
63
|
-
return null
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
function setCache (cacheKey, result) {
|
|
68
|
-
if (!isGitEnabled) return
|
|
69
|
-
|
|
70
|
-
// Ensure cache directory exists
|
|
71
71
|
if (!ensureCacheDir()) return
|
|
72
72
|
|
|
73
73
|
try {
|
|
@@ -82,12 +82,12 @@ function cachedExec (cmd, flags, options) {
|
|
|
82
82
|
if (options === undefined) {
|
|
83
83
|
options = { stdio: 'pipe' }
|
|
84
84
|
}
|
|
85
|
-
if (!
|
|
85
|
+
if (!ensureCacheDir()) {
|
|
86
86
|
return cp.execFileSync(cmd, flags, options)
|
|
87
87
|
}
|
|
88
88
|
const cacheKey = getCacheKey(cmd, flags)
|
|
89
89
|
const cachedResult = getCache(cacheKey)
|
|
90
|
-
if (cachedResult !==
|
|
90
|
+
if (cachedResult !== undefined) {
|
|
91
91
|
if (cachedResult.startsWith('__GIT_COMMAND_FAILED__')) {
|
|
92
92
|
let error
|
|
93
93
|
try {
|
|
@@ -37,6 +37,8 @@ const {
|
|
|
37
37
|
const { filterSensitiveInfoFromRepository } = require('./url')
|
|
38
38
|
const { cachedExec } = require('./git-cache')
|
|
39
39
|
|
|
40
|
+
const legacyStorage = storage('legacy')
|
|
41
|
+
|
|
40
42
|
const GIT_REV_LIST_MAX_BUFFER = 12 * 1024 * 1024 // 12MB
|
|
41
43
|
|
|
42
44
|
function sanitizedExec (
|
|
@@ -47,7 +49,7 @@ function sanitizedExec (
|
|
|
47
49
|
errorMetric,
|
|
48
50
|
shouldTrim = true
|
|
49
51
|
) {
|
|
50
|
-
return
|
|
52
|
+
return legacyStorage.run({ noop: true }, () => {
|
|
51
53
|
let startTime
|
|
52
54
|
if (operationMetric) {
|
|
53
55
|
incrementCountMetric(operationMetric.name, operationMetric.tags)
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { extractPathFromUrl } = require('./url')
|
|
4
|
+
|
|
5
|
+
// OpenTelemetry HTTP semantic-convention attribute names, emitted in place of
|
|
6
|
+
// the Datadog ones when `DD_TRACE_OTEL_SEMANTICS_ENABLED` is set.
|
|
7
|
+
// See https://opentelemetry.io/docs/specs/semconv/http/http-spans/
|
|
8
|
+
const HTTP_REQUEST_METHOD = 'http.request.method'
|
|
9
|
+
const HTTP_RESPONSE_STATUS_CODE = 'http.response.status_code'
|
|
10
|
+
const URL_FULL = 'url.full'
|
|
11
|
+
const URL_PATH = 'url.path'
|
|
12
|
+
const URL_SCHEME = 'url.scheme'
|
|
13
|
+
const URL_QUERY = 'url.query'
|
|
14
|
+
const SERVER_ADDRESS = 'server.address'
|
|
15
|
+
const SERVER_PORT = 'server.port'
|
|
16
|
+
const USER_AGENT_ORIGINAL = 'user_agent.original'
|
|
17
|
+
const CLIENT_ADDRESS = 'client.address'
|
|
18
|
+
const NETWORK_PEER_ADDRESS = 'network.peer.address'
|
|
19
|
+
const HTTP_REQUEST_METHOD_ORIGINAL = 'http.request.method_original'
|
|
20
|
+
|
|
21
|
+
// Known HTTP methods (RFC 9110 + PATCH RFC 5789 + QUERY httpbis draft). A verb
|
|
22
|
+
// outside this set is reported as `_OTHER` with the raw value preserved on
|
|
23
|
+
// `http.request.method_original`, per the OTel HTTP semantic conventions.
|
|
24
|
+
const KNOWN_METHODS = new Set([
|
|
25
|
+
'CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'QUERY', 'TRACE',
|
|
26
|
+
])
|
|
27
|
+
|
|
28
|
+
// Datadog HTTP meta keys replaced by OTel names — omitted when rebuilding meta.
|
|
29
|
+
const DD_HTTP_META_KEYS = new Set([
|
|
30
|
+
'http.method', 'http.status_code', 'http.useragent', 'http.client_ip', 'http.endpoint', 'http.url', 'out.host',
|
|
31
|
+
])
|
|
32
|
+
const NETWORK_DESTINATION_PORT = 'network.destination.port'
|
|
33
|
+
|
|
34
|
+
// IPv6 literals arrive bracketed (URL.hostname / out.host = `[::1]`); OTel
|
|
35
|
+
// `server.address` is the bare address.
|
|
36
|
+
function stripIpv6Brackets (host) {
|
|
37
|
+
return host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {object} ServerUrlParts
|
|
42
|
+
* @property {string} [scheme] value for `url.scheme`
|
|
43
|
+
* @property {string} [address] value for `server.address`
|
|
44
|
+
* @property {number} [port] value for `server.port`
|
|
45
|
+
* @property {string} path value for `url.path`
|
|
46
|
+
* @property {string} [query] value for `url.query` (omitted when empty)
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Decompose a server request URL into the OpenTelemetry `url.*` / `server.*`
|
|
51
|
+
* parts. Structural fields (scheme, address, port, path) are read from the raw
|
|
52
|
+
* URL; the query is taken from the already-obfuscated URL so the configured
|
|
53
|
+
* query-string obfuscation is preserved.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} rawUrl full request URL (`scheme://host[:port]/path?query`)
|
|
56
|
+
* @param {string} obfuscatedUrl same URL with its query string obfuscated
|
|
57
|
+
* @returns {ServerUrlParts}
|
|
58
|
+
*/
|
|
59
|
+
function decomposeServerUrl (rawUrl, obfuscatedUrl) {
|
|
60
|
+
let scheme
|
|
61
|
+
let address
|
|
62
|
+
let port
|
|
63
|
+
let path
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const parsed = new URL(rawUrl)
|
|
67
|
+
scheme = parsed.protocol.length > 1 ? parsed.protocol.slice(0, -1) : undefined
|
|
68
|
+
// `extractURL` builds `http://undefined/...` when the Host header is absent; skip that.
|
|
69
|
+
const hostname = parsed.hostname
|
|
70
|
+
if (hostname && hostname !== 'undefined') {
|
|
71
|
+
address = stripIpv6Brackets(hostname)
|
|
72
|
+
}
|
|
73
|
+
if (parsed.port) {
|
|
74
|
+
const parsedPort = Number.parseInt(parsed.port)
|
|
75
|
+
if (parsedPort > 0) port = parsedPort
|
|
76
|
+
}
|
|
77
|
+
path = parsed.pathname || '/'
|
|
78
|
+
} catch {
|
|
79
|
+
// Malformed or relative URL: fall back to a best-effort path only.
|
|
80
|
+
path = extractPathFromUrl(rawUrl)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let query
|
|
84
|
+
const queryIndex = obfuscatedUrl.indexOf('?')
|
|
85
|
+
if (queryIndex !== -1) {
|
|
86
|
+
const rawQuery = obfuscatedUrl.slice(queryIndex + 1)
|
|
87
|
+
if (rawQuery) query = rawQuery
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return { scheme, address, port, path, query }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const ERROR_TYPE = 'error.type'
|
|
94
|
+
|
|
95
|
+
function toHttpScheme (scheme) {
|
|
96
|
+
if (scheme === 'ws') return 'http'
|
|
97
|
+
if (scheme === 'wss') return 'https'
|
|
98
|
+
return scheme
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Redact any userinfo embedded in a URL's authority, since `url.full` must not
|
|
103
|
+
* leak credentials: `user:pass@host` -> `REDACTED:REDACTED@host`, `user@host` ->
|
|
104
|
+
* `REDACTED@host`. Returns the URL unchanged when no userinfo is present.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} url
|
|
107
|
+
* @returns {string}
|
|
108
|
+
*/
|
|
109
|
+
function redactUrlCredentials (url) {
|
|
110
|
+
const schemeEnd = url.indexOf('://')
|
|
111
|
+
if (schemeEnd === -1) return url
|
|
112
|
+
const authorityStart = schemeEnd + 3
|
|
113
|
+
|
|
114
|
+
let authorityEnd = url.length
|
|
115
|
+
for (let i = authorityStart; i < url.length; i++) {
|
|
116
|
+
const char = url[i]
|
|
117
|
+
if (char === '/' || char === '?' || char === '#') {
|
|
118
|
+
authorityEnd = i
|
|
119
|
+
break
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// userinfo runs to the LAST '@' in the authority (WHATWG); using the first
|
|
124
|
+
// '@' would leak the remainder, e.g. `user:p@ss@host`.
|
|
125
|
+
const at = url.lastIndexOf('@', authorityEnd - 1)
|
|
126
|
+
if (at < authorityStart) return url
|
|
127
|
+
|
|
128
|
+
const redacted = url.slice(authorityStart, at).includes(':') ? 'REDACTED:REDACTED' : 'REDACTED'
|
|
129
|
+
return url.slice(0, authorityStart) + redacted + url.slice(at)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The scheme's default port, used as the `server.port` fallback for client spans
|
|
134
|
+
* (the attribute is required for clients but the explicit port is absent for
|
|
135
|
+
* default-port requests).
|
|
136
|
+
*
|
|
137
|
+
* @param {string} [url]
|
|
138
|
+
* @returns {number | undefined}
|
|
139
|
+
*/
|
|
140
|
+
function defaultPortForUrl (url) {
|
|
141
|
+
if (url === undefined) return
|
|
142
|
+
if (url.startsWith('https:') || url.startsWith('wss:')) return 443
|
|
143
|
+
if (url.startsWith('http:') || url.startsWith('ws:')) return 80
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @typedef {object} FormattedHttpSpan
|
|
148
|
+
* @property {Record<string, string>} meta
|
|
149
|
+
* @property {Record<string, number>} metrics
|
|
150
|
+
* @property {number} error
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Rewrite a formatted span's Datadog HTTP tags to OpenTelemetry HTTP
|
|
155
|
+
* semantic-convention names, in place. Called at serialization time (from
|
|
156
|
+
* `span_format`) when `DD_TRACE_OTEL_SEMANTICS_ENABLED` is set, so every HTTP
|
|
157
|
+
* integration is covered from one place. No-op for non-HTTP spans. The span
|
|
158
|
+
* keeps the Datadog tag names throughout its lifetime — only the serialized
|
|
159
|
+
* output is renamed — so runtime consumers (peer.service, AppSec, trace stats)
|
|
160
|
+
* are unaffected.
|
|
161
|
+
*
|
|
162
|
+
* @param {FormattedHttpSpan} formattedSpan
|
|
163
|
+
*/
|
|
164
|
+
function applyHttpOtelSemantics (formattedSpan) {
|
|
165
|
+
const meta = formattedSpan.meta
|
|
166
|
+
const metrics = formattedSpan.metrics
|
|
167
|
+
const method = meta['http.method']
|
|
168
|
+
const url = meta['http.url']
|
|
169
|
+
if (method === undefined && url === undefined) return
|
|
170
|
+
|
|
171
|
+
// Rebuild meta/metrics as fresh objects that omit the renamed Datadog HTTP
|
|
172
|
+
// keys. Deleting them in place demotes the formatted span to V8 dictionary
|
|
173
|
+
// mode (~40% slower than this rebuild, measured); a fresh object keeps fast
|
|
174
|
+
// properties and can't leak a renamed key as `undefined` on the OTLP path.
|
|
175
|
+
const newMeta = {}
|
|
176
|
+
for (const key of Object.keys(meta)) {
|
|
177
|
+
if (!DD_HTTP_META_KEYS.has(key)) newMeta[key] = meta[key]
|
|
178
|
+
}
|
|
179
|
+
const newMetrics = {}
|
|
180
|
+
for (const key of Object.keys(metrics)) {
|
|
181
|
+
if (key !== NETWORK_DESTINATION_PORT) newMetrics[key] = metrics[key]
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const kind = meta['span.kind']
|
|
185
|
+
|
|
186
|
+
if (method !== undefined) {
|
|
187
|
+
if (KNOWN_METHODS.has(method)) {
|
|
188
|
+
newMeta[HTTP_REQUEST_METHOD] = method
|
|
189
|
+
} else {
|
|
190
|
+
// Unknown verb: bucket to `_OTHER`, preserve the raw value, and use the
|
|
191
|
+
// literal "HTTP" in the span name (the spec forbids the URL path there).
|
|
192
|
+
// Known-method names are already `{method} {route}`.
|
|
193
|
+
newMeta[HTTP_REQUEST_METHOD] = '_OTHER'
|
|
194
|
+
newMeta[HTTP_REQUEST_METHOD_ORIGINAL] = method
|
|
195
|
+
const resource = formattedSpan.resource
|
|
196
|
+
if (typeof resource === 'string') {
|
|
197
|
+
if (resource === method) {
|
|
198
|
+
formattedSpan.resource = 'HTTP'
|
|
199
|
+
} else if (resource.startsWith(`${method} `)) {
|
|
200
|
+
formattedSpan.resource = `HTTP${resource.slice(method.length)}`
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const status = meta['http.status_code']
|
|
207
|
+
let statusCode
|
|
208
|
+
if (status !== undefined) {
|
|
209
|
+
// OTel types http.response.status_code as an int, so emit it as a numeric
|
|
210
|
+
// metric (the OTLP exporter serializes meta as stringValue but metrics as
|
|
211
|
+
// intValue) — mirroring how server.port is handled below. Guard against a
|
|
212
|
+
// non-numeric status, which would otherwise write a NaN metric.
|
|
213
|
+
statusCode = Number.parseInt(status)
|
|
214
|
+
if (Number.isFinite(statusCode)) newMetrics[HTTP_RESPONSE_STATUS_CODE] = statusCode
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const userAgent = meta['http.useragent']
|
|
218
|
+
if (userAgent !== undefined) newMeta[USER_AGENT_ORIGINAL] = userAgent
|
|
219
|
+
|
|
220
|
+
const clientIp = meta['http.client_ip']
|
|
221
|
+
if (clientIp !== undefined) newMeta[CLIENT_ADDRESS] = clientIp
|
|
222
|
+
|
|
223
|
+
// http.endpoint is Datadog-only (omitted above); it has no OTel equivalent.
|
|
224
|
+
|
|
225
|
+
if (kind === 'server') {
|
|
226
|
+
// FIXME: some server frameworks (e.g. Next.js — `packages/datadog-plugin-next`)
|
|
227
|
+
// never populate `http.url`, so the OTel `url.*` / `server.*` attributes below
|
|
228
|
+
// can't be derived and are omitted for those spans. This needs a fix; the
|
|
229
|
+
// short-term option is to set `http.url` in those integrations so they emit
|
|
230
|
+
// the full server attribute set.
|
|
231
|
+
if (url !== undefined) {
|
|
232
|
+
// The query in `http.url` is already obfuscated per config, so it is preserved.
|
|
233
|
+
const { scheme, address, port, path, query } = decomposeServerUrl(url, url)
|
|
234
|
+
if (path !== undefined) newMeta[URL_PATH] = path
|
|
235
|
+
if (scheme !== undefined) newMeta[URL_SCHEME] = toHttpScheme(scheme)
|
|
236
|
+
if (query !== undefined) newMeta[URL_QUERY] = query
|
|
237
|
+
if (address !== undefined) newMeta[SERVER_ADDRESS] = address
|
|
238
|
+
if (port !== undefined) newMetrics[SERVER_PORT] = port
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
if (url !== undefined) {
|
|
242
|
+
// url.full must not carry embedded credentials.
|
|
243
|
+
newMeta[URL_FULL] = redactUrlCredentials(url)
|
|
244
|
+
}
|
|
245
|
+
const outHost = meta['out.host']
|
|
246
|
+
if (outHost !== undefined) newMeta[SERVER_ADDRESS] = stripIpv6Brackets(outHost)
|
|
247
|
+
const clientPort = metrics[NETWORK_DESTINATION_PORT]
|
|
248
|
+
if (clientPort === undefined) {
|
|
249
|
+
// server.port is required for client spans; fall back to the scheme default.
|
|
250
|
+
const defaultPort = defaultPortForUrl(url)
|
|
251
|
+
if (defaultPort !== undefined) newMetrics[SERVER_PORT] = defaultPort
|
|
252
|
+
} else {
|
|
253
|
+
newMetrics[SERVER_PORT] = clientPort
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// OTel error semantics for an error response (no-clobber on an exception-derived
|
|
258
|
+
// type): server spans are errors on 5xx only (4xx MUST be left unset per the
|
|
259
|
+
// spec); client spans on any status >= 400.
|
|
260
|
+
if (status !== undefined && newMeta[ERROR_TYPE] === undefined) {
|
|
261
|
+
const isError = kind === 'server' ? statusCode >= 500 : statusCode >= 400
|
|
262
|
+
if (isError) {
|
|
263
|
+
newMeta[ERROR_TYPE] = status
|
|
264
|
+
formattedSpan.error = 1
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
formattedSpan.meta = newMeta
|
|
269
|
+
formattedSpan.metrics = newMetrics
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
module.exports = {
|
|
273
|
+
NETWORK_PEER_ADDRESS, // imported by web.js (set from req.socket, not at serialization)
|
|
274
|
+
decomposeServerUrl, // exercised directly by the helper spec
|
|
275
|
+
applyHttpOtelSemantics,
|
|
276
|
+
}
|
|
@@ -37,7 +37,12 @@ function isPromptCompletionSampled (sampler, span) {
|
|
|
37
37
|
|
|
38
38
|
module.exports = function makeUtilities (integrationName, tracerConfig) {
|
|
39
39
|
const integrationConfig = tracerConfig[integrationName] || {}
|
|
40
|
-
|
|
40
|
+
// The per-integration config is keyed by the canonical environment variable
|
|
41
|
+
// names (e.g. `DD_LANGCHAIN_SPAN_CHAR_LIMIT`), nested under the integration's
|
|
42
|
+
// namespace. Derive those leaf names from the integration name.
|
|
43
|
+
const prefix = `DD_${integrationName.toUpperCase()}_`
|
|
44
|
+
const spanCharLimit = integrationConfig[`${prefix}SPAN_CHAR_LIMIT`]
|
|
45
|
+
const spanPromptCompletionSampleRate = integrationConfig[`${prefix}SPAN_PROMPT_COMPLETION_SAMPLE_RATE`]
|
|
41
46
|
|
|
42
47
|
const sampler = new Sampler(spanPromptCompletionSampleRate ?? 1)
|
|
43
48
|
|
|
@@ -14,7 +14,7 @@ const NODE_MODULES_PATTERN_START = `node_modules${sep}`
|
|
|
14
14
|
* In production, these frames are already filtered by isNodeModulesFrame.
|
|
15
15
|
*/
|
|
16
16
|
const SHOULD_FILTER_DD_TRACE_INSTRUMENTAION = __filename.endsWith(
|
|
17
|
-
join(
|
|
17
|
+
join('packages', 'dd-trace', 'src', 'plugins', 'util', 'stacktrace.js')
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
@@ -46,7 +46,7 @@ function getCallSites (constructorOpt) {
|
|
|
46
46
|
* Get stack trace of user-land frames.
|
|
47
47
|
*
|
|
48
48
|
* @param {string} stack - The stack trace to parse
|
|
49
|
-
* @param {number} [limit
|
|
49
|
+
* @param {number} [limit] - The maximum number of frames to return
|
|
50
50
|
* @returns {StackFrame[]} - A list of stack frames from user-land code
|
|
51
51
|
*/
|
|
52
52
|
function parseUserLandFrames (stack, limit = Infinity) {
|