├── .nvmrc ├── .dockerignore ├── .yarnrc ├── packages ├── dd-trace │ ├── test │ │ ├── appsec │ │ │ ├── streamtest.txt │ │ │ ├── next │ │ │ │ ├── pages-dir │ │ │ │ │ ├── public │ │ │ │ │ │ └── test.txt │ │ │ │ │ ├── .eslintrc.json │ │ │ │ │ ├── datadog.js │ │ │ │ │ ├── datadog-extended-data-collection.js │ │ │ │ │ └── pages │ │ │ │ │ │ └── api │ │ │ │ │ │ ├── test │ │ │ │ │ │ └── index.js │ │ │ │ │ │ └── test-formdata │ │ │ │ │ │ └── index.js │ │ │ │ └── app-dir │ │ │ │ │ ├── app │ │ │ │ │ ├── page.js │ │ │ │ │ ├── api │ │ │ │ │ │ └── test-text │ │ │ │ │ │ │ └── route.js │ │ │ │ │ └── layout.js │ │ │ │ │ ├── .eslintrc.json │ │ │ │ │ ├── jsconfig.json │ │ │ │ │ ├── datadog.js │ │ │ │ │ └── datadog-extended-data-collection.js │ │ │ ├── rasp │ │ │ │ └── resources │ │ │ │ │ └── template.ejs │ │ │ ├── iast │ │ │ │ ├── analyzers │ │ │ │ │ └── resources │ │ │ │ │ │ ├── template.ejs │ │ │ │ │ │ ├── render-function.js │ │ │ │ │ │ ├── hardcoded-password-functions.js │ │ │ │ │ │ ├── hardcoded-secret-functions.js │ │ │ │ │ │ ├── mongoose-vulnerable-method.js │ │ │ │ │ │ ├── ldap-injection-methods.js │ │ │ │ │ │ ├── fs-promise-way-method.js │ │ │ │ │ │ ├── mongodb-vulnerable-method.js │ │ │ │ │ │ ├── taint-tracking-utils.js │ │ │ │ │ │ ├── fs-sync-way-method.js │ │ │ │ │ │ ├── mysql2-vulnerable-method.js │ │ │ │ │ │ └── sql-injection-methods.js │ │ │ │ ├── resources │ │ │ │ │ ├── init.js │ │ │ │ │ └── eval-methods.js │ │ │ │ └── security-controls │ │ │ │ │ └── resources │ │ │ │ │ ├── sanitizer_default.js │ │ │ │ │ ├── node_modules │ │ │ │ │ ├── sanitizer │ │ │ │ │ │ └── index.js │ │ │ │ │ └── anotherlib │ │ │ │ │ │ └── node_modules │ │ │ │ │ │ └── sanitizer │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── custom_input_validator.js │ │ │ │ │ └── sanitizer.js │ │ │ ├── graphql.block.json │ │ │ └── bad-formatted-rules.json │ │ ├── fixtures │ │ │ └── config │ │ │ │ ├── git-folder-invalid │ │ │ │ ├── HEAD │ │ │ │ └── refs │ │ │ │ │ └── heads │ │ │ │ │ └── head-branch │ │ │ │ ├── git-folder │ │ │ │ ├── HEAD │ │ │ │ └── refs │ │ │ │ │ └── heads │ │ │ │ │ └── head-branch │ │ │ │ ├── appsec-blocked-template.html │ │ │ │ ├── appsec-blocked-template.json │ │ │ │ ├── git-folder-detached │ │ │ │ └── HEAD │ │ │ │ ├── appsec-blocked-graphql-template.json │ │ │ │ ├── git.properties │ │ │ │ ├── appsec-rules.json │ │ │ │ ├── git.properties.credentials │ │ │ │ └── span-sampling-rules.json │ │ ├── plugins │ │ │ └── util │ │ │ │ ├── fixtures │ │ │ │ └── github_event_payload_malformed.json │ │ │ │ └── __test__ │ │ │ │ └── CODEOWNERS │ │ ├── node_modules │ │ │ ├── express-mock │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ ├── other │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ ├── http2 │ │ │ │ ├── foo.js │ │ │ │ └── package.json │ │ │ └── mysql-mock │ │ │ │ ├── lib │ │ │ │ ├── pool.js │ │ │ │ └── connection.js │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ ├── proxyquire.js │ │ ├── setup │ │ │ └── node.js │ │ ├── ritm-tests │ │ │ ├── module-default.js │ │ │ ├── module-b.js │ │ │ └── module-a.js │ │ ├── pkg-loader.js │ │ ├── lambda │ │ │ └── fixtures │ │ │ │ └── datadog-lambda.js │ │ ├── ci-visibility │ │ │ └── dynamic-instrumentation │ │ │ │ └── target-app │ │ │ │ └── di-dependency.js │ │ ├── custom-metrics-app.js │ │ ├── debugger │ │ │ └── devtools_client │ │ │ │ └── snapshot │ │ │ │ ├── target-code │ │ │ │ ├── max-field-count.js │ │ │ │ ├── max-field-count-scopes.js │ │ │ │ └── max-reference-depth.js │ │ │ │ └── stub-session.js │ │ ├── helpers │ │ │ └── config.js │ │ └── opentracing │ │ │ └── api.spec.js │ ├── src │ │ ├── remote_config │ │ │ └── apply_states.js │ │ ├── appsec │ │ │ ├── iast │ │ │ │ ├── taint-tracking │ │ │ │ │ ├── constants.js │ │ │ │ │ ├── secure-marks-generator.js │ │ │ │ │ └── filter.js │ │ │ │ ├── analyzers │ │ │ │ │ ├── hardcoded-rule-type.js │ │ │ │ │ ├── stored-injection-analyzer.js │ │ │ │ │ ├── insecure-cookie-analyzer.js │ │ │ │ │ ├── no-httponly-cookie-analyzer.js │ │ │ │ │ └── no-samesite-cookie-analyzer.js │ │ │ │ ├── vulnerabilities-formatter │ │ │ │ │ ├── constants.js │ │ │ │ │ └── evidence-redaction │ │ │ │ │ │ └── sensitive-analyzers │ │ │ │ │ │ └── hardcoded-password-analyzer.js │ │ │ │ └── tags.js │ │ │ └── waf │ │ │ │ └── diagnostics.js │ │ ├── llmobs │ │ │ ├── storage.js │ │ │ └── constants │ │ │ │ └── text.js │ │ ├── msgpack │ │ │ └── index.js │ │ ├── guardrails │ │ │ └── util.js │ │ ├── opentracing │ │ │ └── propagation │ │ │ │ ├── http.js │ │ │ │ └── binary.js │ │ ├── datastreams │ │ │ └── schemas │ │ │ │ └── schema.js │ │ ├── debugger │ │ │ └── devtools_client │ │ │ │ ├── defaults.js │ │ │ │ └── snapshot │ │ │ │ └── symbols.js │ │ ├── plugins │ │ │ ├── util │ │ │ │ └── serverless.js │ │ │ ├── inbound.js │ │ │ ├── structured_log_plugin.js │ │ │ ├── client.js │ │ │ ├── server.js │ │ │ └── cache.js │ │ ├── aiguard │ │ │ └── noop.js │ │ ├── crashtracking │ │ │ ├── noop.js │ │ │ └── index.js │ │ ├── profiling │ │ │ ├── profilers │ │ │ │ └── event_plugins │ │ │ │ │ ├── dns.js │ │ │ │ │ ├── dns_lookup.js │ │ │ │ │ └── dns_reverse.js │ │ │ └── constants.js │ │ ├── service-naming │ │ │ └── schemas │ │ │ │ ├── v0 │ │ │ │ ├── graphql.js │ │ │ │ └── serverless.js │ │ │ │ └── v1 │ │ │ │ ├── graphql.js │ │ │ │ └── serverless.js │ │ ├── log │ │ │ └── utils.js │ │ ├── noop │ │ │ ├── scope.js │ │ │ └── dogstatsd.js │ │ ├── exporters │ │ │ └── common │ │ │ │ └── util.js │ │ └── scope │ │ │ └── noop │ │ │ └── scope.js │ └── index.js ├── datadog-plugin-next │ └── test │ │ ├── public │ │ └── test.txt │ │ ├── pages │ │ ├── api │ │ │ ├── error │ │ │ │ └── [name].js │ │ │ ├── invalid │ │ │ │ └── [...catchAll].js │ │ │ └── hello │ │ │ │ ├── index.js │ │ │ │ └── other.js │ │ ├── hello │ │ │ ├── index.js │ │ │ ├── other.js │ │ │ └── [name].js │ │ └── error │ │ │ ├── not_found.js │ │ │ └── get_server_side_props.js │ │ ├── app │ │ ├── appDir │ │ │ └── [name] │ │ │ │ └── page.js │ │ ├── layout.js │ │ └── api │ │ │ └── appDir │ │ │ ├── [name] │ │ │ └── route.js │ │ │ └── error │ │ │ └── route.js │ │ ├── integration-test │ │ └── pages │ │ │ └── index.js │ │ └── middleware.js ├── datadog-plugin-google-cloud-vertexai │ └── test │ │ └── resources │ │ └── malformed-stream.txt ├── datadog-esbuild │ └── test │ │ └── resources │ │ ├── export-method.mjs │ │ ├── export-default-method.mjs │ │ └── export-method-and-nested-method.mjs ├── datadog-shimmer │ └── index.js ├── datadog-instrumentations │ ├── src │ │ ├── grpc.js │ │ ├── http.js │ │ ├── http2.js │ │ ├── moleculer.js │ │ ├── helpers │ │ │ ├── rewriter │ │ │ │ ├── instrumentations │ │ │ │ │ └── index.js │ │ │ │ ├── loader.mjs │ │ │ │ └── loader.js │ │ │ └── instrumentations.js │ │ ├── langchain.js │ │ ├── dd-trace-api.js │ │ ├── grpc │ │ │ └── types.js │ │ ├── passport-local.js │ │ ├── passport-http.js │ │ ├── cypress.js │ │ ├── when.js │ │ └── promise.js │ ├── test │ │ ├── helpers │ │ │ ├── rewriter │ │ │ │ └── node_modules │ │ │ │ │ ├── test-trace-async │ │ │ │ │ ├── package.json │ │ │ │ │ └── index.js │ │ │ │ │ ├── test-trace-sync │ │ │ │ │ ├── package.json │ │ │ │ │ └── index.js │ │ │ │ │ └── test-trace-callback │ │ │ │ │ ├── package.json │ │ │ │ │ └── index.js │ │ │ └── check-require-cache │ │ │ │ ├── bad-order.js │ │ │ │ └── good-order.js │ │ ├── q.suite.js │ │ ├── promise.spec.js │ │ ├── promise.suite.js │ │ ├── promise-js.spec.js │ │ ├── q.spec.js │ │ ├── when.spec.js │ │ └── bluebird.spec.js │ └── index.js ├── datadog-core │ ├── index.js │ └── src │ │ └── utils │ │ └── src │ │ ├── uniq.js │ │ └── pick.js ├── datadog-plugin-openai │ └── test │ │ ├── image.png │ │ ├── translation.m4a │ │ └── transcription.m4a ├── datadog-plugin-avsc │ ├── test │ │ └── schemas │ │ │ ├── users.avro │ │ │ └── advanced_users.avro │ └── src │ │ └── index.js ├── datadog-plugin-protobufjs │ ├── test │ │ └── schemas │ │ │ ├── other_message.proto │ │ │ ├── message.proto │ │ │ └── other_message_proto.json │ └── src │ │ └── index.js ├── datadog-plugin-cypress │ └── src │ │ ├── after-run.js │ │ ├── after-spec.js │ │ └── index.js ├── datadog-plugin-bunyan │ ├── test │ │ ├── suite.js │ │ └── integration-test │ │ │ └── server.mjs │ └── src │ │ └── index.js ├── datadog-plugin-connect │ └── test │ │ ├── suite.js │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-amqp10 │ ├── test │ │ └── suite.js │ └── src │ │ └── util.js ├── datadog-plugin-dns │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-couchbase │ └── test │ │ ├── suite.js │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-aws-sdk │ ├── src │ │ └── services │ │ │ ├── default.js │ │ │ ├── sfn.js │ │ │ └── states.js │ └── test │ │ ├── fixtures │ │ ├── kinesis.js │ │ ├── cloudwatchlogs.js │ │ ├── sns.js │ │ ├── sqs.js │ │ ├── s3.js │ │ ├── base.js │ │ └── redshift.js │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-axios │ └── test │ │ ├── integration-test │ │ └── server.mjs │ │ └── suite.js ├── datadog-plugin-fastify │ └── test │ │ ├── integration-test │ │ ├── server.mjs │ │ ├── server2.mjs │ │ ├── server1.mjs │ │ └── helper.mjs │ │ └── suite.js ├── datadog-plugin-azure-functions │ └── test │ │ └── fixtures │ │ ├── host.json │ │ └── package.json ├── datadog-plugin-ioredis │ ├── test │ │ └── integration-test │ │ │ └── server.mjs │ └── src │ │ └── index.js ├── datadog-plugin-iovalkey │ ├── test │ │ └── integration-test │ │ │ └── server.mjs │ └── src │ │ └── index.js ├── datadog-plugin-redis │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-pino │ ├── src │ │ └── index.js │ └── test │ │ ├── integration-test │ │ └── server.mjs │ │ └── suite.js ├── datadog-plugin-winston │ └── src │ │ └── index.js ├── datadog-plugin-opensearch │ ├── test │ │ └── integration-test │ │ │ └── server.mjs │ └── src │ │ └── index.js ├── datadog-plugin-amqplib │ ├── test │ │ ├── suite.js │ │ └── integration-test │ │ │ └── server.mjs │ └── src │ │ └── util.js ├── datadog-plugin-elasticsearch │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-koa │ └── test │ │ ├── suite.js │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-memcached │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-tedious │ └── test │ │ └── suite.js ├── datadog-plugin-graphql │ ├── test │ │ └── suite.js │ └── src │ │ └── tools │ │ └── index.js ├── datadog-plugin-fetch │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-langchain │ └── src │ │ └── handlers │ │ └── default.js ├── datadog-plugin-sharedb │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-limitd-client │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-undici │ └── src │ │ └── index.js ├── datadog-plugin-restify │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-hapi │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-mariadb │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-net │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-apollo │ └── src │ │ ├── gateway │ │ ├── plan.js │ │ ├── execute.js │ │ └── postprocessing.js │ │ └── index.js ├── datadog-plugin-confluentinc-kafka-javascript │ └── src │ │ ├── consumer.js │ │ ├── producer.js │ │ └── batch-consumer.js ├── datadog-plugin-http2 │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-prisma │ └── test │ │ ├── schema.prisma │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-grpc │ └── test │ │ └── hasservice.proto ├── datadog-plugin-google-genai │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-express │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-mongoose │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-anthropic │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-pg │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-cassandra-driver │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-mongodb-core │ └── test │ │ └── integration-test │ │ └── server.mjs ├── datadog-plugin-mysql │ └── test │ │ └── integration-test │ │ └── server.mjs └── datadog-plugin-mysql2 │ └── test │ └── integration-test │ └── server.mjs ├── integration-tests ├── appsec │ ├── rasp │ │ └── streamtest.txt │ ├── iast-esbuild-cjs │ │ ├── random.json │ │ ├── iast │ │ │ └── index.js │ │ ├── esbuild-no-iast.js │ │ └── esbuild.common-config.js │ ├── iast-esbuild-esm │ │ ├── random.json │ │ ├── init.mjs │ │ ├── iast │ │ │ └── index.mjs │ │ └── app.mjs │ ├── esm-security-controls │ │ ├── sanitizer.mjs │ │ ├── sanitizer-default.mjs │ │ └── validator.mjs │ ├── iast-stack-traces-ts-with-sourcemaps │ │ └── init.js │ └── esm-app │ │ ├── worker-dep.mjs │ │ ├── more.mjs │ │ └── custom-noop-hooks.mjs ├── helpers │ ├── output │ │ └── .gitignore │ └── bun.js ├── esbuild │ ├── init.mjs │ ├── openai.js │ ├── typescript-dep.ts │ ├── typescript-app.ts │ ├── aws-sdk.js │ ├── build.esm.mjs │ ├── skip-external.js │ ├── koa.mjs │ └── esm-http-test.mjs ├── ci-visibility │ ├── tinypool-worker.mjs │ ├── vitest-tests │ │ ├── sum.mjs │ │ ├── bad-sum.mjs │ │ ├── impacted-test.mjs │ │ ├── coverage-test.mjs │ │ ├── coverage-test-zero.mjs │ │ ├── test-disabled.mjs │ │ └── dynamic-instrumentation.mjs │ ├── subproject │ │ ├── cypress │ │ │ ├── support │ │ │ │ └── e2e.js │ │ │ ├── plugins-old │ │ │ │ └── index.js │ │ │ └── e2e │ │ │ │ └── spec.cy.js │ │ ├── dependency.js │ │ ├── features │ │ │ └── greetings.feature │ │ ├── vitest-test.mjs │ │ ├── package.json │ │ ├── subproject-test.js │ │ ├── cypress-config.json │ │ └── cypress.config.js │ ├── test │ │ ├── sum.js │ │ ├── fail-test.js │ │ ├── ci-visibility-test.js │ │ ├── ci-visibility-test-2.js │ │ └── efd-parallel │ │ │ ├── ci-visibility-test.js │ │ │ ├── ci-visibility-test-2.js │ │ │ ├── ci-visibility-test-3.js │ │ │ └── ci-visibility-test-4.js │ ├── jest-bad-import-torn-down │ │ ├── off-timing-import.js │ │ ├── jest-bad-import-test-pass.js │ │ ├── jest-bad-import-test-pass-2.js │ │ └── jest-bad-import-test.js │ ├── jest-bad-import │ │ ├── off-timing-import.js │ │ ├── jest-bad-import-test-pass.js │ │ ├── jest-bad-import-test-pass-2.js │ │ └── jest-bad-import-test.js │ ├── packages │ │ └── some-package │ │ │ ├── index.js │ │ │ └── package.json │ ├── test-total-code-coverage │ │ ├── unused-dependency.js │ │ ├── used-dependency.js │ │ ├── test-run.js │ │ └── test-skipped.js │ ├── jest-setup-files-after-env.js │ ├── features-flaky │ │ └── flaky.feature │ ├── features-retry │ │ └── flaky.feature │ ├── features-selenium │ │ └── selenium.feature │ ├── features-esm │ │ └── farewell.feature │ ├── features-di │ │ ├── test-hit-breakpoint.feature │ │ ├── test-not-hit-breakpoint.feature │ │ └── support │ │ │ └── sum.js │ ├── features-test-management │ │ ├── disabled.feature │ │ ├── quarantine.feature │ │ └── attempt-to-fix.feature │ ├── jestEnvironmentBadInit.js │ ├── office-addin-mock │ │ ├── dependency.js │ │ └── test.js │ ├── features-impacted-test │ │ ├── impacted-test.feature │ │ ├── impacted-test-2.feature │ │ └── support │ │ │ └── steps.js │ ├── automatic-log-submission-cucumber │ │ ├── automatic-log-submission.feature │ │ └── support │ │ │ ├── sum.js │ │ │ └── logger.js │ ├── automatic-log-submission │ │ ├── sum.js │ │ ├── logger.js │ │ ├── config-jest.js │ │ └── automatic-log-submission-test.js │ ├── jest │ │ ├── mocked-test.js │ │ └── failing-test.js │ ├── mocha-plugin-tests │ │ ├── failing.js │ │ ├── timeout-fail.js │ │ ├── timeout-pass.js │ │ ├── async-pass.js │ │ ├── done-fail-badly.js │ │ ├── async-fail.js │ │ ├── parameterized.js │ │ ├── hook-sync-error.js │ │ ├── promise-pass.js │ │ ├── done-fail.js │ │ ├── done-pass.js │ │ └── retries.js │ ├── unskippable-test │ │ ├── test-to-run.js │ │ ├── test-to-skip.js │ │ └── test-unskippable.js │ ├── sharding-test │ │ ├── sharding-test-1.js │ │ ├── sharding-test-2.js │ │ ├── sharding-test-3.js │ │ ├── sharding-test-4.js │ │ └── sharding-test-5.js │ ├── test-early-flake-detection │ │ ├── test.js │ │ ├── __image_snapshots__ │ │ │ └── jest-image-snapshot-js-snapshot-can-match-1-snap.png │ │ ├── occasionally-failing-test.js │ │ ├── test-parameterized.js │ │ ├── weird-test-names.js │ │ └── mocha-parameterized.js │ ├── automatic-log-submission-playwright │ │ ├── sum.js │ │ └── logger.js │ ├── test-management │ │ ├── test-disabled-2.js │ │ ├── __snapshots__ │ │ │ ├── test-snapshot-attempt-to-fix-1.js.snap │ │ │ └── test-snapshot-attempt-to-fix-2.js.snap │ │ ├── __image_snapshots__ │ │ │ └── test-snapshot-image-js-snapshot-can-match-1-snap.png │ │ ├── test-quarantine-2.js │ │ ├── test-disabled-1.js │ │ └── test-attempt-to-fix-2.js │ ├── test-parsing-error │ │ ├── parsing-error.js │ │ └── parsing-error-2.js │ ├── timeout-test │ │ └── timeout-test.js │ ├── jest-flaky │ │ ├── flaky-fails.js │ │ └── flaky-passes.js │ ├── jest-plugin-tests │ │ ├── jest-test-suite.js │ │ └── jest-inject-globals.js │ ├── dynamic-instrumentation │ │ ├── parallel-test-hit-breakpoint-2.js │ │ ├── dependency.js │ │ └── parallel-test-hit-breakpoint-1.js │ ├── features │ │ └── farewell.feature │ ├── jest-fast-check │ │ ├── jest-no-fast-check.js │ │ └── jest-fast-check.js │ ├── playwright-did-not-run │ │ ├── did-not-run.js │ │ └── fail-test.js │ ├── jest-package-mock │ │ ├── non-dependency-mock-test.js │ │ ├── non-dependency-mock-test-3.js │ │ ├── non-dependency-mock-test-4.js │ │ ├── non-dependency-mock-test-5.js │ │ ├── non-dependency-mock-test-6.js │ │ └── non-dependency-mock-test-2.js │ ├── jest-mock-bypass-require │ │ └── logger.js │ ├── test-flaky-test-retries │ │ └── eventually-passing-test.js │ ├── mocha-retries-test-fn │ │ ├── mocha-sync.js │ │ ├── mocha-done.js │ │ ├── mocha-promise.js │ │ └── mocha-async.js │ ├── test-impacted-test │ │ ├── test-impacted-1.js │ │ └── test-impacted-2.js │ ├── playwright-test-duration │ │ ├── long-suite-test.js │ │ └── short-suite-test.js │ ├── test-optimization-wrong-init-cucumber │ │ └── sum.feature │ ├── playwright-tests-test-management │ │ └── quarantine-2-test.js │ ├── test-optimization-wrong-init │ │ ├── sum-wrong-init-test.js │ │ └── run-jest.js │ ├── playwright-tests │ │ └── skipped-suite-test.js │ └── playwright-tests-test-capabilities │ │ └── passing-test.js ├── debugger │ └── target-app │ │ ├── source-map-support │ │ ├── hello │ │ │ ├── world.ts │ │ │ ├── world.js.map │ │ │ └── world.js │ │ ├── scripts │ │ │ ├── build-typescript.sh │ │ │ └── build-minifiy.sh │ │ └── minify.min.js │ │ └── re-evaluation │ │ ├── package.json │ │ ├── index.js │ │ └── unique-filename.js ├── code-origin │ └── scripts │ │ └── build-typescript.sh ├── CODEOWNERS ├── cypress │ ├── support │ │ └── e2e.js │ └── e2e │ │ ├── other.cy.js │ │ ├── disable.js │ │ ├── quarantine.js │ │ ├── skipped-test.js │ │ ├── impacted-test.js │ │ ├── impacted-test-order.js │ │ └── multi-origin.js ├── init │ └── trace.js ├── my-nyc.config.js ├── telemetry-forwarder.sh ├── cypress-config.json ├── tsconfig.json ├── startup │ └── unsupported.js ├── config-jest.js └── profiler │ └── dnstest.js ├── .nycrc ├── benchmark ├── sirun │ ├── .gitignore │ ├── monitor.js │ ├── runtime-metrics │ │ ├── index.js │ │ └── README.md │ ├── appsec │ │ ├── common.js │ │ ├── README.md │ │ └── insecure-bank.js │ ├── appsec-iast │ │ ├── common.js │ │ └── insecure-bank.js │ ├── plugin-http │ │ ├── common.js │ │ └── README.md │ ├── plugin-net │ │ ├── common.js │ │ ├── README.md │ │ └── server.js │ ├── plugin-q │ │ ├── README.md │ │ └── index.js │ ├── plugin-dns │ │ ├── README.md │ │ └── index.js │ ├── debugger │ │ └── README.md │ ├── scope │ │ └── README.md │ ├── plugin-graphql │ │ └── README.md │ ├── plugin-bluebird │ │ └── README.md │ ├── shimmer-runtime │ │ └── README.md │ ├── shimmer-startup │ │ └── README.md │ ├── get-variants.js │ ├── run-one-variant.js │ ├── log │ │ └── README.md │ ├── spans │ │ └── README.md │ ├── encoding │ │ └── meta.json │ ├── event_loop.js │ └── startup │ │ └── README.md └── index.js ├── index.js ├── repository.datadog.yml ├── docs ├── relationship.png ├── typedoc.js ├── tsconfig.json ├── README.md └── package.json ├── vendor └── dist │ ├── opentracing │ ├── examples │ │ └── demo │ │ │ └── demo.d.ts │ ├── test │ │ ├── unittest.d.ts │ │ ├── opentracing_api.d.ts │ │ ├── mocktracer_implemenation.d.ts │ │ └── noop_implementation.d.ts │ ├── mock_tracer │ │ └── index.d.ts │ ├── noop.d.ts │ └── binary_carrier.d.ts │ └── source-map │ └── mappings.wasm ├── esbuild.js ├── ci └── cypress │ ├── support.js │ ├── after-run.js │ ├── after-spec.js │ └── plugin.js ├── .taprc ├── static-analysis.datadog.yml ├── ext ├── types.js ├── types.d.ts ├── priority.js ├── priority.d.ts ├── kinds.d.ts ├── kinds.js ├── formats.js ├── scopes.js ├── scopes.d.ts ├── index.d.ts ├── formats.d.ts ├── exporters.js ├── exporters.d.ts └── index.js ├── .codecov.yml ├── examples └── README.md ├── NOTICE ├── init.js ├── .github ├── codeql_config.yml ├── actions │ ├── node │ │ ├── latest │ │ │ └── action.yml │ │ ├── active-lts │ │ │ └── action.yml │ │ ├── oldest-maintenance-lts │ │ │ └── action.yml │ │ └── newest-maintenance-lts │ │ │ └── action.yml │ └── testagent │ │ └── start │ │ └── action.yml ├── chainguard │ └── self.gitlab.read.sts.yaml └── vendored-dependencies.csv ├── scripts └── helpers │ └── color.js ├── LICENSE ├── .vscode └── settings.json ├── .mocharc.js ├── .gitlab └── one-pipeline.locked.yml ├── .editorconfig ├── register.js └── .mochamultireporterrc.js /.nvmrc: -------------------------------------------------------------------------------- 1 | 18 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | ignore-engines true 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/streamtest.txt: -------------------------------------------------------------------------------- 1 | file -------------------------------------------------------------------------------- /integration-tests/appsec/rasp/streamtest.txt: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /integration-tests/helpers/output/.gitignore: -------------------------------------------------------------------------------- 1 | *.out 2 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/public/test.txt: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/pages-dir/public/test.txt: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "reporter": [ 3 | "text", 4 | "lcov" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /benchmark/sirun/.gitignore: -------------------------------------------------------------------------------- 1 | *.ndjson 2 | meta-temp.json 3 | summary.json 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/git-folder-invalid/HEAD: -------------------------------------------------------------------------------- 1 | rm -rf; 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('./packages/dd-trace') 4 | -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-cjs/random.json: -------------------------------------------------------------------------------- 1 | { 2 | "isRandom": true 3 | } 4 | -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-esm/random.json: -------------------------------------------------------------------------------- 1 | { 2 | "isRandom": true 3 | } 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/git-folder/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/head-branch 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/plugins/util/fixtures/github_event_payload_malformed.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /packages/datadog-plugin-google-cloud-vertexai/test/resources/malformed-stream.txt: -------------------------------------------------------------------------------- 1 | empty 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/appsec-blocked-template.html: -------------------------------------------------------------------------------- 1 | blocked 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/appsec-blocked-template.json: -------------------------------------------------------------------------------- 1 | {"error": "blocked"} 2 | -------------------------------------------------------------------------------- /repository.datadog.yml: -------------------------------------------------------------------------------- 1 | --- 2 | schema-version: v1 3 | kind: mergequeue 4 | enable: false 5 | -------------------------------------------------------------------------------- /benchmark/sirun/monitor.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('./event_loop') 4 | require('./gc') 5 | -------------------------------------------------------------------------------- /docs/relationship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/docs/relationship.png -------------------------------------------------------------------------------- /packages/datadog-esbuild/test/resources/export-method.mjs: -------------------------------------------------------------------------------- 1 | export function exportMethod () {} 2 | -------------------------------------------------------------------------------- /vendor/dist/opentracing/examples/demo/demo.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=demo.d.ts.map -------------------------------------------------------------------------------- /vendor/dist/opentracing/test/unittest.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=unittest.d.ts.map -------------------------------------------------------------------------------- /esbuild.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('./packages/datadog-esbuild/index.js') 4 | -------------------------------------------------------------------------------- /packages/datadog-shimmer/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('./src/shimmer') 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/express-mock/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | foo: 'bar' 3 | } 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/other/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'other' 3 | } 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/proxyquire.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('proxyquire') 4 | -------------------------------------------------------------------------------- /ci/cypress/support.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../../packages/datadog-plugin-cypress/src/support') 4 | -------------------------------------------------------------------------------- /integration-tests/esbuild/init.mjs: -------------------------------------------------------------------------------- 1 | import tracer from 'dd-trace' 2 | tracer.init({ flushInterval: 0 }) 3 | -------------------------------------------------------------------------------- /integration-tests/esbuild/openai.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../../').init() 4 | require('openai') 5 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/git-folder-detached/HEAD: -------------------------------------------------------------------------------- 1 | 964886d9ec0c9fc68778e4abb0aab4d9982ce2b5 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/http2/foo.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = 'Hello, World!' 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/mysql-mock/lib/pool.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'Pool' 3 | } 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/setup/node.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('./core') 4 | require('./services') 5 | -------------------------------------------------------------------------------- /.taprc: -------------------------------------------------------------------------------- 1 | check-coverage: false 2 | color: true 3 | coverage: false 4 | node-arg: --expose-gc 5 | reporter: spec 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/tinypool-worker.mjs: -------------------------------------------------------------------------------- 1 | export default ({ a, b }) => { 2 | return a + b 3 | } 4 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/vitest-tests/sum.mjs: -------------------------------------------------------------------------------- 1 | export function sum (a, b) { 2 | return a + b 3 | } 4 | -------------------------------------------------------------------------------- /packages/datadog-esbuild/test/resources/export-default-method.mjs: -------------------------------------------------------------------------------- 1 | export default function exportMethod () {} 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/git-folder/refs/heads/head-branch: -------------------------------------------------------------------------------- 1 | 964886d9ec0c9fc68778e4abb0aab4d9982ce2b5 2 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/mysql-mock/lib/connection.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'Connection' 3 | } 4 | -------------------------------------------------------------------------------- /static-analysis.datadog.yml: -------------------------------------------------------------------------------- 1 | rulesets: 2 | - sit-ci-best-practices: 3 | only: 4 | - ".github/workflows" 5 | -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-esm/init.mjs: -------------------------------------------------------------------------------- 1 | import tracer from 'dd-trace' 2 | tracer.init({ flushInterval: 0 }) 3 | -------------------------------------------------------------------------------- /integration-tests/appsec/esm-security-controls/sanitizer.mjs: -------------------------------------------------------------------------------- 1 | export function sanitize (input) { 2 | return input 3 | } 4 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/grpc.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('./grpc/client') 4 | require('./grpc/server') 5 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/http.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('./http/client') 4 | require('./http/server') 5 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/http2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('./http2/client') 4 | require('./http2/server') 5 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/git-folder-invalid/refs/heads/head-branch: -------------------------------------------------------------------------------- 1 | 964886d9ec0c9fc68778e4abb0aab4d9982ce2b5 2 | -------------------------------------------------------------------------------- /vendor/dist/source-map/mappings.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/vendor/dist/source-map/mappings.wasm -------------------------------------------------------------------------------- /benchmark/sirun/runtime-metrics/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../../..').init() 4 | 5 | setTimeout(() => {}, 1000) 6 | -------------------------------------------------------------------------------- /ci/cypress/after-run.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('../../packages/datadog-plugin-cypress/src/after-run') 4 | -------------------------------------------------------------------------------- /ci/cypress/after-spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('../../packages/datadog-plugin-cypress/src/after-spec') 4 | -------------------------------------------------------------------------------- /ext/types.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | HTTP: 'http', 5 | SERVERLESS: 'serverless', 6 | WEB: 'web' 7 | } 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/cypress/support/e2e.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('dd-trace/ci/cypress/support') 4 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/sum.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function (a, b) { 4 | return a + b 5 | } 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/api/error/[name].js: -------------------------------------------------------------------------------- 1 | export default (_req, _res) => { 2 | throw new Error('oh no') 3 | } 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/ritm-tests/module-default.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function () { 4 | return 'hi' 5 | } 6 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | range: 90..100 3 | round: down 4 | precision: 2 5 | status: 6 | project: off 7 | patch: off 8 | -------------------------------------------------------------------------------- /ext/types.d.ts: -------------------------------------------------------------------------------- 1 | declare const types: { 2 | HTTP: 'http' 3 | SERVERLESS: 'serverless' 4 | WEB: 'web' 5 | } 6 | 7 | export = types 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/app/appDir/[name]/page.js: -------------------------------------------------------------------------------- 1 | export default function Page () { 2 | return

