@depup/dd-trace 5.96.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 +349 -244
- package/index.electron.js +3 -0
- package/initialize.mjs +9 -8
- package/loader-hook.mjs +154 -47
- package/package.json +121 -79
- package/packages/datadog-core/src/storage.js +47 -48
- package/packages/datadog-esbuild/index.js +52 -10
- 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 +22 -32
- 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 +50 -6
- package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +19 -0
- package/packages/datadog-instrumentations/src/cucumber.js +751 -188
- package/packages/datadog-instrumentations/src/cypress-config.js +432 -0
- package/packages/datadog-instrumentations/src/cypress.js +88 -4
- package/packages/datadog-instrumentations/src/dns.js +61 -61
- 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 +56 -34
- 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 +47 -47
- 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/bundler-register.js +41 -13
- 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 +34 -6
- package/packages/datadog-instrumentations/src/helpers/hooks.js +24 -19
- package/packages/datadog-instrumentations/src/helpers/instrument.js +61 -14
- 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 +109 -146
- 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 +50 -27
- package/packages/datadog-instrumentations/src/http/server.js +77 -34
- package/packages/datadog-instrumentations/src/http2/client.js +16 -15
- package/packages/datadog-instrumentations/src/http2/server.js +156 -25
- 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 +1795 -404
- 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 +5 -5
- 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 -128
- 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 +21 -19
- 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 +26 -42
- package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
- package/packages/datadog-instrumentations/src/playwright.js +1090 -351
- package/packages/datadog-instrumentations/src/prisma.js +1 -2
- 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 +5 -3
- package/packages/datadog-instrumentations/src/sequelize.js +1 -1
- package/packages/datadog-instrumentations/src/stripe.js +47 -33
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/url.js +1 -3
- 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 -1258
- package/packages/datadog-instrumentations/src/vm.js +1 -3
- 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 +90 -53
- 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 -24
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +1018 -97
- 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 +136 -68
- package/packages/datadog-plugin-jest/src/util.js +37 -16
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +31 -4
- 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 -17
- 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 +14 -18
- package/packages/datadog-plugin-openai/src/services.js +5 -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 +20 -4
- 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 -34
- 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 +151 -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 +84 -41
- 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/iast-plugin.js +1 -1
- 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 +32 -5
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +84 -49
- 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/remote_config.js +1 -0
- 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/index.js +4 -0
- 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 +36 -6
- 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 +9 -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 +341 -144
- package/packages/dd-trace/src/config/generated-config-types.d.ts +679 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +183 -28
- package/packages/dd-trace/src/config/index.js +565 -1515
- 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 +384 -0
- package/packages/dd-trace/src/config/remote_config.js +59 -2
- package/packages/dd-trace/src/config/supported-configurations.json +638 -530
- package/packages/dd-trace/src/constants.js +15 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +25 -7
- package/packages/dd-trace/src/crashtracking/index.js +1 -7
- 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 +14 -10
- 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 +45 -36
- package/packages/dd-trace/src/encode/0.4.js +830 -269
- 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 +8 -3
- 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 +55 -26
- 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 +29 -3
- 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 +7 -4
- package/packages/dd-trace/src/id.js +46 -27
- package/packages/dd-trace/src/index.js +6 -4
- 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 +41 -8
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -391
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +178 -18
- 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 +92 -38
- 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 +66 -41
- package/packages/dd-trace/src/llmobs/span_processor.js +91 -12
- package/packages/dd-trace/src/llmobs/tagger.js +135 -7
- 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 +13 -5
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +4 -2
- package/packages/dd-trace/src/log/index.js +28 -69
- package/packages/dd-trace/src/log/writer.js +10 -20
- 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 +13 -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 +7 -7
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +62 -13
- 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 +280 -145
- 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 +8 -7
- package/packages/dd-trace/src/plugin_manager.js +44 -20
- package/packages/dd-trace/src/plugins/apollo.js +3 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +391 -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 +22 -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/process-tags/index.js +3 -0
- package/packages/dd-trace/src/profiler.js +27 -2
- package/packages/dd-trace/src/profiling/config.js +145 -393
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -13
- package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +50 -15
- 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 +123 -132
- 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 -14
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
- package/packages/dd-trace/src/profiling/profilers/wall.js +136 -39
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +7 -4
- package/packages/dd-trace/src/propagation-hash/index.js +3 -2
- package/packages/dd-trace/src/proxy.js +82 -39
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +9 -5
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/require-package-json.js +8 -4
- package/packages/dd-trace/src/ritm.js +63 -28
- package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +17 -4
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +45 -41
- package/packages/dd-trace/src/sampler.js +1 -1
- 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 +6 -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 -3
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +25 -39
- package/packages/dd-trace/src/telemetry/session-propagation.js +20 -45
- package/packages/dd-trace/src/telemetry/telemetry.js +42 -183
- 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 -9
- 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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const OtlpHttpExporterBase = require('../otlp/otlp_http_exporter_base')
|
|
4
|
+
const { SAMPLING_PRIORITY_KEY } = require('../../constants')
|
|
5
|
+
const { AUTO_KEEP } = require('../../../../../ext/priority')
|
|
6
|
+
const OtlpTraceTransformer = require('./otlp_transformer')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* OtlpHttpTraceExporter exports DD-formatted spans via OTLP over HTTP/JSON.
|
|
10
|
+
*
|
|
11
|
+
* This implementation follows the OTLP HTTP specification:
|
|
12
|
+
* https://opentelemetry.io/docs/specs/otlp/#otlphttp
|
|
13
|
+
*
|
|
14
|
+
* It receives DD-formatted spans (from span_format.js), transforms them
|
|
15
|
+
* to OTLP ExportTraceServiceRequest JSON format, and sends them to the
|
|
16
|
+
* configured OTLP endpoint via HTTP POST.
|
|
17
|
+
*
|
|
18
|
+
* TODO: Add batch handling similar to the OpenTelemetry SDK Batch Processor
|
|
19
|
+
* (https://opentelemetry.io/docs/specs/otel/trace/sdk/#batching-processor).
|
|
20
|
+
* Currently each finished trace is sent as its own HTTP request, which is
|
|
21
|
+
* unsuitable for high-traffic production environments. The config values
|
|
22
|
+
* `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE`, and `OTEL_BSP_MAX_QUEUE_SIZE`
|
|
23
|
+
* (OTEL_BSP_*) are already defined and should drive that implementation.
|
|
24
|
+
*
|
|
25
|
+
* @class OtlpHttpTraceExporter
|
|
26
|
+
* @augments OtlpHttpExporterBase
|
|
27
|
+
*/
|
|
28
|
+
class OtlpHttpTraceExporter extends OtlpHttpExporterBase {
|
|
29
|
+
#transformer
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new OtlpHttpTraceExporter instance.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} url - OTLP endpoint URL
|
|
35
|
+
* @param {Record<string, string>|undefined} headers - Additional HTTP headers parsed from the
|
|
36
|
+
* corresponding `OTEL_EXPORTER_OTLP_*_HEADERS` env by the MAP parser.
|
|
37
|
+
* @param {number} timeout - Request timeout in milliseconds
|
|
38
|
+
* @param {import('@opentelemetry/api').Attributes} resourceAttributes - Resource attributes
|
|
39
|
+
* @param {boolean} otelTraceSemanticsEnabled - When true, do not emit Datadog-only attributes as span attributes
|
|
40
|
+
*/
|
|
41
|
+
constructor (url, headers, timeout, resourceAttributes, otelTraceSemanticsEnabled) {
|
|
42
|
+
super(url, headers, timeout, 'http/json', 'traces')
|
|
43
|
+
this.#transformer = new OtlpTraceTransformer(resourceAttributes, otelTraceSemanticsEnabled)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Exports DD-formatted spans via OTLP over HTTP.
|
|
48
|
+
*
|
|
49
|
+
* @param {import('./otlp_transformer').DDFormattedSpan[]} spans - Array of DD-formatted spans to export
|
|
50
|
+
* @returns {void}
|
|
51
|
+
*/
|
|
52
|
+
export (spans) {
|
|
53
|
+
if (spans.length === 0) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Drop unsampled traces — OTLP endpoints have no agent-side sampling.
|
|
58
|
+
const priority = spans[0]?.metrics?.[SAMPLING_PRIORITY_KEY]
|
|
59
|
+
if (priority !== undefined && priority < AUTO_KEEP) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const additionalTags = [`spans:${spans.length}`]
|
|
64
|
+
this.recordTelemetry('otel.traces_export_attempts', 1, additionalTags)
|
|
65
|
+
|
|
66
|
+
const payload = this.#transformer.transformSpans(spans)
|
|
67
|
+
this.sendPayload(payload, (result) => {
|
|
68
|
+
if (result.code === 0) {
|
|
69
|
+
this.recordTelemetry('otel.traces_export_successes', 1, additionalTags)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = OtlpHttpTraceExporter
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const OtlpTransformerBase = require('../otlp/otlp_transformer_base')
|
|
4
|
+
const { getProtobufTypes } = require('../otlp/protobuf_loader')
|
|
5
|
+
const { VERSION } = require('../../../../../version')
|
|
6
|
+
const id = require('../../id')
|
|
7
|
+
const { eventTimeNano } = require('../../encode/tags-processors')
|
|
8
|
+
|
|
9
|
+
const { protoSpanKind } = getProtobufTypes()
|
|
10
|
+
const SPAN_KIND_UNSPECIFIED = protoSpanKind.values.SPAN_KIND_UNSPECIFIED
|
|
11
|
+
const SPAN_KIND_INTERNAL = protoSpanKind.values.SPAN_KIND_INTERNAL
|
|
12
|
+
const SPAN_KIND_SERVER = protoSpanKind.values.SPAN_KIND_SERVER
|
|
13
|
+
const SPAN_KIND_CLIENT = protoSpanKind.values.SPAN_KIND_CLIENT
|
|
14
|
+
const SPAN_KIND_PRODUCER = protoSpanKind.values.SPAN_KIND_PRODUCER
|
|
15
|
+
const SPAN_KIND_CONSUMER = protoSpanKind.values.SPAN_KIND_CONSUMER
|
|
16
|
+
|
|
17
|
+
// Cached zero Identifier used to detect zero IDs without re-allocating per span.
|
|
18
|
+
const ZERO_ID = id('0')
|
|
19
|
+
|
|
20
|
+
// DD propagation tag carrying the upper 64 bits of a 128-bit trace ID as 16 hex chars.
|
|
21
|
+
// span_format.js#extractChunkTags only copies this onto the first-in-chunk span, so the
|
|
22
|
+
// transformer scans the batch to find it and applies it to every span's traceId.
|
|
23
|
+
const TRACE_ID_128 = '_dd.p.tid'
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {import('../../id').Identifier} Identifier
|
|
27
|
+
*
|
|
28
|
+
* @typedef {object} DDSpanLink
|
|
29
|
+
* @property {string} trace_id - Hex-encoded trace ID
|
|
30
|
+
* @property {string} span_id - Hex-encoded span ID
|
|
31
|
+
* @property {Record<string, string | number | boolean>} [attributes] - Link attributes
|
|
32
|
+
* @property {number} [flags] - Trace flags
|
|
33
|
+
* @property {string} [tracestate] - W3C trace state
|
|
34
|
+
*
|
|
35
|
+
* @typedef {object} DDSpanEvent
|
|
36
|
+
* @property {string} name - Event name
|
|
37
|
+
* @property {number} startTime - Event start time in milliseconds (sub-ms precision)
|
|
38
|
+
* @property {Record<string, string | number | boolean>} [attributes] - Event attributes
|
|
39
|
+
*
|
|
40
|
+
* @typedef {object} DDFormattedSpan
|
|
41
|
+
* @property {Identifier} trace_id - DD Identifier for trace ID
|
|
42
|
+
* @property {Identifier} span_id - DD Identifier for span ID
|
|
43
|
+
* @property {Identifier} parent_id - DD Identifier for parent span ID
|
|
44
|
+
* @property {string} name - Span operation name
|
|
45
|
+
* @property {string} resource - Resource name
|
|
46
|
+
* @property {string} [service] - Service name
|
|
47
|
+
* @property {string} [type] - Span type
|
|
48
|
+
* @property {number} error - Error flag (0 or 1)
|
|
49
|
+
* @property {{[key: string]: string}} meta - String key-value tags
|
|
50
|
+
* @property {{[key: string]: number}} metrics - Numeric key-value tags
|
|
51
|
+
* @property {{[key: string]: object}} [meta_struct] - Structured tags (JSON-serialized, bytes in protobuf)
|
|
52
|
+
* @property {number} start - Start time in nanoseconds since epoch
|
|
53
|
+
* @property {number} duration - Duration in nanoseconds
|
|
54
|
+
* @property {DDSpanEvent[]} [span_events] - Span events
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
// Map DD span.kind string values to OTLP SpanKind numeric values
|
|
58
|
+
const SPAN_KIND_MAP = {
|
|
59
|
+
internal: SPAN_KIND_INTERNAL,
|
|
60
|
+
server: SPAN_KIND_SERVER,
|
|
61
|
+
client: SPAN_KIND_CLIENT,
|
|
62
|
+
producer: SPAN_KIND_PRODUCER,
|
|
63
|
+
consumer: SPAN_KIND_CONSUMER,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// OTLP StatusCode values (from trace.proto Status.StatusCode enum)
|
|
67
|
+
const STATUS_CODE_UNSET = 0
|
|
68
|
+
const STATUS_CODE_ERROR = 2
|
|
69
|
+
|
|
70
|
+
// DD meta keys that are mapped to dedicated OTLP span fields and should not appear as attributes
|
|
71
|
+
const EXCLUDED_META_KEYS = new Set([
|
|
72
|
+
'_dd.span_links',
|
|
73
|
+
'span.kind',
|
|
74
|
+
TRACE_ID_128,
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
// DD-only error tags that should not appear as attributes when OTel trace semantics are enabled.
|
|
78
|
+
const DD_ERROR_META_KEYS = new Set(['error.message'])
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* OtlpTraceTransformer transforms DD-formatted spans to OTLP trace JSON format.
|
|
82
|
+
*
|
|
83
|
+
* This implementation follows the OTLP trace data model:
|
|
84
|
+
* https://opentelemetry.io/docs/specs/otlp/#trace-data-model
|
|
85
|
+
*
|
|
86
|
+
* It receives DD-formatted spans (from span_format.js) and produces
|
|
87
|
+
* an ExportTraceServiceRequest serialized as JSON (http/json protocol only).
|
|
88
|
+
*
|
|
89
|
+
* @class OtlpTraceTransformer
|
|
90
|
+
* @augments OtlpTransformerBase
|
|
91
|
+
*/
|
|
92
|
+
class OtlpTraceTransformer extends OtlpTransformerBase {
|
|
93
|
+
#otelTraceSemanticsEnabled
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new OtlpTraceTransformer instance.
|
|
97
|
+
*
|
|
98
|
+
* @param {import('@opentelemetry/api').Attributes} resourceAttributes - Resource attributes
|
|
99
|
+
* @param {boolean} [otelTraceSemanticsEnabled] - When true, do not emit Datadog-only attributes as span attributes
|
|
100
|
+
*/
|
|
101
|
+
constructor (resourceAttributes, otelTraceSemanticsEnabled) {
|
|
102
|
+
super(resourceAttributes, 'http/json', 'traces')
|
|
103
|
+
this.#otelTraceSemanticsEnabled = otelTraceSemanticsEnabled
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Transforms DD-formatted spans to OTLP JSON format.
|
|
108
|
+
*
|
|
109
|
+
* @param {DDFormattedSpan[]} spans - Array of DD-formatted spans to transform
|
|
110
|
+
* @returns {Buffer} JSON-encoded trace data
|
|
111
|
+
*/
|
|
112
|
+
transformSpans (spans) {
|
|
113
|
+
const traceData = {
|
|
114
|
+
resourceSpans: [{
|
|
115
|
+
resource: this.transformResource(),
|
|
116
|
+
scopeSpans: this.#transformScopeSpans(spans),
|
|
117
|
+
}],
|
|
118
|
+
}
|
|
119
|
+
return this.serializeToJson(traceData)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Creates scope spans. DD spans do not carry instrumentation scope info,
|
|
124
|
+
* so all spans are placed under a single default scope.
|
|
125
|
+
*
|
|
126
|
+
* @param {DDFormattedSpan[]} spans - Array of DD-formatted spans
|
|
127
|
+
* @returns {object[]} Array of scope span objects
|
|
128
|
+
*/
|
|
129
|
+
#transformScopeSpans (spans) {
|
|
130
|
+
let traceKey
|
|
131
|
+
let traceIdHigh
|
|
132
|
+
const otlpSpans = spans.map((span) => {
|
|
133
|
+
// `_dd.p.tid` lives only on the first-in-chunk span of each trace.
|
|
134
|
+
// Reset at each trace boundary for batching of multiple traces.
|
|
135
|
+
const key = span.trace_id.toString(16)
|
|
136
|
+
if (key !== traceKey) {
|
|
137
|
+
traceKey = key
|
|
138
|
+
traceIdHigh = span.meta?.[TRACE_ID_128]?.toLowerCase()
|
|
139
|
+
}
|
|
140
|
+
return this.#transformSpan(span, traceIdHigh)
|
|
141
|
+
})
|
|
142
|
+
return [{
|
|
143
|
+
scope: {
|
|
144
|
+
name: 'dd-trace-js',
|
|
145
|
+
version: VERSION,
|
|
146
|
+
attributes: [],
|
|
147
|
+
droppedAttributesCount: 0,
|
|
148
|
+
},
|
|
149
|
+
schemaUrl: '',
|
|
150
|
+
spans: otlpSpans,
|
|
151
|
+
}]
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Transforms a single DD-formatted span to an OTLP Span object.
|
|
156
|
+
*
|
|
157
|
+
* @param {DDFormattedSpan} span - DD-formatted span to transform
|
|
158
|
+
* @param {string | undefined} traceIdHigh - 16-char hex of the upper 64 bits of the trace ID
|
|
159
|
+
* @returns {object} OTLP Span object
|
|
160
|
+
*/
|
|
161
|
+
#transformSpan (span, traceIdHigh) {
|
|
162
|
+
const parentId = span.parent_id
|
|
163
|
+
const links = this.#extractLinks(span.meta?.['_dd.span_links'])
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
traceId: span.trace_id.toTraceIdHex(traceIdHigh).padStart(32, '0'),
|
|
167
|
+
spanId: this.#idToBytes(span.span_id, 8),
|
|
168
|
+
parentSpanId: (parentId && !parentId.equals(ZERO_ID)) ? this.#idToBytes(parentId, 8) : undefined,
|
|
169
|
+
name: span.resource,
|
|
170
|
+
kind: this.#mapSpanKind(span.meta?.['span.kind']),
|
|
171
|
+
startTimeUnixNano: span.start,
|
|
172
|
+
endTimeUnixNano: span.start + span.duration,
|
|
173
|
+
attributes: this.#buildAttributes(span),
|
|
174
|
+
droppedAttributesCount: 0,
|
|
175
|
+
events: span.span_events?.length ? span.span_events.map(event => this.#transformEvent(event)) : undefined,
|
|
176
|
+
droppedEventsCount: 0,
|
|
177
|
+
links: links.length ? links : undefined,
|
|
178
|
+
droppedLinksCount: 0,
|
|
179
|
+
status: this.#mapStatus(span),
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Builds OTLP attributes from DD span fields.
|
|
185
|
+
* Merges top-level DD fields (service, resource, type), meta (string tags),
|
|
186
|
+
* and metrics (numeric tags) into a single OTLP KeyValue array.
|
|
187
|
+
*
|
|
188
|
+
* @param {DDFormattedSpan} span - DD-formatted span
|
|
189
|
+
* @returns {object[]} Array of OTLP KeyValue objects
|
|
190
|
+
*/
|
|
191
|
+
#buildAttributes (span) {
|
|
192
|
+
const attributes = []
|
|
193
|
+
|
|
194
|
+
// Add top-level DD span fields as OTLP attributes.
|
|
195
|
+
// When OTel trace semantics are enabled, these Datadog-only concepts
|
|
196
|
+
// are not added to the span attributes so the output conforms to pure
|
|
197
|
+
// OpenTelemetry semantics.
|
|
198
|
+
if (!this.#otelTraceSemanticsEnabled) {
|
|
199
|
+
if (span.service) {
|
|
200
|
+
attributes.push({ key: 'service.name', value: { stringValue: span.service } })
|
|
201
|
+
}
|
|
202
|
+
if (span.name) {
|
|
203
|
+
attributes.push({ key: 'operation.name', value: { stringValue: span.name } })
|
|
204
|
+
}
|
|
205
|
+
if (span.resource) {
|
|
206
|
+
attributes.push({ key: 'resource.name', value: { stringValue: span.resource } })
|
|
207
|
+
}
|
|
208
|
+
if (span.type) {
|
|
209
|
+
attributes.push({ key: 'span.type', value: { stringValue: span.type } })
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Add meta string tags, skipping keys that map to dedicated OTLP fields
|
|
214
|
+
if (span.meta) {
|
|
215
|
+
for (const [key, value] of Object.entries(span.meta)) {
|
|
216
|
+
if (EXCLUDED_META_KEYS.has(key)) continue
|
|
217
|
+
if (this.#otelTraceSemanticsEnabled && DD_ERROR_META_KEYS.has(key)) continue
|
|
218
|
+
attributes.push({ key, value: { stringValue: value } })
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Add metrics as numeric attributes
|
|
223
|
+
if (span.metrics) {
|
|
224
|
+
for (const [key, value] of Object.entries(span.metrics)) {
|
|
225
|
+
if (Number.isInteger(value)) {
|
|
226
|
+
attributes.push({ key, value: { intValue: value } })
|
|
227
|
+
} else {
|
|
228
|
+
attributes.push({ key, value: { doubleValue: value } })
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// TODO: meta_struct values are logically raw bytes. The OTLP http/json spec encodes the bytesValue
|
|
234
|
+
// field as base64, but when http/protobuf or gRPC support is added the payload should be sent as
|
|
235
|
+
// raw bytes directly (no JSON.stringify + base64). The backend decoding side will need to be
|
|
236
|
+
// updated in parallel to accept the unencoded bytes.
|
|
237
|
+
if (span.meta_struct) {
|
|
238
|
+
for (const [key, value] of Object.entries(span.meta_struct)) {
|
|
239
|
+
const bytes = Buffer.from(JSON.stringify(value))
|
|
240
|
+
attributes.push({ key, value: { bytesValue: bytes.toString('base64') } })
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return attributes
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Maps a DD span.kind string to an OTLP SpanKind enum value.
|
|
249
|
+
*
|
|
250
|
+
* @param {string | undefined} kind - DD span kind string
|
|
251
|
+
* @returns {number} OTLP SpanKind enum value
|
|
252
|
+
*/
|
|
253
|
+
#mapSpanKind (kind) {
|
|
254
|
+
if (!kind) return SPAN_KIND_UNSPECIFIED
|
|
255
|
+
return SPAN_KIND_MAP[kind] ?? SPAN_KIND_UNSPECIFIED
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Maps DD span error state to an OTLP Status object.
|
|
260
|
+
* Combines error.type and error.message when both are present so error type
|
|
261
|
+
* information is preserved on the OTel side.
|
|
262
|
+
*
|
|
263
|
+
* @param {DDFormattedSpan} span - DD-formatted span
|
|
264
|
+
* @returns {object} OTLP Status object with code and message
|
|
265
|
+
*/
|
|
266
|
+
#mapStatus (span) {
|
|
267
|
+
if (span.error !== 1) {
|
|
268
|
+
return { code: STATUS_CODE_UNSET, message: '' }
|
|
269
|
+
}
|
|
270
|
+
const errorType = span.meta?.['error.type']
|
|
271
|
+
const errorMessage = span.meta?.['error.message']
|
|
272
|
+
let message = ''
|
|
273
|
+
if (errorType && errorMessage) {
|
|
274
|
+
message = `${errorType}: ${errorMessage}`
|
|
275
|
+
} else if (errorType) {
|
|
276
|
+
message = errorType
|
|
277
|
+
} else if (errorMessage) {
|
|
278
|
+
message = errorMessage
|
|
279
|
+
}
|
|
280
|
+
return { code: STATUS_CODE_ERROR, message }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Transforms a DD span event to an OTLP Event object.
|
|
285
|
+
*
|
|
286
|
+
* @param {DDSpanEvent} event - DD span event
|
|
287
|
+
* @returns {object} OTLP Event object
|
|
288
|
+
*/
|
|
289
|
+
#transformEvent (event) {
|
|
290
|
+
return {
|
|
291
|
+
timeUnixNano: eventTimeNano(event),
|
|
292
|
+
name: event.name || '',
|
|
293
|
+
attributes: this.transformAttributes(event.attributes ?? {}),
|
|
294
|
+
droppedAttributesCount: 0,
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Extracts and transforms span links from the DD _dd.span_links meta JSON string.
|
|
300
|
+
*
|
|
301
|
+
* @param {string | undefined} spanLinksJson - JSON-encoded array of DD span links
|
|
302
|
+
* @returns {object[]} Array of OTLP Link objects
|
|
303
|
+
*/
|
|
304
|
+
#extractLinks (spanLinksJson) {
|
|
305
|
+
if (!spanLinksJson) return []
|
|
306
|
+
|
|
307
|
+
let parsedLinks
|
|
308
|
+
try {
|
|
309
|
+
parsedLinks = JSON.parse(spanLinksJson)
|
|
310
|
+
} catch {
|
|
311
|
+
return []
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (!Array.isArray(parsedLinks)) return []
|
|
315
|
+
|
|
316
|
+
return parsedLinks.map(link => this.#transformLink(link))
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Transforms a single DD span link to an OTLP Link object.
|
|
321
|
+
*
|
|
322
|
+
* @param {DDSpanLink} link - DD span link
|
|
323
|
+
* @returns {object} OTLP Link object
|
|
324
|
+
*/
|
|
325
|
+
#transformLink (link) {
|
|
326
|
+
return {
|
|
327
|
+
traceId: this.#hexToBytes(link.trace_id, 16),
|
|
328
|
+
spanId: this.#hexToBytes(link.span_id, 8),
|
|
329
|
+
traceState: link.tracestate || '',
|
|
330
|
+
attributes: this.transformAttributes(link.attributes ?? {}),
|
|
331
|
+
droppedAttributesCount: 0,
|
|
332
|
+
flags: link.flags,
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Converts a DD Identifier object to a hex-encoded string of the specified byte length.
|
|
338
|
+
* Pads with leading zeros if the identifier buffer is shorter than the target.
|
|
339
|
+
* Per the OTLP http/json spec, trace-ids and span-ids must be hex-encoded strings.
|
|
340
|
+
*
|
|
341
|
+
* @param {Identifier} identifier - DD Identifier
|
|
342
|
+
* @param {number} targetLength - Target byte length (16 for trace ID, 8 for span ID)
|
|
343
|
+
* @returns {string} Hex-encoded string of the specified length
|
|
344
|
+
*/
|
|
345
|
+
#idToBytes (identifier, targetLength) {
|
|
346
|
+
const buffer = identifier.toBuffer()
|
|
347
|
+
if (buffer.length === targetLength) {
|
|
348
|
+
return Buffer.from(buffer).toString('hex')
|
|
349
|
+
}
|
|
350
|
+
if (buffer.length > targetLength) {
|
|
351
|
+
return Buffer.from(buffer.slice(buffer.length - targetLength)).toString('hex')
|
|
352
|
+
}
|
|
353
|
+
// Pad with leading zeros to reach target length.
|
|
354
|
+
const result = Buffer.alloc(targetLength)
|
|
355
|
+
Buffer.from(buffer).copy(result, targetLength - buffer.length)
|
|
356
|
+
return result.toString('hex')
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Normalizes a hex string to the specified byte length.
|
|
361
|
+
* Pads with leading zeros if the hex string is shorter than expected.
|
|
362
|
+
* Per the OTLP http/json spec, trace-ids and span-ids must be hex-encoded strings.
|
|
363
|
+
*
|
|
364
|
+
* @param {string | undefined} hexString - Hex string to normalize
|
|
365
|
+
* @param {number} targetLength - Target byte length
|
|
366
|
+
* @returns {string} Hex-encoded string of the specified length
|
|
367
|
+
*/
|
|
368
|
+
#hexToBytes (hexString, targetLength) {
|
|
369
|
+
if (!hexString) return '0'.repeat(targetLength * 2)
|
|
370
|
+
const cleanHex = hexString.startsWith('0x') ? hexString.slice(2) : hexString
|
|
371
|
+
return cleanHex.padStart(targetLength * 2, '0')
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
module.exports = OtlpTraceTransformer
|
|
@@ -3,49 +3,16 @@
|
|
|
3
3
|
const api = require('@opentelemetry/api')
|
|
4
4
|
const { sanitizeAttributes } = require('../../../../vendor/dist/@opentelemetry/core')
|
|
5
5
|
|
|
6
|
+
const tracer = require('../../')
|
|
7
|
+
|
|
6
8
|
const id = require('../id')
|
|
7
9
|
const log = require('../log')
|
|
8
|
-
const DatadogSpanContext = require('../opentracing/span_context')
|
|
9
10
|
const TextMapPropagator = require('../opentracing/propagation/text_map')
|
|
10
11
|
const TraceState = require('../opentracing/propagation/tracestate')
|
|
11
12
|
const SpanContext = require('./span_context')
|
|
12
13
|
const Span = require('./span')
|
|
13
14
|
const Sampler = require('./sampler')
|
|
14
|
-
|
|
15
|
-
function normalizeLinkContext (context) {
|
|
16
|
-
if (!context) return
|
|
17
|
-
|
|
18
|
-
// OTel API bridge SpanContext wrapper
|
|
19
|
-
if (context._ddContext) return context._ddContext
|
|
20
|
-
|
|
21
|
-
// Datadog span context
|
|
22
|
-
if (typeof context.toTraceId === 'function' && typeof context.toSpanId === 'function') {
|
|
23
|
-
return context
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Standard OTel SpanContext (traceId/spanId)
|
|
27
|
-
if (typeof context.traceId !== 'string' || typeof context.spanId !== 'string') {
|
|
28
|
-
// Invalid
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let sampling
|
|
33
|
-
if (typeof context.traceFlags === 'number') {
|
|
34
|
-
sampling = { priority: context.traceFlags & 1 }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let tracestate
|
|
38
|
-
if (context.traceState?.serialize) {
|
|
39
|
-
tracestate = TraceState.fromString(context.traceState.serialize())
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return new DatadogSpanContext({
|
|
43
|
-
traceId: id(context.traceId, 16),
|
|
44
|
-
spanId: id(context.spanId, 16),
|
|
45
|
-
sampling,
|
|
46
|
-
tracestate,
|
|
47
|
-
})
|
|
48
|
-
}
|
|
15
|
+
const { normalizeLinkContext } = require('./span-helpers')
|
|
49
16
|
|
|
50
17
|
class Tracer {
|
|
51
18
|
constructor (library, config, tracerProvider) {
|
|
@@ -81,10 +48,10 @@ class Tracer {
|
|
|
81
48
|
}
|
|
82
49
|
|
|
83
50
|
_convertOtelContextToDatadog (traceId, spanId, traceFlag, ts, meta = {}) {
|
|
84
|
-
|
|
51
|
+
let origin = null
|
|
85
52
|
let samplingPriority = traceFlag
|
|
86
53
|
|
|
87
|
-
ts = ts?.traceparent
|
|
54
|
+
ts = ts?.traceparent
|
|
88
55
|
|
|
89
56
|
if (ts) {
|
|
90
57
|
// Use TraceState.fromString to parse the tracestate header
|
|
@@ -101,19 +68,17 @@ class Tracer {
|
|
|
101
68
|
// Assuming ddTraceStateData is now a Map or similar structure containing Datadog trace state data
|
|
102
69
|
// Extract values as needed, similar to the original logic
|
|
103
70
|
const samplingPriorityTs = ddTraceStateData.get('s')
|
|
104
|
-
|
|
71
|
+
origin = ddTraceStateData.get('o') ?? null
|
|
105
72
|
// Convert Map to object for meta
|
|
106
73
|
const otherPropagatedTags = Object.fromEntries(ddTraceStateData.entries())
|
|
107
74
|
|
|
108
75
|
// Update meta and samplingPriority based on extracted values
|
|
109
76
|
Object.assign(meta, otherPropagatedTags)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
origin
|
|
114
|
-
)
|
|
77
|
+
// Guard against an undefined/empty `s:` field that would result in NaN.
|
|
78
|
+
const tracestateSamplingPriority = samplingPriorityTs ? Math.trunc(samplingPriorityTs) : undefined
|
|
79
|
+
samplingPriority = TextMapPropagator._getSamplingPriority(traceFlag, tracestateSamplingPriority, origin)
|
|
115
80
|
} else {
|
|
116
|
-
log.debug('
|
|
81
|
+
log.debug('No dd list member in tracestate from incoming request:', ts)
|
|
117
82
|
}
|
|
118
83
|
}
|
|
119
84
|
|
|
@@ -121,8 +86,8 @@ class Tracer {
|
|
|
121
86
|
traceId: id(traceId, 16), spanId: id(), tags: meta, parentId: id(spanId, 16),
|
|
122
87
|
})
|
|
123
88
|
|
|
124
|
-
spanContext._sampling = { priority: samplingPriority }
|
|
125
|
-
spanContext._trace = { origin }
|
|
89
|
+
spanContext._ddContext._sampling = { priority: samplingPriority }
|
|
90
|
+
spanContext._ddContext._trace = { ...spanContext._ddContext._trace, origin }
|
|
126
91
|
return spanContext
|
|
127
92
|
}
|
|
128
93
|
|
|
@@ -142,6 +107,14 @@ class Tracer {
|
|
|
142
107
|
spanContext = new SpanContext()
|
|
143
108
|
}
|
|
144
109
|
|
|
110
|
+
// init() didn't finish setting up real tracing (e.g. DD_TRACE_ENABLED=false,
|
|
111
|
+
// or init() was never called), so the inner tracer is still the noop.
|
|
112
|
+
// DatadogSpan can't construct without a processor + prioritySampler, so fall
|
|
113
|
+
// through to a non-recording span; the SpanContext still propagates.
|
|
114
|
+
if (!tracer._tracingInitialized) {
|
|
115
|
+
return api.trace.wrapSpanContext(spanContext)
|
|
116
|
+
}
|
|
117
|
+
|
|
145
118
|
const spanKind = options.kind || api.SpanKind.INTERNAL
|
|
146
119
|
const links = []
|
|
147
120
|
if (options.links?.length) {
|
|
@@ -157,28 +130,6 @@ class Tracer {
|
|
|
157
130
|
}
|
|
158
131
|
const attributes = sanitizeAttributes(options.attributes)
|
|
159
132
|
|
|
160
|
-
// TODO: sampling API is not yet supported
|
|
161
|
-
// // make sampling decision
|
|
162
|
-
// const samplingResult = this._sampler.shouldSample(
|
|
163
|
-
// context,
|
|
164
|
-
// spanContext.traceId,
|
|
165
|
-
// name,
|
|
166
|
-
// spanKind,
|
|
167
|
-
// attributes,
|
|
168
|
-
// links
|
|
169
|
-
// )
|
|
170
|
-
|
|
171
|
-
// // Should use new span context
|
|
172
|
-
// spanContext._ddContext._sampling.priority =
|
|
173
|
-
// samplingResult.decision === api.SamplingDecision.RECORD_AND_SAMPLED
|
|
174
|
-
// ? AUTO_KEEP
|
|
175
|
-
// : AUTO_REJECT
|
|
176
|
-
|
|
177
|
-
// if (samplingResult.decision === api.SamplingDecision.NOT_RECORD) {
|
|
178
|
-
// api.diag.debug('Recording is off, propagating context in a non-recording span')
|
|
179
|
-
// return api.trace.wrapSpanContext(spanContext)
|
|
180
|
-
// }
|
|
181
|
-
|
|
182
133
|
return new Span(
|
|
183
134
|
this,
|
|
184
135
|
context,
|
|
@@ -10,46 +10,62 @@ const { MultiSpanProcessor, NoopSpanProcessor } = require('./span_processor')
|
|
|
10
10
|
const Tracer = require('./tracer')
|
|
11
11
|
|
|
12
12
|
class TracerProvider {
|
|
13
|
+
#activeProcessor = new NoopSpanProcessor()
|
|
14
|
+
#contextManager = new ContextManager()
|
|
15
|
+
#processors = []
|
|
16
|
+
#tracers = new Map()
|
|
17
|
+
|
|
13
18
|
constructor (config = {}) {
|
|
14
19
|
this.config = config
|
|
15
20
|
this.resource = config.resource
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
// @opentelemetry/sdk-trace 2.x (used by @opentelemetry/sdk-node 0.220+)
|
|
23
|
+
// dropped `addSpanProcessor` and hands the processors to the provider
|
|
24
|
+
// constructor instead. Wire them the same way the 1.x `addSpanProcessor`
|
|
25
|
+
// path does, so a NodeSDK configured with a trace exporter or custom
|
|
26
|
+
// processors still delivers onStart/onEnd to them.
|
|
27
|
+
if (Array.isArray(config.spanProcessors)) {
|
|
28
|
+
for (const spanProcessor of config.spanProcessors) {
|
|
29
|
+
this.addSpanProcessor(spanProcessor)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
getTracer (name = 'opentelemetry', version = '0.0.0', options) {
|
|
24
35
|
const key = `${name}@${version}`
|
|
25
|
-
if (!this.
|
|
26
|
-
this.
|
|
36
|
+
if (!this.#tracers.has(key)) {
|
|
37
|
+
this.#tracers.set(key, new Tracer(
|
|
27
38
|
{ ...options, name, version },
|
|
28
39
|
this.config,
|
|
29
40
|
this
|
|
30
41
|
))
|
|
31
42
|
}
|
|
32
|
-
return this.
|
|
43
|
+
return this.#tracers.get(key)
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @param {NoopSpanProcessor} spanProcessor
|
|
48
|
+
*/
|
|
35
49
|
addSpanProcessor (spanProcessor) {
|
|
36
|
-
if (
|
|
37
|
-
|
|
50
|
+
if (this.#processors.includes(spanProcessor)) return
|
|
51
|
+
|
|
52
|
+
if (!this.#processors.length) {
|
|
53
|
+
this.#activeProcessor.shutdown()
|
|
38
54
|
}
|
|
39
|
-
this.
|
|
40
|
-
this
|
|
41
|
-
this
|
|
55
|
+
this.#processors.push(spanProcessor)
|
|
56
|
+
this.#activeProcessor = new MultiSpanProcessor(
|
|
57
|
+
this.#processors
|
|
42
58
|
)
|
|
43
59
|
}
|
|
44
60
|
|
|
45
61
|
getActiveSpanProcessor () {
|
|
46
|
-
return this
|
|
62
|
+
return this.#activeProcessor
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
// Not actually required by the SDK spec, but the official Node.js SDK does
|
|
50
66
|
// this and the docs reflect that so we should do this too for familiarity.
|
|
51
67
|
register (config = {}) {
|
|
52
|
-
context.setGlobalContextManager(this
|
|
68
|
+
context.setGlobalContextManager(this.#contextManager)
|
|
53
69
|
if (!trace.setGlobalTracerProvider(this)) {
|
|
54
70
|
trace.getTracerProvider().setDelegate(this)
|
|
55
71
|
}
|
|
@@ -68,12 +84,12 @@ class TracerProvider {
|
|
|
68
84
|
return Promise.reject(new Error('Not started'))
|
|
69
85
|
}
|
|
70
86
|
|
|
71
|
-
exporter._writer
|
|
72
|
-
return this.
|
|
87
|
+
exporter._writer?.flush()
|
|
88
|
+
return this.#activeProcessor.forceFlush()
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
shutdown () {
|
|
76
|
-
return this.
|
|
92
|
+
return this.#activeProcessor.shutdown()
|
|
77
93
|
}
|
|
78
94
|
}
|
|
79
95
|
|