Hello World

3 | } 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/rasp/resources/template.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Kaixo!

4 | 5 | 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/dependency.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function (a, b) { 4 | return a + b 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/esbuild/typescript-dep.ts: -------------------------------------------------------------------------------- 1 | export default function greeter(person: string) { 2 | return `Hello ${person}!` 3 | } 4 | 5 | -------------------------------------------------------------------------------- /packages/datadog-core/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { storage } = require('./src/storage') 4 | 5 | module.exports = { storage } 6 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/moleculer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('./moleculer/client') 4 | require('./moleculer/server') 5 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/appsec-blocked-graphql-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": { 3 | "message": "blocked" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/datadog-core/src/utils/src/uniq.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function uniq (arr) { 4 | return [...new Set(arr)] 5 | } 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-openai/test/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/packages/datadog-plugin-openai/test/image.png -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/template.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Kaixo!

4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/app-dir/app/page.js: -------------------------------------------------------------------------------- 1 | export default function Home () { 2 | return ( 3 |
test
4 | ) 5 | } 6 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | Examples are available in the [trace-examples](https://github.com/DataDog/trace-examples/tree/master/javascript/node) repository. 2 | -------------------------------------------------------------------------------- /ext/priority.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | USER_REJECT: -1, 5 | AUTO_REJECT: 0, 6 | AUTO_KEEP: 1, 7 | USER_KEEP: 2 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/cypress/plugins-old/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('dd-trace/ci/cypress/plugin') 4 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/graphql.block.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "custom blocking message" 5 | } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/app-dir/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["next", "next/core-web-vitals"], 3 | "ignorePatterns": ["**/*"] 4 | } 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import-torn-down/off-timing-import.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | sum: (a, b) => a + b 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import/off-timing-import.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function sum (a, b) { 4 | return a + b 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/packages/some-package/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function () { 4 | return 'Hello, world!' 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/source-map-support/hello/world.ts: -------------------------------------------------------------------------------- 1 | export function sayHello () { 2 | return 'hello world' // BREAKPOINT: / 3 | } 4 | -------------------------------------------------------------------------------- /integration-tests/esbuild/typescript-app.ts: -------------------------------------------------------------------------------- 1 | import greeter from './typescript-dep' 2 | 3 | const name = 'World' 4 | 5 | console.log(greeter(name)) 6 | 7 | -------------------------------------------------------------------------------- /packages/datadog-plugin-openai/test/translation.m4a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/packages/datadog-plugin-openai/test/translation.m4a -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/app-dir/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "@/*": ["./*"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/pages-dir/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["next", "next/core-web-vitals"], 3 | "ignorePatterns": ["**/*"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/dd-trace/test/ritm-tests/module-b.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { a } = require('./module-a') 4 | 5 | module.exports.b = () => { return a() } 6 | -------------------------------------------------------------------------------- /benchmark/sirun/appsec/common.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | port: 3231 + parseInt(process.env.CPU_AFFINITY || '0'), 5 | reqs: 100 6 | } 7 | -------------------------------------------------------------------------------- /ext/priority.d.ts: -------------------------------------------------------------------------------- 1 | declare const priority: { 2 | USER_REJECT: -1 3 | AUTO_REJECT: 0 4 | AUTO_KEEP: 1 5 | USER_KEEP: 2 6 | } 7 | 8 | export = priority 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-total-code-coverage/unused-dependency.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function (a, b) { 4 | return a + b 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-total-code-coverage/used-dependency.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function (a, b) { 4 | return a + b 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/re-evaluation/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "re-evaluation-test", 3 | "version": "0.0.0", 4 | "type": "module" 5 | } 6 | -------------------------------------------------------------------------------- /packages/datadog-esbuild/test/resources/export-method-and-nested-method.mjs: -------------------------------------------------------------------------------- 1 | export * from './export-method.mjs' 2 | 3 | export function exportedMethod2 () {} 4 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = [ 4 | ...require('./langchain') 5 | ] 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-avsc/test/schemas/users.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/packages/datadog-plugin-avsc/test/schemas/users.avro -------------------------------------------------------------------------------- /packages/datadog-plugin-openai/test/transcription.m4a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/packages/datadog-plugin-openai/test/transcription.m4a -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Datadog dd-trace-js 2 | Copyright 2016-Present Datadog, Inc. 3 | 4 | This product includes software developed at Datadog, Inc. (https://www.datadoghq.com/). 5 | -------------------------------------------------------------------------------- /benchmark/sirun/appsec-iast/common.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | port: 3331 + parseInt(process.env.CPU_AFFINITY || '0'), 5 | reqs: 100 6 | } 7 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-http/common.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | port: 3031 + parseInt(process.env.CPU_AFFINITY || '0'), 5 | reqs: 350 6 | } 7 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-net/common.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | port: 3131 + parseInt(process.env.CPU_AFFINITY || '0'), 5 | reqs: 100 6 | } 7 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-q/README.md: -------------------------------------------------------------------------------- 1 | This benchmarks promises in a chain using the latest version of `q`. 2 | 3 | The variants are with the tracer and without it. 4 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/rewriter/node_modules/test-trace-async/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-trace-async", 3 | "version": "0.1" 4 | } 5 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/rewriter/node_modules/test-trace-sync/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-trace-sync", 3 | "version": "0.1" 4 | } 5 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/api/invalid/[...catchAll].js: -------------------------------------------------------------------------------- 1 | export default function CatchAllPage () { 2 | return

This is a catch-all page

3 | } 4 | -------------------------------------------------------------------------------- /packages/dd-trace/src/remote_config/apply_states.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | UNACKNOWLEDGED: 1, 5 | ACKNOWLEDGED: 2, 6 | ERROR: 3 7 | } 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/resources/init.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const tracer = require('dd-trace') 4 | 5 | tracer.init({ 6 | flushInterval: 0 7 | }) 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/http2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "http2", 3 | "version": "4.0.0", 4 | "license": "UNLICENSED", 5 | "private": true 6 | } 7 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/mysql-mock/index.js: -------------------------------------------------------------------------------- 1 | require('./lib/connection') 2 | require('./lib/pool') 3 | 4 | module.exports = { 5 | name: 'mysql' 6 | } 7 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-dns/README.md: -------------------------------------------------------------------------------- 1 | Runs `dns.lookup('localhost', cb)` many times. In the `with-tracer` variant, 2 | tracing is enabled. Iteration count is set to 10. 3 | -------------------------------------------------------------------------------- /integration-tests/appsec/esm-security-controls/sanitizer-default.mjs: -------------------------------------------------------------------------------- 1 | function sanitizeDefault (input) { 2 | return input 3 | } 4 | 5 | export default sanitizeDefault 6 | -------------------------------------------------------------------------------- /integration-tests/code-origin/scripts/build-typescript.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | npx --package=typescript -- tsc --sourceMap integration-tests/code-origin/typescript.ts -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/rewriter/node_modules/test-trace-callback/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-trace-callback", 3 | "version": "0.1" 4 | } 5 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/hello/index.js: -------------------------------------------------------------------------------- 1 | export default function Home () { 2 | return ( 3 |
4 | Hello index! 5 |
6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/hello/other.js: -------------------------------------------------------------------------------- 1 | export default function Home () { 2 | return ( 3 |
4 | Hello other! 5 |
6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /benchmark/sirun/debugger/README.md: -------------------------------------------------------------------------------- 1 | # Dynamic Instrumentation Benchmarks 2 | 3 | Benchmark the overhead on the instrumented application of different probe configurations. 4 | -------------------------------------------------------------------------------- /benchmark/sirun/scope/README.md: -------------------------------------------------------------------------------- 1 | This test creates a number (`COUNT`) of promises, awaits, setImmediates and 2 | setTimeouts which a given scope manager (`DD_TRACE_SCOPE`). 3 | -------------------------------------------------------------------------------- /init.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var guard = require('./packages/dd-trace/src/guardrails') 4 | 5 | module.exports = guard(function () { 6 | return require('.').init() 7 | }) 8 | -------------------------------------------------------------------------------- /integration-tests/appsec/iast-stack-traces-ts-with-sourcemaps/init.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const tracer = require('dd-trace') 3 | 4 | tracer.init({ 5 | flushInterval: 0 6 | }) 7 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/rewriter/node_modules/test-trace-async/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function test () {} 4 | 5 | module.exports = { test } 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/hello/[name].js: -------------------------------------------------------------------------------- 1 | export default function Home () { 2 | return ( 3 |
4 | Hello [name]! 5 |
6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-protobufjs/test/schemas/other_message.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message OtherMessage { 4 | repeated string name = 1; 5 | int32 age = 2; 6 | } -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/taint-tracking/constants.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | LOG_MESSAGE: 'LOG', 5 | REWRITTEN_MESSAGE: 'REWRITTEN' 6 | } 7 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/render-function.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function render (res, file) { 4 | res.render(file) 5 | } 6 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/git.properties: -------------------------------------------------------------------------------- 1 | git.commit.sha=4e7da8069bcf5ffc8023603b95653e2dc99d1c7d 2 | git.repository_url=git@github.com:DataDog/dd-trace-js.git 3 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-graphql/README.md: -------------------------------------------------------------------------------- 1 | This makes 5 queries to a GraphQL server with highly nested (100x100) results. 2 | 3 | The variants are with `async_hooks` and without. 4 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-setup-files-after-env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | jest.mock('some-package', () => { 4 | return jest.fn(() => 'Hello, mocked world!') 5 | }) 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/packages/some-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "some-package", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT" 6 | } 7 | -------------------------------------------------------------------------------- /integration-tests/esbuild/aws-sdk.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../../').init() // dd-trace 4 | 5 | const aws = require('aws-sdk') 6 | 7 | global.test = aws.util.inherit 8 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/rewriter/node_modules/test-trace-sync/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | async function test () {} 4 | 5 | module.exports = { test } 6 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/analyzers/hardcoded-rule-type.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | ValueOnly: 'ValueOnly', 5 | NameAndValue: 'NameAndValue' 6 | } 7 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/appsec-rules.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.2", 3 | "metadata": { 4 | "rules_version": "1.5.2" 5 | }, 6 | "rules": [{"a": 1}] 7 | } 8 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-bluebird/README.md: -------------------------------------------------------------------------------- 1 | This creates a lot of promises in a chain using the latest version of `bluebird`. 2 | 3 | The variants are with the tracer and without it. 4 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-flaky/flaky.feature: -------------------------------------------------------------------------------- 1 | Feature: Farewell 2 | Scenario: Say flaky 3 | When the greeter says flaky 4 | Then I should have heard "flaky" 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-retry/flaky.feature: -------------------------------------------------------------------------------- 1 | Feature: Farewell 2 | Scenario: Say flaky 3 | When the greeter says flaky 4 | Then I should have heard "flaky" 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-selenium/selenium.feature: -------------------------------------------------------------------------------- 1 | Feature: Selenium 2 | Scenario: Run selenium 3 | When we run selenium 4 | Then I should have run selenium 5 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/q.suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest('q', 'kriskowal/q', 'latest') 6 | -------------------------------------------------------------------------------- /packages/dd-trace/test/pkg-loader.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const pkg = require('../src/pkg.js') 4 | 5 | // eslint-disable-next-line no-console 6 | console.log(JSON.stringify(pkg)) 7 | -------------------------------------------------------------------------------- /integration-tests/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS for testing purposes 2 | ci-visibility/subproject @datadog-dd-trace-js 3 | ci-visibility/ @datadog-dd-trace-js 4 | cypress/ @datadog-dd-trace-js 5 | -------------------------------------------------------------------------------- /integration-tests/appsec/esm-app/worker-dep.mjs: -------------------------------------------------------------------------------- 1 | function dummyOperation (a) { 2 | return a + 'dummy operation with concat in worker-dep' 3 | } 4 | 5 | dummyOperation('should not crash') 6 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('./src/helpers/bundler-register') 4 | require('./src/helpers/register') 5 | require('./src/helpers/rewriter/loader') 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-cypress/src/after-run.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const cypressPlugin = require('./cypress-plugin') 4 | 5 | module.exports = cypressPlugin.afterRun.bind(cypressPlugin) 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/integration-test/pages/index.js: -------------------------------------------------------------------------------- 1 | export default function Home () { 2 | return ( 3 |
4 |

Hello World

5 |
6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/hardcoded-password-functions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const pswd = 'A3TMAWZUKIWR6O0OGR7B' 4 | 5 | module.exports = { 6 | pswd 7 | } 8 | -------------------------------------------------------------------------------- /vendor/dist/opentracing/test/opentracing_api.d.ts: -------------------------------------------------------------------------------- 1 | export declare function opentracingAPITests(): void; 2 | export default opentracingAPITests; 3 | //# sourceMappingURL=opentracing_api.d.ts.map -------------------------------------------------------------------------------- /.github/codeql_config.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL config" 2 | 3 | paths-ignore: 4 | - 'benchmark' 5 | - 'integration-tests' 6 | - 'node-upstream-tests' 7 | - 'packages/**/test' 8 | - 'scripts' 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-esm/farewell.feature: -------------------------------------------------------------------------------- 1 | Feature: Farewell 2 | Scenario: Say farewell 3 | When the greeter says farewell 4 | Then I should have heard "farewell" 5 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/rewriter/node_modules/test-trace-callback/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function test (cb) { 4 | cb() 5 | } 6 | 7 | module.exports = { test } 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-avsc/test/schemas/advanced_users.avro: -------------------------------------------------------------------------------- 1 | $alyssa@example.com 2 | themedarknotificationsenabledvippremiumbinarydatametadata12345678123 Main StMetropolis 3 | 12345 -------------------------------------------------------------------------------- /packages/datadog-plugin-bunyan/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest('bunyan', 'trentm/node-bunyan', 'latest') 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-connect/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest('connect', 'senchalabs/connect', 'latest') 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-cypress/src/after-spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const cypressPlugin = require('./cypress-plugin') 4 | 5 | module.exports = cypressPlugin.afterSpec.bind(cypressPlugin) 6 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/promise.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../src/promise') 4 | 5 | const assertPromise = require('./helpers/promise') 6 | 7 | assertPromise('promise') 8 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/promise.suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest('promise', 'then/promise', 'latest') 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-amqp10/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest('amqp10', 'noodlefrenzy/node-amqp10', 'latest') 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-dns/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import dns from 'dns' 3 | 4 | dns.lookup('fakedomain.faketld', { all: true }, (err, address, family) => {}) 5 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/hardcoded-secret-functions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const awsToken = 'A3TMAWZUKIWR6O0OGR7B' 4 | 5 | module.exports = { 6 | awsToken 7 | } 8 | -------------------------------------------------------------------------------- /ext/kinds.d.ts: -------------------------------------------------------------------------------- 1 | declare const kinds: { 2 | SERVER: 'server' 3 | CLIENT: 'client' 4 | PRODUCER: 'producer' 5 | CONSUMER: 'consumer' 6 | INTERNAL: 'internal' 7 | } 8 | 9 | export = kinds 10 | -------------------------------------------------------------------------------- /ext/kinds.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | SERVER: 'server', 5 | CLIENT: 'client', 6 | PRODUCER: 'producer', 7 | CONSUMER: 'consumer', 8 | INTERNAL: 'internal' 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/appsec/esm-security-controls/validator.mjs: -------------------------------------------------------------------------------- 1 | export function validate (input) { 2 | return true 3 | } 4 | 5 | export function validateNotConfigured (input) { 6 | return true 7 | } 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-di/test-hit-breakpoint.feature: -------------------------------------------------------------------------------- 1 | 2 | Feature: Greeting 3 | 4 | Scenario: Say hello 5 | When the greeter says hello 6 | Then I should have heard "hello" 7 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-test-management/disabled.feature: -------------------------------------------------------------------------------- 1 | Feature: Disabled 2 | Scenario: Say disabled 3 | When the greeter says disabled 4 | Then I should have heard "disabled" 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import/jest-bad-import-test-pass.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | it('works', () => { 6 | assert.strictEqual(true, true) 7 | }) 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/features/greetings.feature: -------------------------------------------------------------------------------- 1 | Feature: Greetings 2 | Scenario: Say greetings 3 | When the greeter says greetings 4 | Then I should have heard "greetings" 5 | -------------------------------------------------------------------------------- /packages/datadog-plugin-couchbase/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | // const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | // suiteTest('couchbase', 'couchbase/couchnode', 'v3.1.3') 6 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/app/layout.js: -------------------------------------------------------------------------------- 1 | export default function RootLayout ({ children }) { 2 | return ( 3 | 4 | {children} 5 | 6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/constants.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const HEADER_NAME_VALUE_SEPARATOR = ': ' 4 | 5 | module.exports = { 6 | HEADER_NAME_VALUE_SEPARATOR 7 | } 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/ritm-tests/module-a.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { b } = require('./module-b') 4 | 5 | module.exports.a = () => { return 'Called by AJ' } 6 | module.exports.b = () => { b() } 7 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import/jest-bad-import-test-pass-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | it('works', () => { 6 | assert.strictEqual(true, true) 7 | }) 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jestEnvironmentBadInit.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('dd-trace').init({ 4 | service: 'dd-trace-bad-init' 5 | }) 6 | 7 | module.exports = require('jest-environment-node') 8 | -------------------------------------------------------------------------------- /integration-tests/cypress/support/e2e.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line 2 | if (Cypress.env('ENABLE_INCOMPATIBLE_PLUGIN')) { 3 | require('cypress-fail-fast') 4 | } 5 | require('dd-trace/ci/cypress/support') 6 | -------------------------------------------------------------------------------- /integration-tests/esbuild/build.esm.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import esbuild from 'esbuild' 4 | 5 | import commonConfig from './build.esm.common-config.js' 6 | 7 | await esbuild.build(commonConfig) 8 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/promise-js.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../src/promise-js') 4 | 5 | const assertPromise = require('./helpers/promise') 6 | 7 | assertPromise('promise-js') 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/src/services/default.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const BaseAwsSdkPlugin = require('../base') 4 | 5 | class Default extends BaseAwsSdkPlugin {} 6 | 7 | module.exports = Default 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/mongoose-vulnerable-method.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function vulnerableMethod (Test, filter, cb) { 4 | Test.find(filter).then(cb) 5 | } 6 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/security-controls/resources/sanitizer_default.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function sanitize (input) { 4 | return `sanitized ${input}` 5 | } 6 | 7 | module.exports = sanitize 8 | -------------------------------------------------------------------------------- /scripts/helpers/color.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors 4 | module.exports = { 5 | GRAY: '\\033[1;90m', 6 | CYAN: '\\033[1;36m', 7 | NONE: '\\033[0m' 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ## License 2 | 3 | This work is dual-licensed under Apache 2.0 or BSD3. 4 | You may select, at your option, one of the above-listed licenses. 5 | 6 | `SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause` 7 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-http/README.md: -------------------------------------------------------------------------------- 1 | This benchmarks HTTP requests from client to server. 2 | 3 | The variants are with the tracer and without it, and instrumenting on the server 4 | and the client separately. 5 | -------------------------------------------------------------------------------- /ext/formats.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | TEXT_MAP: 'text_map', 5 | HTTP_HEADERS: 'http_headers', 6 | BINARY: 'binary', 7 | LOG: 'log', 8 | TEXT_MAP_DSM: 'text_map_dsm' 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-di/test-not-hit-breakpoint.feature: -------------------------------------------------------------------------------- 1 | 2 | Feature: Greeting 3 | 4 | Scenario: Say hello 5 | When the greeter says hello 6 | Then I should have flakily heard "hello" 7 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-test-management/quarantine.feature: -------------------------------------------------------------------------------- 1 | Feature: Quarantine 2 | Scenario: Say quarantine 3 | When the greeter says quarantine 4 | Then I should have heard "quarantine" 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import-torn-down/jest-bad-import-test-pass.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | it('works', () => { 6 | assert.strictEqual(true, true) 7 | }) 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/office-addin-mock/dependency.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('office-addin-mock') 4 | 5 | function sum (a, b) { 6 | return a + b 7 | } 8 | 9 | module.exports = sum 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/fixtures/kinesis.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const kinesis = {} 4 | 5 | kinesis.describe = { 6 | StreamName: 'test_aws_stream' 7 | } 8 | 9 | module.exports = kinesis 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/app/api/appDir/[name]/route.js: -------------------------------------------------------------------------------- 1 | import { NextResponse } from 'next/server' 2 | 3 | export async function GET (_request) { 4 | return NextResponse.json({}, { status: 200 }) 5 | } 6 | -------------------------------------------------------------------------------- /packages/dd-trace/src/llmobs/storage.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { storage: createStorage } = require('../../../datadog-core') 4 | const storage = createStorage('llmobs') 5 | 6 | module.exports = { storage } 7 | -------------------------------------------------------------------------------- /packages/dd-trace/src/msgpack/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const MsgpackChunk = require('./chunk') 4 | const { MsgpackEncoder } = require('./encoder') 5 | 6 | module.exports = { MsgpackChunk, MsgpackEncoder } 7 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import-torn-down/jest-bad-import-test-pass-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | it('works', () => { 6 | assert.strictEqual(true, true) 7 | }) 8 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/helpers/instrumentations.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const sym = Symbol.for('_ddtrace_instrumentations') 4 | 5 | global[sym] = global[sym] || {} 6 | 7 | module.exports = global[sym] 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/src/services/sfn.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const Stepfunctions = require('./stepfunctions') 3 | class Sfn extends Stepfunctions { 4 | static id = 'sfn' 5 | } 6 | 7 | module.exports = Sfn 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-axios/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import axios from 'axios' 3 | 4 | axios.get('/foo') 5 | .then(() => {}) 6 | .catch(() => {}) 7 | .finally(() => {}) 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-fastify/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import fastify from 'fastify' 2 | import { createAndStartServer } from './helper.mjs' 3 | 4 | const app = fastify() 5 | 6 | createAndStartServer(app) 7 | -------------------------------------------------------------------------------- /packages/dd-trace/src/guardrails/util.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function isTrue (str) { 4 | str = String(str).toLowerCase() 5 | return str === 'true' || str === '1' 6 | } 7 | 8 | module.exports = { isTrue: isTrue } 9 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/bad-formatted-rules.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.2", 3 | "metadata": { 4 | "rules_version": "1.5.0" 5 | }, 6 | "rules": [ 7 | { 8 | 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /vendor/dist/opentracing/test/mocktracer_implemenation.d.ts: -------------------------------------------------------------------------------- 1 | declare function mockTracerimplementationTests(): void; 2 | export default mockTracerimplementationTests; 3 | //# sourceMappingURL=mocktracer_implemenation.d.ts.map -------------------------------------------------------------------------------- /packages/dd-trace/src/opentracing/propagation/http.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const TextMapPropagator = require('./text_map') 4 | 5 | class HttpPropagator extends TextMapPropagator {} 6 | 7 | module.exports = HttpPropagator 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/plugins/util/__test__/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS for testing purposes 2 | packages/dd-trace/test/plugins/util/* @datadog-dd-trace-js 3 | packages/dd-trace/test/plugins/util/test.spec.js @datadog-ci-app 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use the workspace version of TypeScript instead of VSCode's bundled version 3 | "typescript.tsdk": "node_modules/typescript/lib", 4 | "typescript.enablePromptUseWorkspaceTsdk": true, 5 | } 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-impacted-test/impacted-test.feature: -------------------------------------------------------------------------------- 1 | Feature: Impacted Test 2 | Scenario: Say impacted test 3 | When the greeter says impacted test 4 | Then I should have heard "impacted test" 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/vitest-tests/bad-sum.mjs: -------------------------------------------------------------------------------- 1 | export function sum (a, b) { 2 | const localVar = 10 3 | if (a > 10) { 4 | throw new Error('a is too large') 5 | } 6 | return a + b + localVar - localVar 7 | } 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/src/services/states.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const Stepfunctions = require('./stepfunctions') 3 | class States extends Stepfunctions { 4 | static id = 'states' 5 | } 6 | 7 | module.exports = States 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-azure-functions/test/fixtures/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "extensionBundle": { 4 | "id": "Microsoft.Azure.Functions.ExtensionBundle", 5 | "version": "[4.0.0, 4.28.0)" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-fastify/test/integration-test/server2.mjs: -------------------------------------------------------------------------------- 1 | import Fastify from 'fastify' 2 | import { createAndStartServer } from './helper.mjs' 3 | 4 | const app = Fastify.default() 5 | 6 | createAndStartServer(app) 7 | -------------------------------------------------------------------------------- /ext/scopes.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | ASYNC_RESOURCE: 'async_resource', 5 | ASYNC_LOCAL_STORAGE: 'async_local_storage', 6 | ASYNC_HOOKS: 'async_hooks', 7 | SYNC: 'sync', 8 | NOOP: 'noop' 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-impacted-test/impacted-test-2.feature: -------------------------------------------------------------------------------- 1 | Feature: Impacted Test 2 | Scenario: Say impacted test 2 3 | When the greeter says impacted test 4 | Then I should have heard "impacted test" 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-test-management/attempt-to-fix.feature: -------------------------------------------------------------------------------- 1 | Feature: Attempt to fix 2 | Scenario: Say attempt to fix 3 | When the greeter says attempt to fix 4 | Then I should have heard "attempt to fix" 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/office-addin-mock/test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('./dependency') 6 | test('can sum', () => { 7 | assert.strictEqual(sum(1, 2), 3) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/fail-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('fail', () => { 5 | it('can report failed tests', () => { 6 | assert.strictEqual(1 + 2, 4) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/datadog-plugin-fastify/test/integration-test/server1.mjs: -------------------------------------------------------------------------------- 1 | import * as Fastify from 'fastify' 2 | import { createAndStartServer } from './helper.mjs' 3 | 4 | const app = Fastify.default() 5 | 6 | createAndStartServer(app) 7 | -------------------------------------------------------------------------------- /packages/datadog-plugin-ioredis/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import Redis from 'ioredis' 3 | 4 | const client = new Redis({ connectionName: 'test' }) 5 | await client.get('foo') 6 | client.quit() 7 | -------------------------------------------------------------------------------- /packages/datadog-plugin-iovalkey/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import Valkey from 'iovalkey' 3 | 4 | const client = new Valkey({ connectionName: 'test' }) 5 | await client.get('foo') 6 | client.quit() 7 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/tags.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | IAST_ENABLED_TAG_KEY: '_dd.iast.enabled', 5 | IAST_JSON_TAG_KEY: '_dd.iast.json', 6 | IAST_TRACE_METRIC_PREFIX: '_dd.iast.telemetry' 7 | } 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/vitest-test.mjs: -------------------------------------------------------------------------------- 1 | import { describe, test, expect } from 'vitest' 2 | 3 | describe('context', () => { 4 | test('can report passed test', () => { 5 | expect(1 + 2).to.equal(3) 6 | }) 7 | }) 8 | -------------------------------------------------------------------------------- /integration-tests/cypress/e2e/other.cy.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | describe('context', () => { 3 | it('passes', () => { 4 | cy.visit('/') 5 | .get('.hello-world') 6 | .should('have.text', 'Hello World') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/source-map-support/hello/world.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"world.js","sourceRoot":"","sources":["world.ts"],"names":[],"mappings":";;AAAA,4BAEC;AAFD,SAAgB,QAAQ;IACtB,OAAO,aAAa,CAAA,CAAC,gBAAgB;AACvC,CAAC"} -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/langchain.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { addHook, getHooks } = require('./helpers/instrument') 4 | 5 | for (const hook of getHooks('@langchain/core')) { 6 | addHook(hook, exports => exports) 7 | } 8 | -------------------------------------------------------------------------------- /.github/actions/node/latest/action.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Latest 2 | description: Install the latest version of Node.js 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: ./.github/actions/node 7 | with: 8 | version: latest 9 | -------------------------------------------------------------------------------- /ext/scopes.d.ts: -------------------------------------------------------------------------------- 1 | declare const scopes: { 2 | ASYNC_RESOURCE: 'async_resource', 3 | ASYNC_LOCAL_STORAGE: 'async_local_storage', 4 | ASYNC_HOOKS: 'async_hooks' 5 | SYNC: 'sync' 6 | NOOP: 'noop' 7 | } 8 | 9 | export = scopes 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission-cucumber/automatic-log-submission.feature: -------------------------------------------------------------------------------- 1 | Feature: Automatic Log Submission 2 | Scenario: Run Automatic Log Submission 3 | When we run a test 4 | Then I should have made a log 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission/sum.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const logger = require('./logger') 4 | 5 | module.exports = function (a, b) { 6 | logger.log('info', 'sum function being called') 7 | return a + b 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest/mocked-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | jest.mock('../test/sum.js') 6 | 7 | test('adds 1 + 2 to equal 3', () => { 8 | assert.strictEqual(1 + 2, 3) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/failing.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-test-fail', () => { 5 | it('can fail', () => { 6 | assert.strictEqual(true, false) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/unskippable-test/test-to-run.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('test-to-run', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/vitest-tests/impacted-test.mjs: -------------------------------------------------------------------------------- 1 | import { describe, test, expect } from 'vitest' 2 | 3 | describe('impacted test', () => { 4 | test('can impacted test', () => { 5 | expect(1 + 2).to.equal(4) 6 | }) 7 | }) 8 | -------------------------------------------------------------------------------- /integration-tests/cypress/e2e/disable.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | describe('disable', () => { 3 | it('is disabled', () => { 4 | cy.visit('/') 5 | .get('.hello-world') 6 | .should('have.text', 'Hello Warld') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/ldap-injection-methods.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function executeSearch (client, base, filter) { 4 | return client.search(base, filter) 5 | } 6 | 7 | module.exports = { executeSearch } 8 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/git.properties.credentials: -------------------------------------------------------------------------------- 1 | git.commit.sha=4e7da8069bcf5ffc8023603b95653e2dc99d1c7d 2 | git.repository_url=https://username:password@github.com/datadog/dd-trace-js 3 | git.commit.user.email=user@email.com 4 | -------------------------------------------------------------------------------- /.mocharc.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | color: true, 5 | exit: true, 6 | timeout: 5000, 7 | reporter: 'mocha-multi-reporters', 8 | reporterOption: [ 9 | 'configFile=.mochamultireporterrc.js' 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/sharding-test/sharding-test-1.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('sharding test 1', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/sharding-test/sharding-test-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('sharding test 2', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/sharding-test/sharding-test-3.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('sharding test 3', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/sharding-test/sharding-test-4.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('sharding test 4', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/sharding-test/sharding-test-5.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('sharding test 5', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-early-flake-detection/test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('ci visibility', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/unskippable-test/test-to-skip.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('test-to-skip', () => { 5 | it('can report tests', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/cypress/e2e/quarantine.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | describe('quarantine', () => { 3 | it('is quarantined', () => { 4 | cy.visit('/') 5 | .get('.hello-world') 6 | .should('have.text', 'Hello Warld') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/cypress/e2e/skipped-test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | describe('skipped', () => { 3 | it.skip('skipped', () => { 4 | cy.visit('/') 5 | .get('.hello-world') 6 | .should('have.text', 'Hello World') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/fixtures/cloudwatchlogs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const cloudwatchlogs = {} 4 | 5 | cloudwatchlogs.create = { 6 | logGroupName: 'example_cw_log_group' 7 | } 8 | 9 | module.exports = cloudwatchlogs 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/fixtures/sns.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const sns = {} 4 | 5 | sns.create = { 6 | Name: 'example_aws_topic' 7 | } 8 | 9 | sns.get = { 10 | TopicArn: undefined 11 | } 12 | 13 | module.exports = sns 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-bunyan/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const LogPlugin = require('../../dd-trace/src/plugins/log_plugin') 4 | 5 | class BunyanPlugin extends LogPlugin { 6 | static id = 'bunyan' 7 | } 8 | module.exports = BunyanPlugin 9 | -------------------------------------------------------------------------------- /packages/datadog-plugin-redis/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import redis from 'redis' 3 | 4 | const client = redis.createClient() 5 | 6 | await client.connect() 7 | await client.get('foo') 8 | await client.quit() 9 | -------------------------------------------------------------------------------- /packages/dd-trace/src/datastreams/schemas/schema.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class Schema { 4 | constructor (definition, id) { 5 | this.definition = definition 6 | this.id = id 7 | } 8 | } 9 | 10 | module.exports = { Schema } 11 | -------------------------------------------------------------------------------- /packages/dd-trace/src/debugger/devtools_client/defaults.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | MAX_SNAPSHOTS_PER_SECOND_GLOBALLY: 25, 5 | MAX_SNAPSHOTS_PER_SECOND_PER_PROBE: 1, 6 | MAX_NON_SNAPSHOTS_PER_SECOND_PER_PROBE: 5000 7 | } 8 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-net/README.md: -------------------------------------------------------------------------------- 1 | Benchmarks connections between a net server and net client, doing a simple 2 | echo request. Since we only instrument client-side net connections, our variants 3 | are having the client with and without the tracer. 4 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission-playwright/sum.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const logger = require('./logger') 4 | 5 | module.exports = function (a, b) { 6 | logger.log('info', 'sum function being called') 7 | return a + b 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-management/test-disabled-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('disable tests 2', () => { 5 | it('can disable a test', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/esbuild/skip-external.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../../').init() // dd-trace 4 | 5 | // this should be bundled 6 | require('axios') 7 | 8 | // this is in the external list and should not be bundled 9 | require('knex') 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-pino/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const LogPlugin = require('../../dd-trace/src/plugins/log_plugin') 4 | 5 | class PinoPlugin extends LogPlugin { 6 | static id = 'pino' 7 | } 8 | 9 | module.exports = PinoPlugin 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-winston/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const LogPlugin = require('../../dd-trace/src/plugins/log_plugin') 4 | 5 | class WinstonPlugin extends LogPlugin { 6 | static id = 'winston' 7 | } 8 | module.exports = WinstonPlugin 9 | -------------------------------------------------------------------------------- /packages/dd-trace/src/plugins/util/serverless.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const types = require('../../../../../ext/types') 4 | const web = require('./web') 5 | 6 | const serverless = { ...web, TYPE: types.SERVERLESS } 7 | 8 | module.exports = serverless 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "subproject", 3 | "private": true, 4 | "version": "1.0.0", 5 | "description": "app within repo", 6 | "dependencies": { 7 | "dd-trace": "file:../../.." 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/cypress/e2e/impacted-test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | describe('impacted test', () => { 3 | it('is impacted test', () => { 4 | cy.visit('/') 5 | .get('.hello-world') 6 | .should('have.text', 'Hello World') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/datadog-plugin-opensearch/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import opensearch from '@opensearch-project/opensearch' 3 | 4 | const client = new opensearch.Client({ node: 'http://127.0.0.1:9201' }) 5 | await client.ping() 6 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/fs-promise-way-method.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('fs') 4 | 5 | module.exports = function (methodName, args, cb) { 6 | return fs.promises[methodName](...args).then(cb).catch(cb) 7 | } 8 | -------------------------------------------------------------------------------- /vendor/dist/opentracing/mock_tracer/index.d.ts: -------------------------------------------------------------------------------- 1 | import MockContext from './mock_context'; 2 | import MockSpan from './mock_span'; 3 | import MockTracer from './mock_tracer'; 4 | export { MockTracer, MockSpan, MockContext }; 5 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /.github/actions/node/active-lts/action.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Active LTS 2 | description: Install the current Active LTS version of Node.js 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: ./.github/actions/node 7 | with: 8 | version: active 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission-cucumber/support/sum.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const logger = require('./logger') 4 | 5 | module.exports = function (a, b) { 6 | logger.log('info', 'sum function being called') 7 | return a + b 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/cypress/e2e/spec.cy.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | describe('context', () => { 3 | it('passes', () => { 4 | cy.visit('/') 5 | .get('.hello-world') 6 | .should('have.text', 'Hello World') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/datadog-plugin-amqplib/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | // TODO: restore use of latest branch when it gets a matching tag 6 | suiteTest('amqplib', 'amqp-node/amqplib', 'v0.9.0') 7 | -------------------------------------------------------------------------------- /packages/datadog-plugin-azure-functions/test/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azure-function-tests", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "./server.mjs", 6 | "scripts": { 7 | "start": "func start" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-elasticsearch/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import elasticsearch from '@elastic/elasticsearch' 3 | 4 | const client = new elasticsearch.Client({ node: 'http://127.0.0.1:9200' }) 5 | 6 | await client.ping() 7 | -------------------------------------------------------------------------------- /packages/datadog-plugin-ioredis/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const RedisPlugin = require('../../datadog-plugin-redis/src') 4 | 5 | class IORedisPlugin extends RedisPlugin { 6 | static id = 'ioredis' 7 | } 8 | 9 | module.exports = IORedisPlugin 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-koa/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest('koa', 'koajs/koa', 'latest') 6 | 7 | // TODO enable this 8 | // suiteTest('@koa/router', 'koajs/router', 'latest') 9 | -------------------------------------------------------------------------------- /packages/dd-trace/src/aiguard/noop.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class NoopAIGuard { 4 | evaluate (messages, opts) { 5 | return Promise.resolve({ action: 'ALLOW', reason: 'AI Guard is not enabled' }) 6 | } 7 | } 8 | 9 | module.exports = NoopAIGuard 10 | -------------------------------------------------------------------------------- /packages/dd-trace/src/crashtracking/noop.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class NoopCrashtracker { 4 | configure () {} 5 | start () {} 6 | withProfilerSerializing (f) { 7 | return f() 8 | } 9 | } 10 | 11 | module.exports = new NoopCrashtracker() 12 | -------------------------------------------------------------------------------- /packages/dd-trace/src/llmobs/constants/text.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | DROPPED_VALUE_TEXT: "[This value has been dropped because this span's size exceeds the 1MB size limit.]", 5 | UNSERIALIZABLE_VALUE_TEXT: 'Unserializable value' 6 | } 7 | -------------------------------------------------------------------------------- /packages/dd-trace/src/opentracing/propagation/binary.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class BinaryPropagator { 4 | inject (spanContext, carrier) {} 5 | 6 | extract (carrier) { 7 | return null 8 | } 9 | } 10 | 11 | module.exports = BinaryPropagator 12 | -------------------------------------------------------------------------------- /benchmark/sirun/shimmer-runtime/README.md: -------------------------------------------------------------------------------- 1 | This is a test of shimmer performance at startup, meaning the actual shimming operations of shimmer.wrap and shimmer.wrapFunction. 2 | 3 | There are variants for different kinds of functions, and for both types of shimming. 4 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-parsing-error/parsing-error.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { expect } = require('chao') 4 | 5 | describe('test-parsing-error', () => { 6 | it('can report tests', () => { 7 | expect(1 + 2).to.equal(3) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/timeout-test/timeout-test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | jest.setTimeout(100) 3 | describe('ci visibility', () => { 4 | it('will timeout', (done) => { 5 | setTimeout(() => { 6 | done() 7 | }, 200) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/vitest-tests/coverage-test.mjs: -------------------------------------------------------------------------------- 1 | import { describe, test, expect } from 'vitest' 2 | import { sum } from './sum' 3 | 4 | describe('code coverage', () => { 5 | test('passes', () => { 6 | expect(sum(1, 2)).to.equal(3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/check-require-cache/bad-order.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | 4 | require('express') // package required before tracer 5 | const tracer = require('../../../../../') 6 | tracer.init() 7 | 8 | process.exit() 9 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/helpers/check-require-cache/good-order.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | 4 | const tracer = require('../../../../../') 5 | require('express') // package required after tracer 6 | tracer.init() 7 | 8 | process.exit() 9 | -------------------------------------------------------------------------------- /packages/datadog-plugin-memcached/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import Memcached from 'memcached' 3 | 4 | const memcached = new Memcached('localhost:11211', { retries: 0 }) 5 | await memcached.get('test', () => {}) 6 | memcached.end() 7 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/app-dir/datadog.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | module.exports = require('../../../..').init({ 3 | flushInterval: 0, 4 | appsec: { 5 | enabled: true, 6 | rules: path.join(__dirname, 'appsec-rules.json') 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /vendor/dist/opentracing/test/noop_implementation.d.ts: -------------------------------------------------------------------------------- 1 | import { Tracer } from '../index'; 2 | export declare function noopImplementationTests(createTracer?: () => Tracer): void; 3 | export default noopImplementationTests; 4 | //# sourceMappingURL=noop_implementation.d.ts.map -------------------------------------------------------------------------------- /.github/chainguard/self.gitlab.read.sts.yaml: -------------------------------------------------------------------------------- 1 | issuer: https://gitlab.ddbuild.io 2 | 3 | subject_pattern: "project_path:DataDog/apm-reliability/dd-trace-js:ref_type:(branch|tag):ref:.*" 4 | 5 | permissions: 6 | contents: read 7 | actions: read 8 | pull_requests: read 9 | -------------------------------------------------------------------------------- /benchmark/sirun/shimmer-startup/README.md: -------------------------------------------------------------------------------- 1 | This is a test of shimmer performance at runtime, meaning the performance of functions shimmed by shimmer.wrap and shimmer.wrapFunction. 2 | 3 | There are variants for different kinds of functions, and for both types of shimming. 4 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-flaky/flaky-fails.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | describe('test-flaky-test-retries', () => { 6 | it('can retry failed tests', () => { 7 | assert.deepStrictEqual(1, 2) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-plugin-tests/jest-test-suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | describe('jest-test-suite-visibility', () => { 6 | it('works', () => { 7 | assert.strictEqual(true, true) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-parsing-error/parsing-error-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { expect } = require('chao') 4 | 5 | describe('test-parsing-error-2', () => { 6 | it('can report tests', () => { 7 | expect(1 + 2).to.equal(3) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import AWS from 'aws-sdk' 3 | 4 | const s3 = new AWS.S3({ endpoint: 'http://127.0.0.1:4566', region: 'us-east-1', s3ForcePathStyle: true }) 5 | 6 | s3.listBuckets({}, e => e) 7 | -------------------------------------------------------------------------------- /packages/datadog-plugin-pino/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import ddtrace from 'dd-trace' 2 | import pino from 'pino' 3 | 4 | ddtrace.init({ 5 | logInjection: true 6 | }) 7 | 8 | const logger = pino({ name: 'test-logger' }) 9 | 10 | logger.info('test xyz') 11 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/pages-dir/datadog.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | module.exports = require('../../../..').init({ 3 | flushInterval: 0, 4 | appsec: { 5 | enabled: true, 6 | rules: path.join(__dirname, 'appsec-rules.json') 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/mongodb-vulnerable-method.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function vulnerableMethod (collection, filter) { 4 | // comment to force a vulnerability in line 5 instead of 4 5 | return collection.find(filter) 6 | } 7 | -------------------------------------------------------------------------------- /benchmark/sirun/appsec/README.md: -------------------------------------------------------------------------------- 1 | This benchmarks HTTP requests from client to server. 2 | 3 | The variants are: 4 | - control tracer without appsec 5 | - tracer with appsec but no attacks 6 | - control tracer without appsec but with attacks 7 | - tracer with appsec and attacks 8 | 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/dynamic-instrumentation/parallel-test-hit-breakpoint-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('dynamic-instrumentation 2', () => { 5 | it('is not retried', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-management/__snapshots__/test-snapshot-attempt-to-fix-1.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing 2 | 3 | exports[`attempt to fix snapshot is flaky 1`] = `3` 4 | exports[`attempt to fix snapshot is flaky 2`] = `"a"` 5 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-management/__snapshots__/test-snapshot-attempt-to-fix-2.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing 2 | 3 | exports[`attempt to fix snapshot 2 is flaky 1`] = `3` 4 | exports[`attempt to fix snapshot 2 is flaky 2`] = `"a"` 5 | -------------------------------------------------------------------------------- /packages/dd-trace/src/plugins/inbound.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const TracingPlugin = require('./tracing') 4 | 5 | class InboundPlugin extends TracingPlugin { 6 | bindFinish (ctx) { 7 | return ctx.parentStore 8 | } 9 | } 10 | 11 | module.exports = InboundPlugin 12 | -------------------------------------------------------------------------------- /packages/dd-trace/src/profiling/profilers/event_plugins/dns.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const EventPlugin = require('./event') 4 | 5 | class DNSPlugin extends EventPlugin { 6 | static id = 'dns' 7 | 8 | static entryType = 'dns' 9 | } 10 | 11 | module.exports = DNSPlugin 12 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/resources/eval-methods.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | runEval: (code, result) => { 5 | const script = `(${code}, result)` 6 | 7 | // eslint-disable-next-line no-eval 8 | return eval(script) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.gitlab/one-pipeline.locked.yml: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE MANUALLY 2 | # This file is auto-generated by automation. 3 | include: 4 | - remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/04f6a88e3db67cb88821632d138a2a5c3105ba59760bd3dfc60b54733501ecc3/one-pipeline.yml 5 | -------------------------------------------------------------------------------- /docs/typedoc.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | excludeExternals: true, 5 | excludePrivate: true, 6 | excludeProtected: true, 7 | // includeDeclarations: true, 8 | // mode: 'file', 9 | name: 'dd-trace', 10 | out: 'out', 11 | readme: 'API.md' 12 | } 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/timeout-fail.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe('mocha-test-timeout-fail', () => { 4 | it('times out', function (done) { 5 | this.timeout(100) 6 | setTimeout(() => { 7 | done() 8 | }, 200) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/vitest-tests/coverage-test-zero.mjs: -------------------------------------------------------------------------------- 1 | import { describe, test, expect } from 'vitest' 2 | import { sum } from './sum' 3 | 4 | describe('code coverage', () => { 5 | test('passes', () => { 6 | expect(typeof sum === 'function').toBe(true) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/init/trace.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | // eslint-disable-next-line no-console 4 | console.log(!!global._ddtrace) 5 | // eslint-disable-next-line no-console 6 | console.log('instrumentation source:', global._ddtrace._tracer._config.instrumentationSource) 7 | process.exit() 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-tedious/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest({ 6 | modName: 'tedious', 7 | repoUrl: 'tediousjs/tedious', 8 | commitish: 'latest', 9 | testCmd: 'npm run test' 10 | }) 11 | -------------------------------------------------------------------------------- /.github/actions/node/oldest-maintenance-lts/action.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Oldest Maintenance LTS 2 | description: Install the oldest Maintenance LTS version of Node.js 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: ./.github/actions/node 7 | with: 8 | version: oldest 9 | -------------------------------------------------------------------------------- /benchmark/sirun/get-variants.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | 5 | const path = require('path') 6 | const metaJson = require(path.join(process.cwd(), 'meta.json')) 7 | const variants = Object.keys(metaJson.variants) 8 | 9 | process.stdout.write(variants.join(' ')) 10 | -------------------------------------------------------------------------------- /docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["es2017"], 4 | "moduleResolution": "node", 5 | "module": "commonjs", 6 | "baseUrl": ".", 7 | "strict": true, 8 | "types": ["node"] 9 | }, 10 | "files": [ 11 | "../index.d.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/dynamic-instrumentation/dependency.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function (a, b) { 4 | const localVariable = 2 5 | if (a > 10) { 6 | throw new Error('a is too big') 7 | } 8 | return a + b + localVariable - localVariable 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-plugin-tests/jest-inject-globals.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { describe, it, expect } = require('@jest/globals') 4 | 5 | describe('jest-inject-globals', () => { 6 | it('will be run', () => { 7 | expect(true).toEqual(true) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/timeout-pass.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | describe('mocha-test-timeout-pass', () => { 4 | it('does not timeout', function (done) { 5 | this.timeout(300) 6 | setTimeout(() => { 7 | done() 8 | }, 200) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-management/__image_snapshots__/test-snapshot-image-js-snapshot-can-match-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/integration-tests/ci-visibility/test-management/__image_snapshots__/test-snapshot-image-js-snapshot-can-match-1-snap.png -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/ci-visibility-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('./sum') 6 | describe('ci visibility', () => { 7 | it('can report tests', () => { 8 | assert.strictEqual(sum(1, 2), 3) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/my-nyc.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | // non default name so that it only gets picked up intentionally 4 | module.exports = { 5 | exclude: ['node_modules/**'], 6 | include: process.env.NYC_INCLUDE ? JSON.parse(process.env.NYC_INCLUDE) : ['ci-visibility/test/**'] 7 | } 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-graphql/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest({ 6 | modName: 'graphql', 7 | repoUrl: 'graphql/graphql-js', 8 | commitish: 'latest', 9 | testCmd: 'npm run testonly' 10 | }) 11 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/security-controls/resources/node_modules/sanitizer/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function sanitize (input) { 4 | return `sanitized ${input}` 5 | } 6 | 7 | module.exports = { 8 | sanitize, 9 | 10 | nested: { 11 | sanitize 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/dd-trace/test/fixtures/config/span-sampling-rules.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "service": "mysql", "name": "mysql.query", "sample_rate": 0.0, "max_per_second": 1 }, 3 | { "service": "mysql", "sample_rate": 0.5 }, 4 | { "service": "mysql", "sample_rate": 1.0 }, 5 | { "sample_rate": 0.1 } 6 | ] 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [*.md] 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /.github/actions/node/newest-maintenance-lts/action.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Newst Maintenance LTS 2 | description: Install the newest Maintenance LTS version of Node.js 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: ./.github/actions/node 7 | with: 8 | version: maintenance 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features/farewell.feature: -------------------------------------------------------------------------------- 1 | Feature: Farewell 2 | Scenario: Say farewell 3 | When the greeter says farewell 4 | Then I should have heard "farewell" 5 | Scenario: Say whatever 6 | When the greeter says whatever 7 | Then I should have heard "whatever" 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-fast-check/jest-no-fast-check.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | describe('fast check with seed', () => { 6 | it('should include seed (with seed=12)', () => { 7 | assert.deepStrictEqual(1 + 2, 3) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/playwright-did-not-run/did-not-run.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, expect } = require('@playwright/test') 4 | 5 | test.describe('did not run', () => { 6 | test('because of early bail', async () => { 7 | expect(true).toBe(false) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/source-map-support/hello/world.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.sayHello = sayHello; 4 | function sayHello() { 5 | return 'hello world'; // BREAKPOINT: / 6 | } 7 | //# sourceMappingURL=world.js.map -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/dd-trace-api.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { addHook } = require('./helpers/instrument') 4 | 5 | // Empty hook just to make the plugin load. 6 | // TODO: Add version range when the module is released on npm. 7 | addHook({ name: 'dd-trace-api' }, api => api) 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-bunyan/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import ddtrace from 'dd-trace' 2 | import bunyan from 'bunyan' 3 | 4 | ddtrace.init({ 5 | logInjection: true 6 | }) 7 | 8 | const logger = bunyan.createLogger({ name: 'test-logger' }) 9 | 10 | logger.info('test xyz') 11 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/middleware.js: -------------------------------------------------------------------------------- 1 | import { NextResponse } from 'next/server' 2 | 3 | export default function middleware () { 4 | // the existence of this file will test that having middleware 5 | // doesn't break instrumentation in tests 6 | return NextResponse.next() 7 | } 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/error/not_found.js: -------------------------------------------------------------------------------- 1 | export async function getServerSideProps (ctx) { 2 | return { 3 | notFound: true 4 | } 5 | } 6 | 7 | export default function NotFound () { 8 | return ( 9 |
10 | Not found! 11 |
12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-opensearch/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const ElasticsearchPlugin = require('../../datadog-plugin-elasticsearch/src') 4 | 5 | class OpenSearchPlugin extends ElasticsearchPlugin { 6 | static id = 'opensearch' 7 | } 8 | 9 | module.exports = OpenSearchPlugin 10 | -------------------------------------------------------------------------------- /packages/dd-trace/test/lambda/fixtures/datadog-lambda.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const _tracer = require('../../../../dd-trace') 4 | 5 | const datadog = (handler) => async (...args) => { 6 | return _tracer.wrap('aws.lambda', {}, handler)(...args) 7 | } 8 | 9 | module.exports = datadog 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-di/support/sum.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function funSum (a, b) { 4 | const localVariable = 2 5 | if (a > 10) { 6 | throw new Error('the number is too big') 7 | } 8 | 9 | return a + b + localVariable 10 | } 11 | 12 | module.exports = funSum 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/playwright-did-not-run/fail-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, expect } = require('@playwright/test') 4 | 5 | test.describe('failing test', () => { 6 | test('fails and causes early bail', async () => { 7 | expect(true).toBe(false) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/ci-visibility-test-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('./sum') 6 | describe('ci visibility 2', () => { 7 | it('can report tests 2', () => { 8 | assert.strictEqual(sum(1, 2), 3) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/datadog-plugin-fetch/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | 3 | // An arbitrary port is used here as we just need a request even if it fails. 4 | global.fetch('http://localhost:55555/foo') 5 | .then((response) => {}) 6 | .then((data) => {}) 7 | .catch((err) => {}) 8 | -------------------------------------------------------------------------------- /benchmark/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const execSync = require('child_process').execSync 4 | const exec = cmd => execSync(cmd, { stdio: [0, 1, 2] }) 5 | 6 | exec('node benchmark/core') 7 | exec('node benchmark/scope') 8 | exec('node benchmark/dd-trace') 9 | exec('node benchmark/openfeature') 10 | -------------------------------------------------------------------------------- /packages/datadog-core/src/utils/src/pick.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function pick (object, props) { 4 | const result = {} 5 | props.forEach(prop => { 6 | if (Object.hasOwn(object, prop)) { 7 | result[prop] = object[prop] 8 | } 9 | }) 10 | return result 11 | } 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-langchain/src/handlers/default.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class LangChainHandler { 4 | // no-op for default handler 5 | extractProvider (instance) {} 6 | 7 | // no-op for default handler 8 | extractModel (instance) {} 9 | } 10 | 11 | module.exports = LangChainHandler 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-sharedb/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import ShareDB from 'sharedb' 3 | 4 | const backend = new ShareDB({ presence: true }) 5 | const connection = backend.connect() 6 | await connection.get('some-collection', 'some-id').fetch() 7 | connection.close() 8 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/taint-tracking/secure-marks-generator.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | let next = 0 4 | 5 | function getNextSecureMark () { 6 | return (1 << next++) >>> 0 7 | } 8 | 9 | function reset () { 10 | next = 0 11 | } 12 | 13 | module.exports = { getNextSecureMark, reset } 14 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/other/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "other", 3 | "version": "1.0.0-rc.1", 4 | "description": "", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "", 9 | "license": "ISC", 10 | "private": true 11 | } 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-early-flake-detection/__image_snapshots__/jest-image-snapshot-js-snapshot-can-match-1-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-trace-js/HEAD/integration-tests/ci-visibility/test-early-flake-detection/__image_snapshots__/jest-image-snapshot-js-snapshot-can-match-1-snap.png -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-total-code-coverage/test-run.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('./used-dependency') 6 | describe('test-run', () => { 7 | it('can report tests', () => { 8 | assert.strictEqual(sum(1, 2), 3) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/source-map-support/scripts/build-typescript.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | npx --package=typescript -- tsc --sourceMap \ 4 | integration-tests/debugger/target-app/source-map-support/typescript.ts \ 5 | integration-tests/debugger/target-app/source-map-support/hello/world.ts 6 | -------------------------------------------------------------------------------- /integration-tests/esbuild/koa.mjs: -------------------------------------------------------------------------------- 1 | import Koa from 'koa' 2 | import Router from '@koa/router' 3 | 4 | const app = new Koa() 5 | 6 | const fooRouter = new Router() 7 | 8 | fooRouter.get('/foo', (ctx) => { 9 | ctx.body = 'foo' 10 | }) 11 | 12 | app.use(fooRouter.routes()) 13 | 14 | app.listen(3000) 15 | -------------------------------------------------------------------------------- /integration-tests/telemetry-forwarder.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Implemented this in bash instead of Node.js for two reasons: 4 | # 1. It's trivial in bash. 5 | # 2. We're using NODE_OPTIONS in tests to init the tracer, and we don't want that for this script. 6 | 7 | echo "$1 $(cat -)" >> $FORWARDER_OUT 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-limitd-client/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import LimitdClient from 'limitd-client' 3 | 4 | const limitd = new LimitdClient('limitd://127.0.0.1:9231', function (err, resp) {}) 5 | 6 | limitd.take('user', 'test', () => {}) 7 | 8 | limitd.disconnect() 9 | -------------------------------------------------------------------------------- /packages/dd-trace/test/ci-visibility/dynamic-instrumentation/target-app/di-dependency.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function (a, b) { 4 | const localVar = 1 5 | if (a > 10) { 6 | throw new Error('a is too big') 7 | } 8 | return a + b + localVar // location of the breakpoint 9 | } 10 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | Note: If you're viewing this `docs/` directory on GitHub 2 | you'll find that none of the links work and that most of 3 | the content is missing. This directory simply contains 4 | base files used to generate docs for the API docs site: 5 | 6 | [API Documentation](https://datadoghq.dev/dd-trace-js/) 7 | -------------------------------------------------------------------------------- /ext/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as formats from './formats' 2 | import * as kinds from './kinds' 3 | import * as priority from './priority' 4 | import * as tags from './tags' 5 | import * as types from './types' 6 | import * as exporters from './exporters' 7 | 8 | export { formats, kinds, priority, tags, types, exporters } 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import/jest-bad-import-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | it('will fail', () => { 6 | setTimeout(() => { 7 | const sum = require('./off-timing-import.js') 8 | 9 | assert.strictEqual(sum(1, 2), 3) 10 | }, 0) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-package-mock/non-dependency-mock-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const hello = require('some-package') 6 | 7 | test('hello function returns correct greeting', () => { 8 | assert.strictEqual(hello(), 'Hello, mocked world!') 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/subproject-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const dependency = require('./dependency') 6 | 7 | describe('subproject-test', () => { 8 | it('can run', () => { 9 | assert.strictEqual(dependency(1, 2), 3) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/efd-parallel/ci-visibility-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('../sum') 6 | 7 | describe('ci visibility', () => { 8 | it('can report tests', () => { 9 | assert.deepStrictEqual(sum(1, 2), 3) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/error/get_server_side_props.js: -------------------------------------------------------------------------------- 1 | export async function getServerSideProps (ctx) { 2 | throw new Error('fail') 3 | } 4 | 5 | export default function GetServerSideProps () { 6 | return ( 7 |
8 | Get Server Side Props! 9 |
10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-undici/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const FetchPlugin = require('../../datadog-plugin-fetch/src/index.js') 4 | 5 | class UndiciPlugin extends FetchPlugin { 6 | static id = 'undici' 7 | static prefix = 'tracing:apm:undici:fetch' 8 | } 9 | 10 | module.exports = UndiciPlugin 11 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/security-controls/resources/custom_input_validator.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function validate (input) { 4 | return input 5 | } 6 | 7 | function validateObject (input) { 8 | return input 9 | } 10 | 11 | module.exports = { 12 | validate, 13 | validateObject 14 | } 15 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/security-controls/resources/node_modules/anotherlib/node_modules/sanitizer/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function sanitize (input) { 4 | return `sanitized ${input}` 5 | } 6 | 7 | module.exports = { 8 | sanitize, 9 | 10 | nested: { 11 | sanitize 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /register.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* eslint n/no-unsupported-features/node-builtins: ['error', { version: '>=20.6.0', allowExperimental: true }] */ 4 | 5 | const { register } = require('node:module') 6 | const { pathToFileURL } = require('node:url') 7 | 8 | register('./loader-hook.mjs', pathToFileURL(__filename)) 9 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-mock-bypass-require/logger.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const winston = require('winston') 4 | 5 | module.exports = winston.createLogger({ 6 | level: 'info', 7 | format: winston.format.simple(), 8 | transports: [ 9 | new winston.transports.Console() 10 | ] 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-package-mock/non-dependency-mock-test-3.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const hello = require('some-package') 6 | 7 | test('hello function returns correct greeting', () => { 8 | assert.strictEqual(hello(), 'Hello, mocked world!') 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-package-mock/non-dependency-mock-test-4.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const hello = require('some-package') 6 | 7 | test('hello function returns correct greeting', () => { 8 | assert.strictEqual(hello(), 'Hello, mocked world!') 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-package-mock/non-dependency-mock-test-5.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const hello = require('some-package') 6 | 7 | test('hello function returns correct greeting', () => { 8 | assert.strictEqual(hello(), 'Hello, mocked world!') 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-package-mock/non-dependency-mock-test-6.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const hello = require('some-package') 6 | 7 | test('hello function returns correct greeting', () => { 8 | assert.strictEqual(hello(), 'Hello, mocked world!') 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-early-flake-detection/occasionally-failing-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | let globalCounter = 0 5 | 6 | describe('fail', () => { 7 | it('occasionally fails', () => { 8 | assert.strictEqual((globalCounter++) % 2, 0) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-flaky-test-retries/eventually-passing-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | let counter = 0 5 | 6 | describe('test-flaky-test-retries', () => { 7 | it('can retry failed tests', () => { 8 | assert.strictEqual(++counter, 3) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-total-code-coverage/test-skipped.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('./unused-dependency') 6 | describe('test-skipped', () => { 7 | it('can report tests', () => { 8 | assert.strictEqual(sum(1, 2), 3) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/efd-parallel/ci-visibility-test-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('../sum') 6 | 7 | describe('ci visibility 2', () => { 8 | it('can report tests 2', () => { 9 | assert.deepStrictEqual(sum(1, 2), 3) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/efd-parallel/ci-visibility-test-3.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('../sum') 6 | 7 | describe('ci visibility 3', () => { 8 | it('can report tests 3', () => { 9 | assert.deepStrictEqual(sum(1, 2), 3) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test/efd-parallel/ci-visibility-test-4.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('../sum') 6 | 7 | describe('ci visibility 4', () => { 8 | it('can report tests 4', () => { 9 | assert.deepStrictEqual(sum(1, 2), 3) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/grpc/types.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | unary: 'unary', 5 | bidi: 'bidi_streaming', 6 | client_stream: 'client_streaming', 7 | clientStream: 'client_streaming', 8 | server_stream: 'server_streaming', 9 | serverStream: 'server_streaming' 10 | } 11 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/fixtures/sqs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const sqs = {} 4 | 5 | sqs.create = { 6 | QueueName: 'SQS_QUEUE_NAME', 7 | Attributes: { 8 | MessageRetentionPeriod: '86400' 9 | } 10 | } 11 | 12 | sqs.get = { 13 | QueueUrl: undefined 14 | } 15 | 16 | module.exports = sqs 17 | -------------------------------------------------------------------------------- /packages/datadog-plugin-axios/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest({ 6 | modName: 'axios', 7 | repoUrl: 'axios/axios', 8 | commitish: 'latest', 9 | testCmd: 'node_modules/.bin/grunt mochaTest', 10 | parallel: false 11 | }) 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-graphql/src/tools/index.js: -------------------------------------------------------------------------------- 1 | // file mostly untouched from apollo-graphql 2 | 3 | "use strict"; 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | var signature_1 = require("./signature"); 6 | exports.defaultEngineReportingSignature = signature_1.defaultEngineReportingSignature; 7 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/app-dir/app/api/test-text/route.js: -------------------------------------------------------------------------------- 1 | import { NextResponse } from 'next/server' 2 | export async function POST (request) { 3 | const body = await request.text() 4 | return NextResponse.json({ 5 | now: Date.now(), 6 | cache: 'no-store', 7 | data: body 8 | }) 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-package-mock/non-dependency-mock-test-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const hello = jest.requireActual('some-package') 6 | 7 | test('hello function returns correct greeting', () => { 8 | assert.strictEqual(hello(), 'Hello, world!') 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-early-flake-detection/test-parameterized.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('parameterized', () => { 5 | test.each(['parameter 1', 'parameter 2'])('test %s', (value) => { 6 | assert.deepStrictEqual(value.startsWith('parameter'), true) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /integration-tests/cypress-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "video": false, 3 | "screenshotOnRunFailure": false, 4 | "pluginsFile": "cypress/plugins-old/index.js", 5 | "supportFile": "cypress/support/e2e.js", 6 | "integrationFolder": "cypress/e2e", 7 | "defaultCommandTimeout": 1000, 8 | "nodeVersion": "system" 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/source-map-support/scripts/build-minifiy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | npx uglify-js integration-tests/debugger/target-app/source-map-support/minify.js \ 4 | -o integration-tests/debugger/target-app/source-map-support/minify.min.js \ 5 | --v8 \ 6 | --source-map url=minify.min.js.map 7 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/passport-local.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { addHook } = require('./helpers/instrument') 4 | const { strategyHook } = require('./passport-utils') 5 | 6 | addHook({ 7 | name: 'passport-local', 8 | file: 'lib/strategy.js', 9 | versions: ['>=1.0.0'] 10 | }, strategyHook) 11 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/pages-dir/datadog-extended-data-collection.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | module.exports = require('../../../..').init({ 3 | flushInterval: 0, 4 | appsec: { 5 | enabled: true, 6 | rules: path.join(__dirname, '..', '..', 'extended-data-collection.rules.json') 7 | } 8 | }) 9 | -------------------------------------------------------------------------------- /packages/dd-trace/test/custom-metrics-app.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | 4 | /* eslint-disable no-console */ 5 | 6 | console.log('demo app started') 7 | 8 | const tracer = require('../../../').init() 9 | 10 | tracer.dogstatsd.increment('page.views.data') 11 | 12 | console.log('demo app finished') 13 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-dns/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | if (Number(process.env.USE_TRACER)) { 4 | require('../../..').init() 5 | } 6 | 7 | const dns = require('dns') 8 | 9 | function testRun (count) { 10 | if (++count === 1000) return 11 | dns.lookup('localhost', () => testRun(count)) 12 | } 13 | 14 | testRun(0) 15 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-retries-test-fn/mocha-sync.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | let attempt = 0 5 | 6 | describe('mocha-sync-retries', function () { 7 | this.retries(4) 8 | 9 | it('will be retried and pass', () => { 10 | assert.equal(attempt++, 2) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/appsec/esm-app/more.mjs: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import childProcess from 'node:child_process' 3 | 4 | const router = express.Router() 5 | router.get('/cmdi-vulnerable', (req, res) => { 6 | childProcess.execSync(`ls ${req.query.args}`) 7 | 8 | res.end() 9 | }) 10 | 11 | export default router 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-bad-import-torn-down/jest-bad-import-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | afterAll(() => { 6 | process.nextTick(() => { 7 | require('./off-timing-import.js') 8 | }) 9 | }) 10 | it('will fail', () => { 11 | assert.strictEqual(true, true) 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-fast-check/jest-fast-check.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, fc } = require('@fast-check/jest') 4 | 5 | describe('fast check', () => { 6 | test.prop([fc.string(), fc.string(), fc.string()])('will not include seed', (a, b, c) => { 7 | expect([a, b, c]).toContain(b) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-restify/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import restify from 'restify' 3 | 4 | const server = restify.createServer() 5 | 6 | server.listen(0, () => { 7 | const port = (/** @type {import('net').AddressInfo} */ (server.address())).port 8 | process.send({ port }) 9 | }) 10 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/app-dir/datadog-extended-data-collection.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = require('../../../..').init({ 4 | flushInterval: 0, 5 | appsec: { 6 | enabled: true, 7 | rules: path.join(__dirname, '..', '..', 'extended-data-collection.rules.json') 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/source-map-support/minify.min.js: -------------------------------------------------------------------------------- 1 | "use strict";require("dd-trace/init");const{createServer}=require("node:http");const server=createServer((req,res)=>{res.end("hello world")});server.listen(process.env.APP_PORT||0,()=>{process.send?.({port:server.address().port})}); 2 | //# sourceMappingURL=minify.min.js.map -------------------------------------------------------------------------------- /packages/datadog-plugin-hapi/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import Hapi from '@hapi/hapi' 3 | 4 | const server = Hapi.server({ port: 0, host: 'localhost' }) 5 | server.route({ method: 'GET', path: '/', handler: (request, h) => 'foo\n' }) 6 | await server.start() 7 | process.send({ port: server.info.port }) 8 | -------------------------------------------------------------------------------- /packages/datadog-plugin-mariadb/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import mariadb from 'mariadb' 3 | 4 | const pool = mariadb.createPool({ 5 | host: 'localhost', 6 | user: 'root', 7 | database: 'db', 8 | port: 3306 9 | }) 10 | await pool.query('SELECT 1 + 1 AS solution') 11 | await pool.end() 12 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/waf/diagnostics.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | DIAGNOSTIC_KEYS: [ 5 | 'rules', 6 | 'custom_rules', 7 | 'exclusions', 8 | 'actions', 9 | 'processors', 10 | 'scanners', 11 | 'rules_override', 12 | 'rules_data', 13 | 'exclusion_data' 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /packages/dd-trace/src/plugins/structured_log_plugin.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const LogPlugin = require('./log_plugin') 4 | 5 | module.exports = class StructuredLogPlugin extends LogPlugin { 6 | _isEnabled (config) { 7 | return super._isEnabled(config) || (config.enabled && config.logInjection === 'structured') 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/dd-trace/src/service-naming/schemas/v0/graphql.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { identityService } = require('../util') 4 | 5 | const graphql = { 6 | server: { 7 | graphql: { 8 | opName: () => 'graphql.execute', 9 | serviceName: identityService 10 | } 11 | } 12 | } 13 | 14 | module.exports = graphql 15 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/taint-tracking-utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | // Move this file to temp dir before requiring to force a rewriting 4 | // because the files into the tracer are not rewritten 5 | 6 | module.exports = { 7 | add (param1, param2) { 8 | return param1 + param2 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/mysql-mock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mysql-mock", 3 | "version": "2.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "private": true 12 | } 13 | -------------------------------------------------------------------------------- /ext/formats.d.ts: -------------------------------------------------------------------------------- 1 | import * as opentracing from 'opentracing' 2 | 3 | declare const formats: { 4 | TEXT_MAP: typeof opentracing.FORMAT_TEXT_MAP 5 | HTTP_HEADERS: typeof opentracing.FORMAT_HTTP_HEADERS 6 | BINARY: typeof opentracing.FORMAT_BINARY 7 | LOG: 'log' 8 | TEXT_MAP_DSM: 'text_map_dsm' 9 | } 10 | 11 | export = formats 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-impacted-test/test-impacted-1.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('impacted tests', () => { 5 | it('can pass normally', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | 9 | it('can fail', () => { 10 | assert.strictEqual(1 + 2, 4) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-impacted-test/test-impacted-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('impacted tests 2', () => { 5 | it('can pass normally', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | 9 | it('can fail', () => { 10 | assert.strictEqual(1 + 2, 4) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs: -------------------------------------------------------------------------------- 1 | import { rewrite } from './index.js' 2 | 3 | async function load (url, context, nextLoad) { 4 | const result = await nextLoad(url, context) 5 | 6 | result.source = rewrite(result.source, url, context.format) 7 | 8 | return result 9 | } 10 | 11 | export { load } 12 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/passport-http.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { addHook } = require('./helpers/instrument') 4 | const { strategyHook } = require('./passport-utils') 5 | 6 | addHook({ 7 | name: 'passport-http', 8 | file: 'lib/passport-http/strategies/basic.js', 9 | versions: ['>=0.3.0'] 10 | }, strategyHook) 11 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/app-dir/app/layout.js: -------------------------------------------------------------------------------- 1 | export const metadata = { 2 | title: 'Create Next App', 3 | description: 'Generated by create next app' 4 | } 5 | 6 | export default function RootLayout ({ children }) { 7 | return ( 8 | 9 | {children} 10 | 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/dd-trace/test/node_modules/express-mock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-mock", 3 | "version": "4.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "private": true 12 | } 13 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-net/server.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const net = require('net') 4 | const { port, reqs } = require('./common') 5 | 6 | let connectionsMade = 0 7 | 8 | const server = net.createServer(c => { 9 | if (++connectionsMade === reqs) { 10 | c.on('end', () => server.close()) 11 | } 12 | c.pipe(c) 13 | }).listen(port) 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission/logger.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { createLogger, format, transports } = require('winston') 4 | 5 | module.exports = createLogger({ 6 | level: 'info', 7 | exitOnError: false, 8 | format: format.json(), 9 | transports: [ 10 | new transports.Console() 11 | ] 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-retries-test-fn/mocha-done.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | let attempt = 0 5 | 6 | describe('mocha-done-retries', function () { 7 | this.retries(4) 8 | 9 | it('will be retried and pass', (done) => { 10 | assert.equal(attempt++, 2) 11 | done() 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/cypress-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "video": false, 3 | "screenshotOnRunFailure": false, 4 | "pluginsFile": "cypress/plugins-old/index.js", 5 | "supportFile": "cypress/support/e2e.js", 6 | "integrationFolder": "cypress/e2e", 7 | "defaultCommandTimeout": 1000, 8 | "nodeVersion": "system" 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-early-flake-detection/weird-test-names.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | it('no describe can do stuff', () => { 5 | assert.strictEqual(1, 1) 6 | }) 7 | 8 | describe('describe ', () => { 9 | it('trailing space ', () => { 10 | assert.strictEqual(1, 1) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/datadog-plugin-net/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import net from 'net' 3 | 4 | const client = net.createConnection(0, () => {}) 5 | 6 | client.on('data', (data) => {}) 7 | 8 | client.on('end', () => { 9 | client.end() 10 | }) 11 | 12 | client.on('error', (err) => { 13 | client.end() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/datadog-plugin-pino/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest({ 6 | modName: 'pino', 7 | repoUrl: 'pinojs/pino', 8 | commitish: 'latest', 9 | testCmd: 'node_modules/.bin/tap test/*test.js test/*/*test.js --no-coverage', 10 | parallel: false 11 | }) 12 | -------------------------------------------------------------------------------- /packages/dd-trace/src/service-naming/schemas/v1/graphql.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { identityService } = require('../util') 4 | 5 | const graphql = { 6 | server: { 7 | graphql: { 8 | opName: () => 'graphql.server.request', 9 | serviceName: identityService 10 | } 11 | } 12 | } 13 | 14 | module.exports = graphql 15 | -------------------------------------------------------------------------------- /benchmark/sirun/run-one-variant.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | 5 | const { exec, stdio } = require('./run-util') 6 | 7 | process.env.DD_INSTRUMENTATION_TELEMETRY_ENABLED = 'false' 8 | 9 | const env = Object.assign({}, process.env, { DD_TRACE_STARTUP_LOGS: 'false' }) 10 | 11 | exec('sirun', ['meta-temp.json'], { env, stdio }) 12 | -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-esm/iast/index.mjs: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import childProcess from 'node:child_process' 3 | 4 | const router = express.Router() 5 | 6 | router.get('/cmdi-vulnerable', (req, res) => { 7 | childProcess.execSync(`ls ${req.query.args}`) 8 | 9 | res.end() 10 | }) 11 | 12 | export default router 13 | -------------------------------------------------------------------------------- /integration-tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "outDir": "ci-visibility/playwright-tests-ts-out", 6 | "sourceMap": true, 7 | "skipLibCheck": true 8 | }, 9 | "include": ["ci-visibility/playwright-tests-ts"], 10 | "files": ["playwright.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/fs-sync-way-method.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('fs') 4 | 5 | module.exports = function (methodName, args, cb) { 6 | const method = `${methodName}Sync` 7 | try { 8 | const res = fs[method](...args) 9 | cb(res) 10 | } catch (e) { 11 | cb(null) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/pages-dir/pages/api/test/index.js: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | 3 | export default async function POST (req, res) { 4 | const body = req.body 5 | res.status(200).json({ 6 | cache: 'no-store', 7 | data: body, 8 | query: req.query 9 | }) 10 | } 11 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission-playwright/logger.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { createLogger, format, transports } = require('winston') 4 | 5 | module.exports = createLogger({ 6 | level: 'info', 7 | exitOnError: false, 8 | format: format.json(), 9 | transports: [ 10 | new transports.Console() 11 | ] 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-management/test-quarantine-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('quarantine tests 2', () => { 5 | it('can quarantine a test', () => { 6 | assert.strictEqual(1 + 2, 3) 7 | }) 8 | 9 | it('can pass normally', () => { 10 | assert.strictEqual(1 + 2, 3) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/datadog-plugin-avsc/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const SchemaPlugin = require('../../dd-trace/src/plugins/schema') 4 | const SchemaExtractor = require('./schema_iterator') 5 | 6 | class AvscPlugin extends SchemaPlugin { 7 | static id = 'avsc' 8 | static schemaExtractor = SchemaExtractor 9 | } 10 | 11 | module.exports = AvscPlugin 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-fastify/test/suite.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const suiteTest = require('../../dd-trace/test/plugins/suite') 4 | 5 | suiteTest({ 6 | modName: 'fastify', 7 | repoUrl: 'fastify/fastify', 8 | commitish: 'latest', 9 | testCmd: 'node_modules/.bin/tap -J test/*.test.js test/*/*.test.js --no-coverage --no-check-coverage' 10 | }) 11 | -------------------------------------------------------------------------------- /packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | collectionSizeSym: Symbol('datadog.collectionSize'), 5 | largeCollectionSkipThresholdSym: Symbol('datadog.largeCollectionSkipThresholdSym'), 6 | fieldCountSym: Symbol('datadog.fieldCount'), 7 | timeBudgetSym: Symbol('datadog.timeout') 8 | } 9 | -------------------------------------------------------------------------------- /packages/dd-trace/src/log/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const memoize = func => { 4 | const cache = {} 5 | const memoized = function (key) { 6 | if (!cache[key]) { 7 | cache[key] = func.apply(this, arguments) 8 | } 9 | 10 | return cache[key] 11 | } 12 | 13 | return memoized 14 | } 15 | 16 | module.exports = { memoize } 17 | -------------------------------------------------------------------------------- /packages/dd-trace/src/plugins/client.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const OutboundPlugin = require('./outbound') 4 | 5 | class ClientPlugin extends OutboundPlugin { 6 | static operation = 'request' 7 | static kind = 'client' 8 | static type = 'web' // overridden by storage and other client type plugins 9 | } 10 | 11 | module.exports = ClientPlugin 12 | -------------------------------------------------------------------------------- /ext/exporters.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | LOG: 'log', 4 | AGENT: 'agent', 5 | DATADOG: 'datadog', 6 | AGENT_PROXY: 'agent_proxy', 7 | JEST_WORKER: 'jest_worker', 8 | CUCUMBER_WORKER: 'cucumber_worker', 9 | MOCHA_WORKER: 'mocha_worker', 10 | PLAYWRIGHT_WORKER: 'playwright_worker', 11 | VITEST_WORKER: 'vitest_worker' 12 | } 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission-cucumber/support/logger.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { createLogger, format, transports } = require('winston') 4 | 5 | module.exports = createLogger({ 6 | level: 'info', 7 | exitOnError: false, 8 | format: format.json(), 9 | transports: [ 10 | new transports.Console() 11 | ] 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/async-pass.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-test-async-pass', () => { 5 | it('can do passed async tests', async () => { 6 | await new Promise(resolve => { 7 | setTimeout(resolve, 100) 8 | }) 9 | assert.strictEqual(true, true) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/done-fail-badly.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-test-done-fail', () => { 5 | it('can do badly setup failed tests with done', (done) => { 6 | setTimeout(() => { 7 | assert.strictEqual(true, false) 8 | done() 9 | }, 100) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/playwright-test-duration/long-suite-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, expect } = require('@playwright/test') 4 | 5 | test.describe('long suite', () => { 6 | test('should be able to run', async () => { 7 | await new Promise(resolve => setTimeout(resolve, 5000)) 8 | expect(true).toBe(true) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/datadog-plugin-apollo/src/gateway/plan.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo') 4 | 5 | class ApolloGatewayPlanPlugin extends ApolloBasePlugin { 6 | static operation = 'plan' 7 | static prefix = 'tracing:apm:apollo:gateway:plan' 8 | } 9 | 10 | module.exports = ApolloGatewayPlanPlugin 11 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/analyzers/stored-injection-analyzer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const InjectionAnalyzer = require('./injection-analyzer') 4 | 5 | class StoredInjectionAnalyzer extends InjectionAnalyzer { 6 | _areRangesVulnerable (ranges) { 7 | return ranges?.length > 0 8 | } 9 | } 10 | 11 | module.exports = StoredInjectionAnalyzer 12 | -------------------------------------------------------------------------------- /packages/dd-trace/src/noop/scope.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class Scope { 4 | active () { 5 | return null 6 | } 7 | 8 | activate (span, callback) { 9 | if (typeof callback !== 'function') return callback 10 | 11 | return callback() 12 | } 13 | 14 | bind (fn, span) { 15 | return fn 16 | } 17 | } 18 | 19 | module.exports = Scope 20 | -------------------------------------------------------------------------------- /packages/dd-trace/src/plugins/server.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const InboundPlugin = require('./inbound') 4 | 5 | class ServerPlugin extends InboundPlugin { 6 | static operation = 'request' 7 | static kind = 'server' 8 | static type = 'web' // a default that may eventually be overriden by nonweb servers 9 | } 10 | 11 | module.exports = ServerPlugin 12 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/next/pages-dir/pages/api/test-formdata/index.js: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | 3 | export default async function POST (req, res) { 4 | const body = req.body 5 | res.status(200).json({ 6 | cache: 'no-store', 7 | data: body, 8 | query: req.query 9 | }) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/dist/opentracing/noop.d.ts: -------------------------------------------------------------------------------- 1 | import Span from './span'; 2 | import SpanContext from './span_context'; 3 | import Tracer from './tracer'; 4 | export declare let tracer: Tracer | null; 5 | export declare let spanContext: SpanContext | null; 6 | export declare let span: Span | null; 7 | export declare function initialize(): void; 8 | //# sourceMappingURL=noop.d.ts.map -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-cjs/iast/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const express = require('express') 4 | const { execSync } = require('child_process') 5 | 6 | const router = express.Router() 7 | 8 | router.get('/cmdi-vulnerable', (req, res) => { 9 | execSync(`ls ${req.query.args}`) 10 | 11 | res.end() 12 | }) 13 | 14 | module.exports = router 15 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/async-fail.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-test-async-fail', () => { 5 | it('can do failed async tests', async () => { 6 | await new Promise(resolve => { 7 | setTimeout(resolve, 100) 8 | }) 9 | assert.strictEqual(true, false) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/parameterized.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const forEach = require('mocha-each') 6 | describe('mocha-parameterized', () => { 7 | forEach([[1, 2, 3]]).it('can do parameterized', (left, right, expected) => { 8 | assert.strictEqual(left + right, expected) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-retries-test-fn/mocha-promise.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | let attempt = 0 5 | 6 | describe('mocha-promise-retries', function () { 7 | this.retries(4) 8 | 9 | it('will be retried and pass', () => { 10 | assert.equal(attempt++, 2) 11 | return Promise.resolve() 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-optimization-wrong-init-cucumber/sum.feature: -------------------------------------------------------------------------------- 1 | Feature: Sum calculation 2 | As a developer 3 | I want to test sum functionality 4 | So that I can verify basic math operations 5 | 6 | Scenario: Add two numbers 7 | Given I have two numbers 1 and 2 8 | When I add them together 9 | Then the result should be 3 10 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/vitest-tests/test-disabled.mjs: -------------------------------------------------------------------------------- 1 | import { describe, test, expect } from 'vitest' 2 | 3 | describe('disable tests', () => { 4 | test('can disable a test', () => { 5 | // eslint-disable-next-line no-console 6 | console.log('I am running') // to check if this is being run 7 | expect(1 + 2).to.equal(4) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-amqplib/src/util.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function getResourceName (method, fields = {}) { 4 | return [ 5 | method, 6 | fields.exchange, 7 | fields.routingKey, 8 | fields.queue, 9 | fields.source, 10 | fields.destination 11 | ].filter(Boolean).join(' ') 12 | } 13 | 14 | module.exports = { getResourceName } 15 | -------------------------------------------------------------------------------- /packages/dd-trace/src/service-naming/schemas/v0/serverless.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { identityService } = require('../util') 4 | 5 | const serverless = { 6 | server: { 7 | 'azure-functions': { 8 | opName: () => 'azure.functions.invoke', 9 | serviceName: identityService 10 | } 11 | } 12 | } 13 | 14 | module.exports = serverless 15 | -------------------------------------------------------------------------------- /packages/dd-trace/src/service-naming/schemas/v1/serverless.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { identityService } = require('../util') 4 | 5 | const serverless = { 6 | server: { 7 | 'azure-functions': { 8 | opName: () => 'azure.functions.invoke', 9 | serviceName: identityService 10 | } 11 | } 12 | } 13 | 14 | module.exports = serverless 15 | -------------------------------------------------------------------------------- /.github/actions/testagent/start/action.yml: -------------------------------------------------------------------------------- 1 | name: "Start the APM Test Agent" 2 | description: "Starts the APM Test Agent image with environment." 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 7 | - run: docker compose up -d testagent || docker compose up -d testagent 8 | shell: bash 9 | -------------------------------------------------------------------------------- /benchmark/sirun/appsec/insecure-bank.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const http = require('http') 4 | const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path 5 | 6 | const { port } = require('./common') 7 | 8 | app.set('port', port) 9 | const server = http.createServer(app) 10 | 11 | server.listen(port, () => { server.close() }) 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-management/test-disabled-1.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('disable tests', () => { 5 | it('can disable a test', () => { 6 | // eslint-disable-next-line no-console 7 | console.log('I am running') // to check if this is being run 8 | assert.strictEqual(1 + 2, 4) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/fixtures/s3.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const s3 = {} 4 | 5 | s3.put = { 6 | Bucket: 'test-aws-bucket-9bd88aa3-6fc1-44bd-ae3a-ba25f49c3eef', 7 | Key: 'test.txt', 8 | Body: 'Hello World!' 9 | } 10 | 11 | s3.create = { 12 | Bucket: 'test-aws-bucket-9bd88aa3-6fc1-44bd-ae3a-ba25f49c3eef' 13 | } 14 | 15 | module.exports = s3 16 | -------------------------------------------------------------------------------- /packages/datadog-plugin-confluentinc-kafka-javascript/src/consumer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const KafkajsConsumerPlugin = require('../../datadog-plugin-kafkajs/src/consumer') 4 | 5 | class ConfluentKafkaJsConsumerPlugin extends KafkajsConsumerPlugin { 6 | static id = 'confluentinc-kafka-javascript' 7 | } 8 | 9 | module.exports = ConfluentKafkaJsConsumerPlugin 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-confluentinc-kafka-javascript/src/producer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const KafkajsProducerPlugin = require('../../datadog-plugin-kafkajs/src/producer') 4 | 5 | class ConfluentKafkaJsProducerPlugin extends KafkajsProducerPlugin { 6 | static id = 'confluentinc-kafka-javascript' 7 | } 8 | 9 | module.exports = ConfluentKafkaJsProducerPlugin 10 | -------------------------------------------------------------------------------- /benchmark/sirun/appsec-iast/insecure-bank.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const http = require('http') 4 | const app = require('/opt/insecure-bank-js/app') // eslint-disable-line import/no-absolute-path 5 | 6 | const { port } = require('./common') 7 | 8 | app.set('port', port) 9 | const server = http.createServer(app) 10 | 11 | server.listen(port, () => { server.close() }) 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-apollo/src/gateway/execute.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo') 4 | 5 | class ApolloGatewayExecutePlugin extends ApolloBasePlugin { 6 | static operation = 'execute' 7 | static prefix = 'tracing:apm:apollo:gateway:execute' 8 | } 9 | 10 | module.exports = ApolloGatewayExecutePlugin 11 | -------------------------------------------------------------------------------- /packages/datadog-plugin-cypress/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Plugin = require('../../dd-trace/src/plugins/plugin') 4 | 5 | // Cypress plugin does not patch any library. This is just a placeholder to 6 | // follow the structure of the plugins 7 | class CypressPlugin extends Plugin { 8 | static id = 'cypress' 9 | } 10 | 11 | module.exports = CypressPlugin 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-http2/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import http2 from 'http2' 3 | 4 | const server = http2.createServer((req, res) => { 5 | res.end('Hello, HTTP/2!') 6 | }) 7 | 8 | server.listen(0, () => { 9 | const port = (/** @type {import('net').AddressInfo} */ (server.address())).port 10 | process.send({ port }) 11 | }) 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/api/hello/index.js: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | 3 | export default (req, res) => { 4 | const tracer = require('../../../../../dd-trace') 5 | const span = tracer.scope().active() 6 | const name = span && span.context()._name 7 | 8 | res.status(200).json({ name }) 9 | } 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/pages/api/hello/other.js: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | 3 | export default (req, res) => { 4 | const tracer = require('../../../../../dd-trace') 5 | const span = tracer.scope().active() 6 | const name = span && span.context()._name 7 | 8 | res.status(200).json({ name }) 9 | } 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-prisma/test/schema.prisma: -------------------------------------------------------------------------------- 1 | generator client { 2 | provider = "prisma-client-js" 3 | } 4 | 5 | datasource db { 6 | provider = "postgresql" 7 | url = "postgres://postgres:postgres@localhost:5432/postgres" 8 | } 9 | 10 | model User { 11 | id Int @id @default(autoincrement()) 12 | email String @unique 13 | name String? 14 | } 15 | -------------------------------------------------------------------------------- /ext/exporters.d.ts: -------------------------------------------------------------------------------- 1 | declare const exporters: { 2 | LOG: 'log', 3 | AGENT: 'agent', 4 | DATADOG: 'datadog', 5 | AGENT_PROXY: 'agent_proxy', 6 | JEST_WORKER: 'jest_worker', 7 | CUCUMBER_WORKER: 'cucumber_worker', 8 | MOCHA_WORKER: 'mocha_worker', 9 | PLAYWRIGHT_WORKER: 'playwright_worker', 10 | VITEST_WORKER: 'vitest_worker' 11 | } 12 | 13 | export = exporters 14 | -------------------------------------------------------------------------------- /integration-tests/appsec/esm-app/custom-noop-hooks.mjs: -------------------------------------------------------------------------------- 1 | function dummyOperation (a) { 2 | return a + 'should have ' + 'dummy operation to be rewritten' + ' without crashing' 3 | } 4 | 5 | export async function initialize () { 6 | dummyOperation('should have') 7 | } 8 | 9 | export async function load (url, context, nextLoad) { 10 | return nextLoad(url, context) 11 | } 12 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-early-flake-detection/mocha-parameterized.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const forEach = require('mocha-each') 6 | describe('parameterized', () => { 7 | forEach(['parameter 1', 'parameter 2']).it('test %s', (value) => { 8 | assert.strictEqual(value.startsWith('parameter'), true) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/q.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../src/q') 4 | 5 | const assertPromise = require('./helpers/promise') 6 | 7 | assertPromise('q', Q => { 8 | return function Promise (executor) { 9 | const deferred = Q.defer() 10 | 11 | executor(deferred.resolve, deferred.reject) 12 | 13 | return deferred.promise 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /packages/datadog-plugin-next/test/app/api/appDir/error/route.js: -------------------------------------------------------------------------------- 1 | import { NextResponse } from 'next/server' 2 | 3 | export async function GET (req) { 4 | let status = 200 5 | try { 6 | throw new Error('error in app dir api route') 7 | } catch (error) { 8 | req.error = error 9 | status = 500 10 | } 11 | 12 | return NextResponse.json({}, { status }) 13 | } 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-protobufjs/test/schemas/message.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "other_message.proto"; 4 | 5 | enum Status { 6 | UNKNOWN = 0; 7 | ACTIVE = 1; 8 | INACTIVE = 2; 9 | DELETED = 3; 10 | } 11 | 12 | message MyMessage { 13 | string id = 1; 14 | string value = 2; 15 | repeated OtherMessage otherMessage = 3; 16 | Status status = 4; 17 | } -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-esm/app.mjs: -------------------------------------------------------------------------------- 1 | import './init.mjs' 2 | 3 | import express from 'express' 4 | 5 | import iastRouter from './iast/index.mjs' 6 | 7 | const app = express() 8 | 9 | app.use('/iast', iastRouter) 10 | 11 | const server = app.listen(0, () => { 12 | process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port }) 13 | }) 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/hook-sync-error.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-fail-hook-sync', () => { 5 | beforeEach(() => { 6 | const value = '' 7 | value.unsafe.error = '' 8 | }) 9 | 10 | it('will not run but be reported as failed', () => { 11 | assert.strictEqual(true, true) 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/vitest-tests/dynamic-instrumentation.mjs: -------------------------------------------------------------------------------- 1 | import { describe, test, expect } from 'vitest' 2 | import { sum } from './bad-sum' 3 | 4 | describe('dynamic instrumentation', () => { 5 | test('can sum', () => { 6 | expect(sum(11, 2)).to.equal(13) 7 | }) 8 | test('is not retried', () => { 9 | expect(sum(1, 2)).to.equal(3) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/re-evaluation/index.js: -------------------------------------------------------------------------------- 1 | import { createServer } from 'node:http' 2 | 3 | const server = createServer((req, res) => { 4 | res.end('Hello, World!') // This needs to be line 4 5 | }) 6 | 7 | server.listen(process.env.APP_PORT || 0, () => { 8 | process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/startup/unsupported.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | /* eslint-disable-next-line n/no-missing-import */ 6 | import('d3-format').then(({ format }) => { 7 | const siFormat = format('.4~s') 8 | 9 | // This is `1.2undefined` when unexpectedly patched by import-in-the-middle. 10 | assert.equal(siFormat(1200), '1.2k') 11 | }) 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-protobufjs/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const SchemaPlugin = require('../../dd-trace/src/plugins/schema') 4 | const SchemaExtractor = require('./schema_iterator') 5 | 6 | class ProtobufjsPlugin extends SchemaPlugin { 7 | static id = 'protobufjs' 8 | 9 | static schemaExtractor = SchemaExtractor 10 | } 11 | 12 | module.exports = ProtobufjsPlugin 13 | -------------------------------------------------------------------------------- /packages/dd-trace/src/noop/dogstatsd.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * @import { DogStatsD } from "../../../../index.d.ts" 5 | * @implements {DogStatsD} 6 | */ 7 | module.exports = class NoopDogStatsDClient { 8 | increment () {} 9 | 10 | decrement () {} 11 | 12 | gauge () {} 13 | 14 | distribution () {} 15 | 16 | histogram () {} 17 | 18 | flush () {} 19 | } 20 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/security-controls/resources/sanitizer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function sanitize (input) { 4 | return `sanitized ${input}` 5 | } 6 | 7 | function sanitizeObject (input) { 8 | return { sanitized: true, ...input } 9 | } 10 | 11 | module.exports = { 12 | sanitize, 13 | sanitizeObject, 14 | 15 | nested: { 16 | sanitize 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /benchmark/sirun/runtime-metrics/README.md: -------------------------------------------------------------------------------- 1 | This benchmark runs the with runtime metrics and an accelerated flush. While 2 | this can catch code regressions, it's mostly meant to catch things like memory 3 | leaks where metrics would start piling up. This can be hard to catch in tests, 4 | but it would cause the app to become slower and slower over time which would 5 | be visible in the benchmark. 6 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission/config-jest.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | projects: [], 5 | testPathIgnorePatterns: ['/node_modules/'], 6 | cache: false, 7 | testMatch: [ 8 | '**/ci-visibility/automatic-log-submission/automatic-log-submission-*' 9 | ], 10 | testRunner: 'jest-circus/runner', 11 | testEnvironment: 'node' 12 | } 13 | -------------------------------------------------------------------------------- /packages/datadog-plugin-grpc/test/hasservice.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package thing.service; 4 | 5 | service ThingService { 6 | rpc FindOne (ThingById) returns (Thing); 7 | rpc FindMany (stream ThingById) returns (stream Thing); 8 | } 9 | 10 | message ThingById { 11 | int32 id = 1; 12 | } 13 | 14 | message Thing { 15 | int32 id = 1; 16 | string name = 2; 17 | } 18 | -------------------------------------------------------------------------------- /.github/vendored-dependencies.csv: -------------------------------------------------------------------------------- 1 | "aws-lambda-nodejs-runtime-interface-client","https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/v2.1.0/src/utils/UserFunction.ts","['Apache-2.0']","['Amazon.com Inc. or its affiliates']" 2 | "is-git-url","https://github.com/jonschlinkert/is-git-url/blob/396965ffabf2f46656c8af4c47bef1d69f09292e/index.js#L9C15-L9C87","['MIT']","['Jon Schlinkert']" 3 | -------------------------------------------------------------------------------- /integration-tests/debugger/target-app/re-evaluation/unique-filename.js: -------------------------------------------------------------------------------- 1 | import { createServer } from 'node:http' 2 | 3 | const server = createServer((req, res) => { 4 | res.end('Hello, World!') // This needs to be line 4 5 | }) 6 | 7 | server.listen(process.env.APP_PORT || 0, () => { 8 | process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port }) 9 | }) 10 | -------------------------------------------------------------------------------- /integration-tests/esbuild/esm-http-test.mjs: -------------------------------------------------------------------------------- 1 | import './init.mjs' 2 | 3 | import http from 'http' 4 | 5 | process.env.DD_TRACE_DEBUG = 'true' 6 | 7 | const server = http.createServer((req, res) => { 8 | res.end('Egun on!') 9 | }) 10 | 11 | server.listen(0, () => { 12 | const port = (/** @type {import('net').AddressInfo} */ (server.address())).port 13 | process.send({ port }) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/when.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../src/when') 4 | 5 | const assertPromise = require('./helpers/promise') 6 | 7 | assertPromise('when', when => { 8 | return function Promise (executor) { 9 | const deferred = when.defer() 10 | 11 | executor(deferred.resolve, deferred.reject) 12 | 13 | return deferred.promise 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /packages/datadog-plugin-google-genai/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import { GoogleGenAI } from '@google/genai' 2 | 3 | const client = new GoogleGenAI({ 4 | apiKey: process.env.GOOGLE_API_KEY, 5 | httpOptions: { baseUrl: 'http://127.0.0.1:9126/vcr/genai' } 6 | }) 7 | 8 | await client.models.generateContent({ 9 | model: 'gemini-2.0-flash', 10 | contents: 'Hello, world!' 11 | }) 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-koa/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import Koa from 'koa' 3 | 4 | const app = new Koa() 5 | 6 | app.use(async (ctx) => { 7 | ctx.body = 'hello, world\n' 8 | }) 9 | 10 | const server = app.listen(0, () => { 11 | const port = (/** @type {import('net').AddressInfo} */ (server.address())).port 12 | process.send({ port }) 13 | }) 14 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/mysql2-vulnerable-method.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function vulnerableMethod (connection, sql) { 4 | return new Promise((resolve, reject) => { 5 | connection.query(sql, function (err) { 6 | if (err) { 7 | reject(err) 8 | } else { 9 | resolve() 10 | } 11 | }) 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /packages/dd-trace/test/appsec/iast/analyzers/resources/sql-injection-methods.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function executeQuery (sql, clientOrPool) { 4 | return clientOrPool.query(sql) 5 | } 6 | 7 | function executeQueryWithCallback (sql, clientOrPool, cb) { 8 | return clientOrPool.query(sql, cb) 9 | } 10 | 11 | module.exports = { 12 | executeQuery, 13 | executeQueryWithCallback 14 | } 15 | -------------------------------------------------------------------------------- /packages/dd-trace/test/debugger/devtools_client/snapshot/target-code/max-field-count.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function run () { 4 | const obj = {} 5 | 6 | // 40 is larger the default maxFieldCount of 20 7 | for (let i = 1; i <= 40; i++) { 8 | obj[`field${i}`] = i 9 | } 10 | 11 | return 'my return value' // breakpoint at this line 12 | } 13 | 14 | module.exports = { run } 15 | -------------------------------------------------------------------------------- /benchmark/sirun/log/README.md: -------------------------------------------------------------------------------- 1 | This test calls the internal logger on various log levels for many iterations. 2 | 3 | * `without-log` is the baseline that has logging disabled completely. 4 | * `skip-log` has logs enabled but uses a log level that isn't so that the handler doesn't run. 5 | * `with-debug` has logs enabled and sends a debug log. 6 | * `with-error` has logs enabled and sends an error log. 7 | -------------------------------------------------------------------------------- /benchmark/sirun/spans/README.md: -------------------------------------------------------------------------------- 1 | This test initializes a tracer with the no-op scope manager. It then creates 2 | many spans, and depending on the variant, either finishes all of them as they 3 | are created, or later on once they're all created. Prior to creating any spans, 4 | it modifies the processor instance so that no span processing (or exporting) is 5 | done, and it simply stops storing the spans. 6 | -------------------------------------------------------------------------------- /ext/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const formats = require('./formats') 4 | const kinds = require('./kinds') 5 | const priority = require('./priority') 6 | const tags = require('./tags') 7 | const types = require('./types') 8 | const exporters = require('./exporters') 9 | 10 | module.exports = { 11 | formats, 12 | kinds, 13 | priority, 14 | tags, 15 | types, 16 | exporters 17 | } 18 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest-flaky/flaky-passes.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | let counter = 0 6 | 7 | describe('test-flaky-test-retries', () => { 8 | it('can retry flaky tests', () => { 9 | assert.deepStrictEqual(++counter, 3) 10 | }) 11 | 12 | it('will not retry passed tests', () => { 13 | assert.deepStrictEqual(3, 3) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/playwright-tests-test-management/quarantine-2-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, expect } = require('@playwright/test') 4 | 5 | test.describe('flaky', () => { 6 | test('should be flaky', async ({ page }, testInfo) => { 7 | if (testInfo.retry === 0) { 8 | throw new Error('I am flaky') 9 | } 10 | expect(true).toBe(true) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/datadog-plugin-confluentinc-kafka-javascript/src/batch-consumer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const KafkajsBatchConsumerPlugin = require('../../datadog-plugin-kafkajs/src/batch-consumer') 4 | 5 | class ConfluentKafkaJsBatchConsumerPlugin extends KafkajsBatchConsumerPlugin { 6 | static id = 'confluentinc-kafka-javascript' 7 | } 8 | 9 | module.exports = ConfluentKafkaJsBatchConsumerPlugin 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-connect/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import connect from 'connect' 3 | 4 | const app = connect() 5 | 6 | app.use((req, res) => { 7 | res.end('hello, world\n') 8 | }) 9 | 10 | const server = app.listen(0, () => { 11 | const port = (/** @type {import('net').AddressInfo} */ (server.address())).port 12 | process.send({ port }) 13 | }) 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-express/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import express from 'express' 3 | 4 | const app = express() 5 | 6 | app.use((req, res) => { 7 | res.end('hello, world\n') 8 | }) 9 | 10 | const server = app.listen(0, () => { 11 | const port = (/** @type {import('net').AddressInfo} */ (server.address())).port 12 | process.send({ port }) 13 | }) 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-mongoose/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import mongoose from 'mongoose' 3 | 4 | const testSchema = new mongoose.Schema({ 5 | a: Number 6 | }) 7 | const TestModel = mongoose.model('Test', testSchema) 8 | 9 | await mongoose.connect('mongodb://localhost:27017/test_db') 10 | await TestModel.create({ a: 1 }) 11 | await mongoose.disconnect() 12 | -------------------------------------------------------------------------------- /packages/dd-trace/test/debugger/devtools_client/snapshot/stub-session.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const inspector = require('../../../../src/debugger/devtools_client/inspector_promises_polyfill') 4 | const session = module.exports = /** @type {import('../../../../src/debugger/devtools_client/session').CDPSession} */ 5 | (new inspector.Session()) 6 | session.connect() 7 | 8 | session['@noCallThru'] = true 9 | -------------------------------------------------------------------------------- /benchmark/sirun/encoding/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "encoders", 3 | "run": "node index.js", 4 | "run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node index.js\"", 5 | "cachegrind": false, 6 | "instructions": true, 7 | "iterations": 22, 8 | "variants": { 9 | "0.4": { "env": { "ENCODER_VERSION": "0.4" } }, 10 | "0.5": { "env": { "ENCODER_VERSION": "0.5" } } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/promise-pass.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-test-promise-pass', () => { 5 | it('can do passed promise tests', () => { 6 | return new Promise((resolve) => { 7 | setTimeout(() => { 8 | assert.strictEqual(true, true) 9 | resolve() 10 | }, 100) 11 | }) 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-anthropic/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import { Anthropic } from '@anthropic-ai/sdk' 2 | 3 | const client = new Anthropic({ baseURL: 'http://127.0.0.1:9126/vcr/anthropic' }) 4 | 5 | await client.messages.create({ 6 | model: 'claude-3-7-sonnet-20250219', 7 | messages: [{ role: 'user', content: 'Hello, world!' }], 8 | max_tokens: 100, 9 | temperature: 0.5 10 | }) 11 | -------------------------------------------------------------------------------- /packages/datadog-plugin-iovalkey/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const RedisPlugin = require('../../datadog-plugin-redis/src') 4 | 5 | class IOValkeyPlugin extends RedisPlugin { 6 | static id = 'iovalkey' 7 | 8 | static system = 'valkey' 9 | 10 | constructor (...args) { 11 | super(...args) 12 | this._spanType = 'valkey' 13 | } 14 | } 15 | 16 | module.exports = IOValkeyPlugin 17 | -------------------------------------------------------------------------------- /packages/datadog-plugin-pg/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import pg from 'pg' 3 | 4 | const conn = { 5 | user: 'postgres', 6 | host: 'localhost', 7 | database: 'postgres', 8 | password: 'postgres', 9 | port: 5432 10 | } 11 | 12 | const client = new pg.Client(conn) 13 | client.connect() 14 | 15 | await client.query('SELECT NOW() AS now') 16 | client.end() 17 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/taint-tracking/filter.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const NODE_MODULES = 'node_modules' 4 | 5 | const isPrivateModule = function (file) { 6 | return file && !file.includes(NODE_MODULES) 7 | } 8 | 9 | const isDdTrace = function (file) { 10 | return Boolean(file?.includes('dd-trace')) 11 | } 12 | 13 | module.exports = { 14 | isPrivateModule, 15 | isDdTrace 16 | } 17 | -------------------------------------------------------------------------------- /packages/dd-trace/test/debugger/devtools_client/snapshot/target-code/max-field-count-scopes.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function run () { 4 | // local scope 5 | const { a1, b1, c1, d1 } = {} 6 | 7 | { 8 | // block scope 9 | const { a2, b2, c2, d2 } = {} 10 | 11 | return { a1, b1, c1, d1, a2, b2, c2, d2 } // breakpoint at this line 12 | } 13 | } 14 | 15 | module.exports = { run } 16 | -------------------------------------------------------------------------------- /.mochamultireporterrc.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const reporterEnabled = ['spec'] 4 | 5 | // eslint-disable-next-line eslint-rules/eslint-process-env 6 | if (process.env.CI) { 7 | reporterEnabled.push('mocha-junit-reporter') 8 | } 9 | 10 | module.exports = { 11 | reporterEnabled, 12 | mochaJunitReporterReporterOptions: { 13 | mochaFile: `./node-${process.versions.node}-junit.xml` 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ci/cypress/plugin.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { NODE_MAJOR } = require('../../version') 4 | 5 | // These polyfills are here because cypress@6.7.0, which we still support for v5, runs its plugin code 6 | // with Node.js@12. 7 | if (NODE_MAJOR < 18) { 8 | require('./polyfills') 9 | } 10 | 11 | require('../init') 12 | 13 | module.exports = require('../../packages/datadog-plugin-cypress/src/plugin') 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-optimization-wrong-init/sum-wrong-init-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('node:assert') 4 | const tracer = require('dd-trace') 5 | 6 | tracer.trace('sum.test', { resource: 'sum.test.js' }, () => { 7 | describe('sum', () => { 8 | it('should return the sum of two numbers', () => { 9 | assert.equal(1 + 2, 3) 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/cypress.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { addHook } = require('./helpers/instrument') 4 | const { DD_MAJOR } = require('../../../version') 5 | 6 | // No handler because this is only useful for testing. 7 | // Cypress plugin does not patch any library. 8 | addHook({ 9 | name: 'cypress', 10 | versions: DD_MAJOR >= 6 ? ['>=10.2.0'] : ['>=6.7.0'] 11 | }, lib => lib) 12 | -------------------------------------------------------------------------------- /packages/datadog-plugin-apollo/src/gateway/postprocessing.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo') 4 | 5 | class ApolloGatewayPostProcessingPlugin extends ApolloBasePlugin { 6 | static operation = 'postprocessing' 7 | static prefix = 'tracing:apm:apollo:gateway:postprocessing' 8 | } 9 | 10 | module.exports = ApolloGatewayPostProcessingPlugin 11 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/analyzers/insecure-cookie-analyzer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { INSECURE_COOKIE } = require('../vulnerabilities') 4 | const CookieAnalyzer = require('./cookie-analyzer') 5 | 6 | class InsecureCookieAnalyzer extends CookieAnalyzer { 7 | constructor () { 8 | super(INSECURE_COOKIE, 'secure') 9 | } 10 | } 11 | 12 | module.exports = new InsecureCookieAnalyzer() 13 | -------------------------------------------------------------------------------- /packages/dd-trace/src/crashtracking/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { isMainThread } = require('worker_threads') 4 | const log = require('../log') 5 | 6 | if (isMainThread) { 7 | try { 8 | module.exports = require('./crashtracker') 9 | } catch (e) { 10 | log.warn(e.message) 11 | module.exports = require('./noop') 12 | } 13 | } else { 14 | module.exports = require('./noop') 15 | } 16 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-management/test-attempt-to-fix-2.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('attempt to fix tests 2', () => { 5 | it('can attempt to fix a test', () => { 6 | // eslint-disable-next-line no-console 7 | console.log('I am running when attempt to fix 2') // to check if this is being run 8 | assert.strictEqual(1 + 2, 3) 9 | }) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/helpers/rewriter/loader.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Module = require('module') 4 | const shimmer = require('../../../../datadog-shimmer') 5 | const { rewrite } = require('./') 6 | 7 | shimmer.wrap(Module.prototype, '_compile', compile => function (content, filename, format) { 8 | return compile.call(this, rewrite(content, filename, format), filename, format) 9 | }) 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-cassandra-driver/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import cassandra from 'cassandra-driver' 3 | 4 | const client = new cassandra.Client({ 5 | contactPoints: ['127.0.0.1'], 6 | localDataCenter: 'datacenter1', 7 | keyspace: 'system' 8 | }) 9 | 10 | await client.connect() 11 | await client.execute('SELECT now() FROM local;') 12 | await client.shutdown() 13 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/hardcoded-password-analyzer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function extractSensitiveRanges (evidence, valuePattern) { 4 | const { value } = evidence 5 | if (valuePattern.test(value)) { 6 | return [{ 7 | start: 0, 8 | end: value.length 9 | }] 10 | } 11 | 12 | return [] 13 | } 14 | -------------------------------------------------------------------------------- /packages/dd-trace/src/profiling/constants.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const snapshotKinds = Object.freeze({ 4 | PERIODIC: 'periodic', 5 | ON_SHUTDOWN: 'on_shutdown', 6 | ON_OUT_OF_MEMORY: 'on_oom' 7 | }) 8 | 9 | const oomExportStrategies = Object.freeze({ 10 | PROCESS: 'process', 11 | ASYNC_CALLBACK: 'async', 12 | LOGS: 'logs' 13 | }) 14 | 15 | module.exports = { snapshotKinds, oomExportStrategies } 16 | -------------------------------------------------------------------------------- /packages/dd-trace/test/helpers/config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const proxyquire = require('proxyquire') 4 | 5 | // Resolve the config module from within the test package 6 | const CONFIG_PATH = require.resolve('../../src/config') 7 | 8 | function getConfigFresh (options) { 9 | return proxyquire.noPreserveCache()(CONFIG_PATH, {})(options) 10 | } 11 | 12 | module.exports = { 13 | getConfigFresh, 14 | } 15 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/done-fail.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-test-done-fail', () => { 5 | it('can do failed tests with done', (done) => { 6 | setTimeout(() => { 7 | try { 8 | assert.strictEqual(true, false) 9 | done() 10 | } catch (e) { 11 | done(e) 12 | } 13 | }, 100) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/done-pass.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('mocha-test-done-pass', () => { 5 | it('can do passed tests with done', (done) => { 6 | setTimeout(() => { 7 | try { 8 | assert.strictEqual(true, true) 9 | done() 10 | } catch (e) { 11 | done(e) 12 | } 13 | }, 100) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-retries-test-fn/mocha-async.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | let attempt = 0 5 | 6 | describe('mocha-async-retries', function () { 7 | this.retries(4) 8 | 9 | it('will be retried and pass', async () => { 10 | await new Promise(resolve => { 11 | setTimeout(resolve, 0) 12 | }) 13 | assert.equal(attempt++, 2) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/subproject/cypress.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | defaultCommandTimeout: 1000, 5 | e2e: { 6 | setupNodeEvents (on, config) { 7 | return require('dd-trace/ci/cypress/plugin')(on, config) 8 | }, 9 | specPattern: process.env.SPEC_PATTERN || 'cypress/e2e/**/*.cy.js' 10 | }, 11 | video: false, 12 | screenshotOnRunFailure: false 13 | } 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/unskippable-test/test-unskippable.js: -------------------------------------------------------------------------------- 1 | /** Some comment */ 2 | /* eslint-disable jsdoc/valid-types */ 3 | /** 4 | * @datadog {"unskippable": true} 5 | */ 6 | /* Some other comment */ 7 | 'use strict' 8 | 9 | const assert = require('assert') 10 | 11 | describe('test-unskippable', () => { 12 | it('can report tests', () => { 13 | assert.strictEqual(1 + 2, 3) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /integration-tests/config-jest.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | projects: process.env.PROJECTS ? JSON.parse(process.env.PROJECTS) : [__dirname], 5 | testPathIgnorePatterns: ['/node_modules/'], 6 | cache: false, 7 | testMatch: [ 8 | process.env.TESTS_TO_RUN || '**/ci-visibility/test/ci-visibility-test*' 9 | ], 10 | testRunner: 'jest-circus/runner', 11 | testEnvironment: 'node' 12 | } 13 | -------------------------------------------------------------------------------- /integration-tests/cypress/e2e/impacted-test-order.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | describe('impacted test order', () => { 4 | it('first test', () => { 5 | cy.visit('/') 6 | .get('.hello-world') 7 | .should('have.text', 'Hello World') 8 | }) 9 | 10 | it('second test', () => { 11 | cy.visit('/') 12 | .get('.hello-world') 13 | .should('have.text', 'Hello World') 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/test/bluebird.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('../src/bluebird') 4 | 5 | const assertPromise = require('./helpers/promise') 6 | 7 | assertPromise('bluebird') 8 | 9 | assertPromise('bluebird', bluebird => bluebird.getNewLibraryCopy(), '^2.11.0 || ^3.4.1') 10 | 11 | assertPromise('bluebird', bluebird => bluebird.getNewLibraryCopy().getNewLibraryCopy(), '^2.11.0 || ^3.4.1') 12 | -------------------------------------------------------------------------------- /packages/dd-trace/test/debugger/devtools_client/snapshot/target-code/max-reference-depth.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function run () { 4 | // eslint-disable-next-line no-unused-vars 5 | const myNestedObj = { 6 | deepObj: { foo: { foo: { foo: { foo: { foo: true } } } } }, 7 | deepArr: [[[[[42]]]]] 8 | } 9 | return 'my return value' // breakpoint at this line 10 | } 11 | 12 | module.exports = { run } 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/playwright-test-duration/short-suite-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, expect } = require('@playwright/test') 4 | 5 | test.describe('short suite', () => { 6 | test('should be able to run', async () => { 7 | expect(true).toBe(true) 8 | }) 9 | 10 | test.skip('should skip and not mess up the duration of the test suite', async () => { 11 | // TODO 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/playwright-tests/skipped-suite-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, expect } = require('@playwright/test') 4 | 5 | test.beforeEach(async ({ page }) => { 6 | await page.goto(process.env.PW_BASE_URL) 7 | }) 8 | 9 | test.fixme('should work with fixme root', async ({ page }) => { 10 | await expect(page.locator('.hello-world')).toHaveText([ 11 | 'Hello Warld' 12 | ]) 13 | }) 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-amqplib/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import amqplib from 'amqplib' 3 | 4 | const connection = await amqplib.connect('amqp://localhost:5672') 5 | const channel = await connection.createChannel() 6 | 7 | await channel.assertQueue('test', {}) 8 | 9 | if (channel) { 10 | await channel.close() 11 | } 12 | if (connection) { 13 | await connection.close() 14 | } 15 | -------------------------------------------------------------------------------- /packages/datadog-plugin-mongodb-core/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import mongodb from 'mongodb' 3 | 4 | const client = new mongodb.MongoClient('mongodb://127.0.0.1:27017') 5 | await client.connect() 6 | const db = client.db('test_db') 7 | const collection = db.collection('test_collection') 8 | collection.insertOne({ a: 1 }, {}, () => {}) 9 | setTimeout(() => { client.close() }, 1500) 10 | -------------------------------------------------------------------------------- /packages/datadog-plugin-protobufjs/test/schemas/other_message_proto.json: -------------------------------------------------------------------------------- 1 | { 2 | "nested": { 3 | "OtherMessage": { 4 | "fields": { 5 | "name": { 6 | "rule": "repeated", 7 | "type": "string", 8 | "id": 1 9 | }, 10 | "age": { 11 | "type": "int32", 12 | "id": 2 13 | } 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/analyzers/no-httponly-cookie-analyzer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { NO_HTTPONLY_COOKIE } = require('../vulnerabilities') 4 | const CookieAnalyzer = require('./cookie-analyzer') 5 | 6 | class NoHttponlyCookieAnalyzer extends CookieAnalyzer { 7 | constructor () { 8 | super(NO_HTTPONLY_COOKIE, 'HttpOnly') 9 | } 10 | } 11 | 12 | module.exports = new NoHttponlyCookieAnalyzer() 13 | -------------------------------------------------------------------------------- /packages/dd-trace/test/opentracing/api.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('tap').mochaGlobals() 4 | require('../setup/core') 5 | 6 | const apiCompatibilityChecks = require('opentracing/lib/test/api_compatibility').default 7 | const tracer = require('../..') 8 | 9 | apiCompatibilityChecks(() => { 10 | return tracer.init({ 11 | service: 'test', 12 | flushInterval: 0, 13 | plugins: false 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/dynamic-instrumentation/parallel-test-hit-breakpoint-1.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const sum = require('./dependency') 6 | describe('dynamic-instrumentation', () => { 7 | it('retries with DI', function () { 8 | assert.strictEqual(sum(11, 3), 14) 9 | }) 10 | 11 | it('is not retried', () => { 12 | assert.strictEqual(1 + 2, 3) 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/mocha-plugin-tests/retries.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | let attempt = 0 5 | 6 | describe('mocha-test-retries', function () { 7 | this.retries(4) 8 | 9 | it('will be retried and pass', () => { 10 | assert.strictEqual(attempt++, 2) 11 | }) 12 | 13 | it('will be retried and fail', () => { 14 | assert.strictEqual(attempt++, 8) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/when.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { addHook } = require('./helpers/instrument') 4 | const { wrapThen } = require('./helpers/promise') 5 | const shimmer = require('../../datadog-shimmer') 6 | 7 | addHook({ 8 | name: 'when', 9 | file: 'lib/Promise.js', 10 | versions: ['>=3'] 11 | }, Promise => { 12 | shimmer.wrap(Promise.prototype, 'then', wrapThen) 13 | return Promise 14 | }) 15 | -------------------------------------------------------------------------------- /packages/datadog-plugin-apollo/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const CompositePlugin = require('../../dd-trace/src/plugins/composite') 4 | const ApolloGatewayPlugin = require('./gateway') 5 | 6 | class ApolloPlugin extends CompositePlugin { 7 | static id = 'apollo' 8 | static get plugins () { 9 | return { 10 | gateway: ApolloGatewayPlugin 11 | } 12 | } 13 | } 14 | 15 | module.exports = ApolloPlugin 16 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/fixtures/base.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fixtures = { 4 | cloudwatchlogs: require('./cloudwatchlogs'), 5 | dynamodb: require('./dynamodb'), 6 | kinesis: require('./kinesis'), 7 | lambda: require('./lambda'), 8 | s3: require('./s3'), 9 | redshift: require('./redshift'), 10 | sns: require('./sns'), 11 | sqs: require('./sqs') 12 | } 13 | 14 | module.exports = fixtures 15 | -------------------------------------------------------------------------------- /packages/dd-trace/src/appsec/iast/analyzers/no-samesite-cookie-analyzer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { NO_SAMESITE_COOKIE } = require('../vulnerabilities') 4 | const CookieAnalyzer = require('./cookie-analyzer') 5 | 6 | class NoSamesiteCookieAnalyzer extends CookieAnalyzer { 7 | constructor () { 8 | super(NO_SAMESITE_COOKIE, 'SameSite=strict') 9 | } 10 | } 11 | 12 | module.exports = new NoSamesiteCookieAnalyzer() 13 | -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-cjs/esbuild-no-iast.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* eslint-disable no-console */ 4 | 5 | const esbuild = require('esbuild') 6 | 7 | const esbuildCommonConfig = require('./esbuild.common-config') 8 | 9 | esbuild.build({ 10 | ...esbuildCommonConfig, 11 | outfile: 'build/iast-disabled.js', 12 | sourcemap: false 13 | }).catch((err) => { 14 | console.error(err) 15 | process.exit(1) 16 | }) 17 | -------------------------------------------------------------------------------- /integration-tests/appsec/iast-esbuild-cjs/esbuild.common-config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const ddPlugin = require('dd-trace/esbuild') 4 | 5 | module.exports = { 6 | entryPoints: ['app.js'], 7 | bundle: true, 8 | minify: true, 9 | plugins: [ddPlugin], 10 | platform: 'node', 11 | target: ['node18'], 12 | external: [ 13 | '@datadog/native-iast-taint-tracking', 14 | '@datadog/wasm-js-rewriter' 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/features-impacted-test/support/steps.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | const { When, Then } = require('@cucumber/cucumber') 5 | 6 | Then('I should have heard {string}', function (expectedResponse) { 7 | assert.equal(this.whatIHeard, expectedResponse) 8 | }) 9 | 10 | When('the greeter says impacted test', function () { 11 | this.whatIHeard = 'impacted test' 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/jest/failing-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | describe('failing', () => { 5 | it.failing('can report failed tests', () => { 6 | assert.strictEqual(1 + 2, 4) 7 | }) 8 | 9 | it.failing('can report failing tests as failures', () => { 10 | assert.strictEqual(1 + 2, 3) // this passes but it should fail! So the test.status should be fail 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/playwright-tests-test-capabilities/passing-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { test, expect } = require('@playwright/test') 4 | 5 | test.beforeEach(async ({ page }) => { 6 | await page.goto(process.env.PW_BASE_URL) 7 | }) 8 | 9 | test('should work with passing tests', async ({ page }) => { 10 | await expect(page.locator('.hello-world')).toHaveText([ 11 | 'Hello World' 12 | ]) 13 | }) 14 | -------------------------------------------------------------------------------- /integration-tests/cypress/e2e/multi-origin.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | it('tests multiple origins', () => { 4 | // Visit first site 5 | cy.visit('/'); 6 | cy.get('.hello-world') 7 | .should('have.text', 'Hello World') 8 | 9 | // Visit second site 10 | cy.origin(Cypress.env('BASE_URL_SECOND'), () => { 11 | cy.visit('/') 12 | cy.get('.hella-world').should('have.text', 'Hella World') 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/datadog-instrumentations/src/promise.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { addHook } = require('./helpers/instrument') 4 | const { wrapThen } = require('./helpers/promise') 5 | const shimmer = require('../../datadog-shimmer') 6 | 7 | addHook({ 8 | name: 'promise', 9 | file: 'lib/core.js', 10 | versions: ['>=7'] 11 | }, Promise => { 12 | shimmer.wrap(Promise.prototype, 'then', wrapThen) 13 | return Promise 14 | }) 15 | -------------------------------------------------------------------------------- /packages/datadog-plugin-aws-sdk/test/fixtures/redshift.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const redshift = {} 4 | 5 | redshift.create = { 6 | ClusterIdentifier: 'example_redshift_cluster', 7 | MasterUserPassword: 'example_user_password', 8 | MasterUsername: 'example_username', 9 | NodeType: 'ds2.large' 10 | } 11 | 12 | redshift.get = { 13 | ClusterIdentifier: 'example_redshift_cluster' 14 | } 15 | 16 | module.exports = redshift 17 | -------------------------------------------------------------------------------- /packages/datadog-plugin-fastify/test/integration-test/helper.mjs: -------------------------------------------------------------------------------- 1 | export async function createAndStartServer (app) { 2 | app.get('/', async (request, reply) => { 3 | return 'hello, world\n' 4 | }) 5 | 6 | try { 7 | await app.listen({ port: 0 }) 8 | const address = app.server.address() 9 | const port = address.port 10 | process.send({ port }) 11 | } catch (err) { 12 | process.exit(1) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/datadog-plugin-mysql/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import mysql from 'mysql' 3 | 4 | const conn = { 5 | host: 'localhost', 6 | user: 'root', 7 | database: 'db', 8 | port: 3306 9 | } 10 | 11 | const connection = mysql.createConnection(conn) 12 | connection.connect() 13 | 14 | connection.query('SELECT NOW() AS now', function (error, results, fields) {}) 15 | 16 | connection.end() 17 | -------------------------------------------------------------------------------- /packages/dd-trace/src/exporters/common/util.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { getEnvironmentVariable } = require('../../config-helper') 4 | 5 | function safeJSONStringify (value) { 6 | return JSON.stringify( 7 | value, 8 | (key, value) => key === 'dd-api-key' ? undefined : value, 9 | getEnvironmentVariable('DD_TRACE_BEAUTIFUL_LOGS') ? 2 : undefined 10 | ) 11 | } 12 | 13 | module.exports = { safeJSONStringify } 14 | -------------------------------------------------------------------------------- /packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const DNSPlugin = require('./dns') 4 | 5 | class DNSLookupPlugin extends DNSPlugin { 6 | static operation = 'lookup' 7 | 8 | extendEvent (event, startEvent) { 9 | event.name = 'lookup' 10 | event.detail = { hostname: startEvent.args[0] } 11 | 12 | return event 13 | } 14 | } 15 | 16 | module.exports = DNSLookupPlugin 17 | -------------------------------------------------------------------------------- /benchmark/sirun/plugin-q/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | if (Number(process.env.USE_TRACER)) { 4 | require('../../..').init() 5 | } 6 | 7 | const Q = require('../../../versions/q').get() 8 | 9 | const count = process.env.COUNT ? Number(process.env.COUNT) : 50000 10 | 11 | const p = Q.defer() 12 | let pChain = p.promise 13 | 14 | for (let i = 0; i < count; i++) { 15 | pChain = pChain.then(() => {}) 16 | } 17 | 18 | p.resolve() 19 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "1.0.0", 4 | "main": "typedoc.js", 5 | "scripts": { 6 | "build": "typedoc ../index.d.ts && ./add-redirects.sh", 7 | "pretest": "tsc -p . && tsc --types node test", 8 | "test": "node test" 9 | }, 10 | "license": "BSD-3-Clause", 11 | "private": true, 12 | "devDependencies": { 13 | "typedoc": "^0.28.12", 14 | "typescript": "^5.9.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /integration-tests/helpers/bun.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { join, resolve } = require('path') 4 | 5 | const PROJECT_ROOT = resolve(__dirname, '..', '..') 6 | const BUN_INSTALL = join(PROJECT_ROOT, '.bun') 7 | const BUN = join(PROJECT_ROOT, 'node_modules', '.bin', 'bun') 8 | 9 | function withBun (env = process.env) { 10 | return { ...env, BUN_INSTALL, _DD_IGNORE_ENGINES: true } 11 | } 12 | 13 | module.exports = { BUN, withBun } 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-amqp10/src/util.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function getAddress (link) { 4 | if (!link || !link.session || !link.session.connection) return {} 5 | 6 | return link.session.connection.address || {} 7 | } 8 | 9 | function getShortName (link) { 10 | if (!link || !link.name) return null 11 | 12 | return link.name.split('_').slice(0, -1).join('_') 13 | } 14 | 15 | module.exports = { getAddress, getShortName } 16 | -------------------------------------------------------------------------------- /packages/datadog-plugin-couchbase/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import { connect } from 'couchbase' 3 | 4 | const cluster = await connect( 5 | 'couchbase://127.0.0.1', 6 | { 7 | username: 'Administrator', 8 | password: 'password' 9 | }) 10 | 11 | const bucket = cluster.bucket('datadog-test') 12 | const coll = bucket.defaultCollection() 13 | await coll.upsert('testdoc', { name: 'Frank' }) 14 | -------------------------------------------------------------------------------- /packages/datadog-plugin-prisma/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import { PrismaClient } from '@prisma/client' 3 | 4 | const prismaClient = new PrismaClient() 5 | const user = await prismaClient.user.create({ 6 | data: { 7 | name: 'John Doe', 8 | email: 'john.doe@datadoghq.com' 9 | } 10 | }) 11 | 12 | await prismaClient.user.findUnique({ 13 | where: { 14 | id: user.id 15 | } 16 | }) 17 | -------------------------------------------------------------------------------- /packages/dd-trace/src/plugins/cache.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const StoragePlugin = require('./storage') 4 | 5 | class CachePlugin extends StoragePlugin { 6 | static operation = 'command' 7 | 8 | startSpan (options, ctx) { 9 | if (!options.kind) { 10 | options.kind = this.constructor.kind 11 | } 12 | return super.startSpan(this.operationName(), options, ctx) 13 | } 14 | } 15 | 16 | module.exports = CachePlugin 17 | -------------------------------------------------------------------------------- /packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const DNSPlugin = require('./dns') 4 | 5 | class DNSReversePlugin extends DNSPlugin { 6 | static operation = 'reverse' 7 | 8 | extendEvent (event, startEvent) { 9 | event.name = 'getHostByAddr' 10 | event.detail = { host: startEvent.args[0] } 11 | 12 | return event 13 | } 14 | } 15 | 16 | module.exports = DNSReversePlugin 17 | -------------------------------------------------------------------------------- /benchmark/sirun/event_loop.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { monitorEventLoopDelay } = require('perf_hooks') 4 | const StatsD = require('./statsd') 5 | const statsd = new StatsD() 6 | 7 | const histogram = monitorEventLoopDelay({ resolution: 1 }) 8 | 9 | histogram.enable() 10 | 11 | process.on('beforeExit', () => { 12 | histogram.disable() 13 | 14 | statsd.gauge('event_loop.delay.max', histogram.max) 15 | statsd.flush() 16 | }) 17 | -------------------------------------------------------------------------------- /benchmark/sirun/startup/README.md: -------------------------------------------------------------------------------- 1 | This is a simple startup test. It tests with an without the tracer, and with 2 | and without requiring every dependency and devDependency in the package.json, 3 | for a total of four variants. 4 | 5 | While it's unrealistic to load all the tracer's devDependencies, the intention 6 | is to simulate loading a lot of dependencies for an application, and have them 7 | either be intercepted by our loader hooks, or not. 8 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/automatic-log-submission/automatic-log-submission-test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | 5 | const logger = require('./logger') 6 | const sum = require('./sum') 7 | describe('test', () => { 8 | it('should return true', () => { 9 | logger.log('info', 'Hello simple log!') 10 | 11 | assert.strictEqual(true, true) 12 | assert.strictEqual(sum(1, 2), 3) 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /integration-tests/ci-visibility/test-optimization-wrong-init/run-jest.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | require('dd-trace').init({ 4 | service: 'sum-service-tests', 5 | }) 6 | 7 | const { runCLI } = require('jest') 8 | 9 | async function main () { 10 | const projectRoot = process.cwd() 11 | 12 | await runCLI( 13 | { 14 | testMatch: ['**/sum-wrong-init-test.js'], 15 | }, 16 | [projectRoot] 17 | ) 18 | } 19 | 20 | main() 21 | -------------------------------------------------------------------------------- /packages/datadog-plugin-mysql2/test/integration-test/server.mjs: -------------------------------------------------------------------------------- 1 | import 'dd-trace/init.js' 2 | import mysql from 'mysql2' 3 | 4 | const conn = { 5 | host: '127.0.0.1', 6 | user: 'root', 7 | database: 'db', 8 | port: 3306 9 | } 10 | 11 | const connection = mysql.createConnection(conn) 12 | 13 | connection.connect() 14 | 15 | connection.query('SELECT NOW() AS now', function (error, results, fields) {}) 16 | 17 | connection.end() 18 | -------------------------------------------------------------------------------- /packages/dd-trace/src/scope/noop/scope.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class Scope { 4 | constructor (span, finishSpanOnClose) { 5 | this._span = span 6 | this._finishSpanOnClose = finishSpanOnClose 7 | this.close() 8 | } 9 | 10 | span () { 11 | return this._span 12 | } 13 | 14 | close () { 15 | if (this._finishSpanOnClose) { 16 | this._span.finish() 17 | } 18 | } 19 | } 20 | 21 | module.exports = Scope 22 | -------------------------------------------------------------------------------- /vendor/dist/opentracing/binary_carrier.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Convenience class to use as a binary carrier. 3 | * 4 | * Any valid Object with a field named `buffer` may be used as a binary carrier; 5 | * this class is only one such type of object that can be used. 6 | */ 7 | export default class BinaryCarrier { 8 | buffer: ArrayLike; 9 | constructor(buffer: ArrayLike); 10 | } 11 | //# sourceMappingURL=binary_carrier.d.ts.map -------------------------------------------------------------------------------- /integration-tests/profiler/dnstest.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const dns = require('node:dns') 4 | 5 | require('dd-trace').init().profilerStarted().then(() => { 6 | dns.lookupService('13.224.103.60', 80, () => {}) 7 | dns.lookup('example.org', () => {}) 8 | dns.lookup('example.com', () => {}) 9 | dns.lookup('datadoghq.com', () => {}) 10 | dns.resolve4('datadoghq.com', () => {}) 11 | dns.lookup('dfslkgsjkrtgrdg.com', () => {}) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/dd-trace/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | if (!global._ddtrace) { 4 | const TracerProxy = require('./src') 5 | 6 | Object.defineProperty(global, '_ddtrace', { 7 | value: new TracerProxy(), 8 | enumerable: false, 9 | configurable: true, 10 | writable: true 11 | }) 12 | 13 | global._ddtrace.default = global._ddtrace 14 | global._ddtrace.tracer = global._ddtrace 15 | } 16 | 17 | module.exports = global._ddtrace 18 | --------------------------------------------------------------------------------