dd-trace 5.70.0 → 5.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE-3rdparty.csv +5 -0
  2. package/index.d.ts +110 -1
  3. package/initialize.mjs +7 -1
  4. package/package.json +21 -2
  5. package/packages/datadog-instrumentations/src/anthropic.js +115 -0
  6. package/packages/datadog-instrumentations/src/azure-event-hubs.js +37 -0
  7. package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
  8. package/packages/datadog-instrumentations/src/cucumber.js +7 -7
  9. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
  10. package/packages/datadog-instrumentations/src/jest.js +29 -36
  11. package/packages/datadog-instrumentations/src/mocha/main.js +8 -9
  12. package/packages/datadog-instrumentations/src/mocha/utils.js +1 -1
  13. package/packages/datadog-instrumentations/src/mocha/worker.js +2 -2
  14. package/packages/datadog-instrumentations/src/pg.js +1 -1
  15. package/packages/datadog-instrumentations/src/playwright.js +5 -5
  16. package/packages/datadog-instrumentations/src/vitest.js +8 -8
  17. package/packages/datadog-plugin-anthropic/src/index.js +17 -0
  18. package/packages/datadog-plugin-anthropic/src/tracing.js +30 -0
  19. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +73 -27
  20. package/packages/datadog-plugin-azure-event-hubs/src/index.js +15 -0
  21. package/packages/datadog-plugin-azure-event-hubs/src/producer.js +82 -0
  22. package/packages/datadog-plugin-azure-functions/src/index.js +37 -0
  23. package/packages/datadog-plugin-cucumber/src/index.js +3 -3
  24. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +9 -9
  25. package/packages/datadog-plugin-jest/src/util.js +10 -2
  26. package/packages/datadog-plugin-mocha/src/index.js +2 -2
  27. package/packages/datadog-plugin-playwright/src/index.js +2 -2
  28. package/packages/datadog-plugin-vitest/src/index.js +2 -2
  29. package/packages/datadog-plugin-ws/src/server.js +5 -3
  30. package/packages/dd-trace/src/appsec/reporter.js +70 -21
  31. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +1 -1
  32. package/packages/dd-trace/src/config.js +110 -26
  33. package/packages/dd-trace/src/config_defaults.js +14 -0
  34. package/packages/dd-trace/src/git_properties.js +90 -5
  35. package/packages/dd-trace/src/llmobs/plugins/anthropic.js +282 -0
  36. package/packages/dd-trace/src/llmobs/tagger.js +35 -0
  37. package/packages/dd-trace/src/noop/proxy.js +3 -0
  38. package/packages/dd-trace/src/openfeature/constants/constants.js +51 -0
  39. package/packages/dd-trace/src/openfeature/flagging_provider.js +45 -0
  40. package/packages/dd-trace/src/openfeature/index.js +77 -0
  41. package/packages/dd-trace/src/openfeature/noop.js +101 -0
  42. package/packages/dd-trace/src/openfeature/writers/base.js +181 -0
  43. package/packages/dd-trace/src/openfeature/writers/exposures.js +173 -0
  44. package/packages/dd-trace/src/openfeature/writers/util.js +43 -0
  45. package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +100 -0
  46. package/packages/dd-trace/src/opentelemetry/logs/index.js +87 -0
  47. package/packages/dd-trace/src/opentelemetry/logs/logger.js +77 -0
  48. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +126 -0
  49. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +173 -0
  50. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +367 -0
  51. package/packages/dd-trace/src/opentelemetry/protos/common.proto +116 -0
  52. package/packages/dd-trace/src/opentelemetry/protos/logs.proto +226 -0
  53. package/packages/dd-trace/src/opentelemetry/protos/logs_service.proto +78 -0
  54. package/packages/dd-trace/src/opentelemetry/protos/protobuf_loader.js +48 -0
  55. package/packages/dd-trace/src/opentelemetry/protos/resource.proto +45 -0
  56. package/packages/dd-trace/src/plugins/ci_plugin.js +7 -6
  57. package/packages/dd-trace/src/plugins/index.js +2 -0
  58. package/packages/dd-trace/src/plugins/util/test.js +6 -5
  59. package/packages/dd-trace/src/profiling/config.js +21 -1
  60. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +3 -2
  61. package/packages/dd-trace/src/profiling/profiler.js +44 -22
  62. package/packages/dd-trace/src/profiling/profilers/events.js +12 -3
  63. package/packages/dd-trace/src/profiling/profilers/space.js +35 -24
  64. package/packages/dd-trace/src/profiling/profilers/wall.js +14 -6
  65. package/packages/dd-trace/src/proxy.js +22 -1
  66. package/packages/dd-trace/src/remote_config/capabilities.js +2 -0
  67. package/packages/dd-trace/src/remote_config/index.js +3 -0
  68. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +4 -0
  69. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
  70. package/packages/dd-trace/src/supported-configurations.json +18 -0
  71. package/packages/dd-trace/src/telemetry/telemetry.js +13 -1
  72. package/register.js +9 -1
@@ -3,11 +3,14 @@ require,@datadog/libdatadog,Apache license 2.0,Copyright 2024 Datadog Inc.
3
3
  require,@datadog/native-appsec,Apache license 2.0,Copyright 2018 Datadog Inc.
4
4
  require,@datadog/native-metrics,Apache license 2.0,Copyright 2018 Datadog Inc.
5
5
  require,@datadog/native-iast-taint-tracking,Apache license 2.0,Copyright 2018 Datadog Inc.
6
+ require,@datadog/openfeature-node-server,Apache license 2.0,Copyright 2024 Datadog Inc.
6
7
  require,@datadog/pprof,Apache license 2.0,Copyright 2019 Google Inc.
7
8
  require,@datadog/sketches-js,Apache license 2.0,Copyright 2020 Datadog Inc.
8
9
  require,@datadog/wasm-js-rewriter,Apache license 2.0,Copyright 2018 Datadog Inc.
9
10
  require,@opentelemetry/api,Apache license 2.0,Copyright OpenTelemetry Authors
11
+ require,@opentelemetry/api-logs,Apache license 2.0,Copyright OpenTelemetry Authors
10
12
  require,@opentelemetry/core,Apache license 2.0,Copyright OpenTelemetry Authors
13
+ require,@opentelemetry/resources,Apache license 2.0,Copyright OpenTelemetry Authors
11
14
  require,@isaacs/ttlcache,ISC,Copyright (c) 2022-2023 - Isaac Z. Schlueter and Contributors
12
15
  require,crypto-randomuuid,MIT,Copyright 2021 Node.js Foundation and contributors
13
16
  require,dc-polyfill,MIT,Copyright 2023 Datadog Inc.
@@ -41,6 +44,8 @@ dev,@types/tap,MIT,Copyright (c) Microsoft Corp.
41
44
  dev,@eslint/eslintrc,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
42
45
  dev,@eslint/js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
43
46
  dev,@msgpack/msgpack,ISC,Copyright 2019 The MessagePack Community
47
+ dev,@openfeature/core,Apache-2.0,Copyright OpenFeature Authors
48
+ dev,@openfeature/server-sdk,Apache-2.0,Copyright OpenFeature Authors
44
49
  dev,@stylistic/eslint-plugin,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
45
50
  dev,axios,MIT,Copyright 2014-present Matt Zabriskie
46
51
  dev,benchmark,MIT,Copyright 2010-2016 Mathias Bynens Robert Kieffer John-David Dalton
package/index.d.ts CHANGED
@@ -139,6 +139,16 @@ interface Tracer extends opentracing.Tracer {
139
139
  */
140
140
  llmobs: tracer.llmobs.LLMObs;
141
141
 
142
+ /**
143
+ * OpenFeature Provider with Remote Config integration.
144
+ *
145
+ * Extends DatadogNodeServerProvider with Remote Config integration for dynamic flag configuration.
146
+ * Enable with DD_FLAGGING_PROVIDER_ENABLED=true.
147
+ *
148
+ * @beta This feature is in preview and not ready for production use
149
+ */
150
+ openfeature: tracer.OpenFeatureProvider;
151
+
142
152
  /**
143
153
  * AI Guard SDK
144
154
  */
@@ -168,9 +178,11 @@ interface Plugins {
168
178
  "aerospike": tracer.plugins.aerospike;
169
179
  "amqp10": tracer.plugins.amqp10;
170
180
  "amqplib": tracer.plugins.amqplib;
181
+ "anthropic": tracer.plugins.anthropic;
171
182
  "apollo": tracer.plugins.apollo;
172
183
  "avsc": tracer.plugins.avsc;
173
184
  "aws-sdk": tracer.plugins.aws_sdk;
185
+ "azure-event-hubs": tracer.plugins.azure_event_hubs;
174
186
  "azure-functions": tracer.plugins.azure_functions;
175
187
  "azure-service-bus": tracer.plugins.azure_service_bus;
176
188
  "bunyan": tracer.plugins.bunyan;
@@ -198,7 +210,7 @@ interface Plugins {
198
210
  "ioredis": tracer.plugins.ioredis;
199
211
  "iovalkey": tracer.plugins.iovalkey;
200
212
  "jest": tracer.plugins.jest;
201
- "kafkajs": tracer.plugins.kafkajs
213
+ "kafkajs": tracer.plugins.kafkajs;
202
214
  "knex": tracer.plugins.knex;
203
215
  "koa": tracer.plugins.koa;
204
216
  "langchain": tracer.plugins.langchain;
@@ -622,6 +634,21 @@ declare namespace tracer {
622
634
  */
623
635
  maxContentSize?: number
624
636
  }
637
+
638
+ /**
639
+ * Configuration for Feature Flagging & Experimentation.
640
+ *
641
+ * @beta This feature is in preview and not ready for production use
642
+ */
643
+ flaggingProvider?: {
644
+ /**
645
+ * Whether to enable the feature flagging provider.
646
+ * Requires Remote Config to be properly configured.
647
+ *
648
+ * @default false
649
+ */
650
+ enabled?: boolean
651
+ }
625
652
  };
626
653
 
627
654
  /**
@@ -785,6 +812,8 @@ declare namespace tracer {
785
812
 
786
813
  /** Whether to enable request body collection on RASP event
787
814
  * @default false
815
+ *
816
+ * @deprecated Use UI and Remote Configuration to enable extended data collection
788
817
  */
789
818
  bodyCollection?: boolean
790
819
  },
@@ -809,20 +838,28 @@ declare namespace tracer {
809
838
  },
810
839
  /**
811
840
  * Configuration for extended headers collection tied to security events
841
+ *
842
+ * @deprecated Use UI and Remote Configuration to enable extended data collection
812
843
  */
813
844
  extendedHeadersCollection?: {
814
845
  /** Whether to enable extended headers collection
815
846
  * @default false
847
+ *
848
+ * @deprecated Use UI and Remote Configuration to enable extended data collection
816
849
  */
817
850
  enabled: boolean,
818
851
 
819
852
  /** Whether to redact collected headers
820
853
  * @default true
854
+ *
855
+ * @deprecated Use UI and Remote Configuration to enable extended data collection
821
856
  */
822
857
  redaction: boolean,
823
858
 
824
859
  /** Specifies the maximum number of headers collected.
825
860
  * @default 50
861
+ *
862
+ * @deprecated Use UI and Remote Configuration to enable extended data collection
826
863
  */
827
864
  maxHeaders: number,
828
865
  }
@@ -1087,6 +1124,65 @@ declare namespace tracer {
1087
1124
  eventTrackingV2: EventTrackingV2
1088
1125
  }
1089
1126
 
1127
+ /**
1128
+ * Flagging Provider (OpenFeature-compatible).
1129
+ *
1130
+ * Wraps @datadog/openfeature-node-server with Remote Config integration for dynamic flag configuration.
1131
+ * Implements the OpenFeature Provider interface for flag evaluation.
1132
+ *
1133
+ * @beta This feature is in preview and not ready for production use
1134
+ */
1135
+ export interface OpenFeatureProvider {
1136
+ /**
1137
+ * Metadata about this provider.
1138
+ */
1139
+ metadata: { name: string; [key: string]: any };
1140
+
1141
+ /**
1142
+ * Resolves a boolean flag value.
1143
+ *
1144
+ * @param flagKey The key of the flag to evaluate
1145
+ * @param defaultValue The default value to return if evaluation fails
1146
+ * @param context Evaluation context (e.g., user attributes)
1147
+ * @param logger Optional logger instance
1148
+ * @returns Promise resolving to evaluation result with value and reason
1149
+ */
1150
+ resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: object, logger: object): Promise<{ value: boolean; reason?: string; [key: string]: any }>;
1151
+
1152
+ /**
1153
+ * Resolves a string flag value.
1154
+ *
1155
+ * @param flagKey The key of the flag to evaluate
1156
+ * @param defaultValue The default value to return if evaluation fails
1157
+ * @param context Evaluation context (e.g., user attributes)
1158
+ * @param logger Optional logger instance
1159
+ * @returns Promise resolving to evaluation result with value and reason
1160
+ */
1161
+ resolveStringEvaluation(flagKey: string, defaultValue: string, context: object, logger: object): Promise<{ value: string; reason?: string; [key: string]: any }>;
1162
+
1163
+ /**
1164
+ * Resolves a number flag value.
1165
+ *
1166
+ * @param flagKey The key of the flag to evaluate
1167
+ * @param defaultValue The default value to return if evaluation fails
1168
+ * @param context Evaluation context (e.g., user attributes)
1169
+ * @param logger Optional logger instance
1170
+ * @returns Promise resolving to evaluation result with value and reason
1171
+ */
1172
+ resolveNumberEvaluation(flagKey: string, defaultValue: number, context: object, logger: object): Promise<{ value: number; reason?: string; [key: string]: any }>;
1173
+
1174
+ /**
1175
+ * Resolves an object flag value.
1176
+ *
1177
+ * @param flagKey The key of the flag to evaluate
1178
+ * @param defaultValue The default value to return if evaluation fails
1179
+ * @param context Evaluation context (e.g., user attributes)
1180
+ * @param logger Optional logger instance
1181
+ * @returns Promise resolving to evaluation result with value and reason
1182
+ */
1183
+ resolveObjectEvaluation<T = any>(flagKey: string, defaultValue: T, context: object, logger: object): Promise<{ value: T; reason?: string; [key: string]: any }>;
1184
+ }
1185
+
1090
1186
  export namespace aiguard {
1091
1187
 
1092
1188
  /**
@@ -1530,6 +1626,12 @@ declare namespace tracer {
1530
1626
  */
1531
1627
  interface amqplib extends Instrumentation {}
1532
1628
 
1629
+ /**
1630
+ * This plugin automatically instruments the
1631
+ * [anthropic](https://www.npmjs.com/package/@anthropic-ai/sdk) module.
1632
+ */
1633
+ interface anthropic extends Instrumentation {}
1634
+
1533
1635
  /**
1534
1636
  * Currently this plugin automatically instruments
1535
1637
  * [@apollo/gateway](https://github.com/apollographql/federation) for module versions >= v2.3.0.
@@ -1601,6 +1703,12 @@ declare namespace tracer {
1601
1703
  [key: string]: boolean | Object | undefined;
1602
1704
  }
1603
1705
 
1706
+ /**
1707
+ * This plugin automatically instruments the
1708
+ * @azure/event-hubs module
1709
+ */
1710
+ interface azure_event_hubs extends Integration {}
1711
+
1604
1712
  /**
1605
1713
  * This plugin automatically instruments the
1606
1714
  * @azure/functions module.
@@ -1612,6 +1720,7 @@ declare namespace tracer {
1612
1720
  * @azure/service-bus module
1613
1721
  */
1614
1722
  interface azure_service_bus extends Integration {}
1723
+
1615
1724
  /**
1616
1725
  * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
1617
1726
  * to automatically inject trace identifiers in log records when the
package/initialize.mjs CHANGED
@@ -36,7 +36,13 @@ ${result.source}`
36
36
  const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(Number)
37
37
 
38
38
  const brokenLoaders = NODE_MAJOR === 18 && NODE_MINOR === 0
39
- const iitmExclusions = [/langsmith/, /openai\/_shims/, /openai\/resources\/chat\/completions\/messages/, /openai\/agents-core\/dist\/shims/]
39
+ const iitmExclusions = [
40
+ /langsmith/,
41
+ /openai\/_shims/,
42
+ /openai\/resources\/chat\/completions\/messages/,
43
+ /openai\/agents-core\/dist\/shims/,
44
+ /@anthropic-ai\/sdk\/_shims/
45
+ ]
40
46
 
41
47
  export async function load (url, context, nextLoad) {
42
48
  const iitmExclusionsMatch = iitmExclusions.some((exclusion) => exclusion.test(url))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.70.0",
3
+ "version": "5.72.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -46,6 +46,7 @@
46
46
  "test:llmobs:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:plugins",
47
47
  "test:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\"",
48
48
  "test:plugins:ci": "yarn services && nyc --no-clean --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins",
49
+ "test:plugins:ci:flaky": "yarn services && nyc --no-clean --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins -- --bail --retries 2",
49
50
  "test:plugins:upstream": "node ./packages/dd-trace/test/plugins/suite.js",
50
51
  "test:profiler": "tap \"packages/dd-trace/test/profiling/**/*.spec.js\"",
51
52
  "test:profiler:ci": "npm run test:profiler -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/profiling/**/*.js\"",
@@ -56,6 +57,7 @@
56
57
  "test:integration:cypress": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/cypress/*.spec.js\"",
57
58
  "test:integration:debugger": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/debugger/*.spec.js\"",
58
59
  "test:integration:esbuild": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/esbuild/*.spec.js\"",
60
+ "test:integration:openfeature": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/openfeature/*.spec.js\"",
59
61
  "test:integration:jest": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/jest/*.spec.js\"",
60
62
  "test:integration:mocha": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/mocha/*.spec.js\"",
61
63
  "test:integration:playwright": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/playwright/*.spec.js\"",
@@ -121,12 +123,15 @@
121
123
  "@datadog/native-appsec": "10.2.1",
122
124
  "@datadog/native-iast-taint-tracking": "4.0.0",
123
125
  "@datadog/native-metrics": "3.1.1",
124
- "@datadog/pprof": "5.10.0",
126
+ "@datadog/openfeature-node-server": "0.1.0-preview.10",
127
+ "@datadog/pprof": "5.11.1",
125
128
  "@datadog/sketches-js": "2.1.1",
126
129
  "@datadog/wasm-js-rewriter": "4.0.1",
127
130
  "@isaacs/ttlcache": "^1.4.1",
128
131
  "@opentelemetry/api": ">=1.0.0 <1.10.0",
132
+ "@opentelemetry/api-logs": "<1.0.0",
129
133
  "@opentelemetry/core": ">=1.14.0 <1.31.0",
134
+ "@opentelemetry/resources": ">=1.0.0 <1.10.0",
130
135
  "crypto-randomuuid": "^1.0.0",
131
136
  "dc-polyfill": "^0.1.10",
132
137
  "ignore": "^7.0.5",
@@ -151,11 +156,25 @@
151
156
  "tlhunter-sorted-set": "^0.1.0",
152
157
  "ttl-set": "^1.0.0"
153
158
  },
159
+ "peerDependencies": {
160
+ "@openfeature/core": "^1.9.0",
161
+ "@openfeature/server-sdk": "~1.18.0"
162
+ },
163
+ "peerDependenciesMeta": {
164
+ "@openfeature/core": {
165
+ "optional": true
166
+ },
167
+ "@openfeature/server-sdk": {
168
+ "optional": true
169
+ }
170
+ },
154
171
  "devDependencies": {
155
172
  "@babel/helpers": "^7.27.6",
156
173
  "@eslint/eslintrc": "^3.3.1",
157
174
  "@eslint/js": "^9.29.0",
158
175
  "@msgpack/msgpack": "^3.1.2",
176
+ "@openfeature/core": "^1.8.1",
177
+ "@openfeature/server-sdk": "~1.18.0",
159
178
  "@stylistic/eslint-plugin": "^5.0.0",
160
179
  "@types/chai": "^4.3.16",
161
180
  "@types/mocha": "^10.0.10",
@@ -0,0 +1,115 @@
1
+ 'use strict'
2
+
3
+ const { addHook } = require('./helpers/instrument')
4
+ const shimmer = require('../../datadog-shimmer')
5
+ const { channel, tracingChannel } = require('dc-polyfill')
6
+
7
+ const anthropicTracingChannel = tracingChannel('apm:anthropic:request')
8
+ const onStreamedChunkCh = channel('apm:anthropic:request:chunk')
9
+
10
+ function wrapStreamIterator (iterator, ctx) {
11
+ return function () {
12
+ const itr = iterator.apply(this, arguments)
13
+ shimmer.wrap(itr, 'next', next => function () {
14
+ return next.apply(this, arguments)
15
+ .then(res => {
16
+ const { done, value: chunk } = res
17
+ onStreamedChunkCh.publish({ ctx, chunk, done })
18
+
19
+ if (done) {
20
+ finish(ctx)
21
+ }
22
+
23
+ return res
24
+ })
25
+ .catch(error => {
26
+ finish(ctx, null, error)
27
+ throw error
28
+ })
29
+ })
30
+
31
+ return itr
32
+ }
33
+ }
34
+
35
+ function wrapCreate (create) {
36
+ return function () {
37
+ if (!anthropicTracingChannel.start.hasSubscribers) {
38
+ return create.apply(this, arguments)
39
+ }
40
+
41
+ const options = arguments[0]
42
+ const stream = options.stream
43
+
44
+ const ctx = { options, resource: 'create' }
45
+
46
+ return anthropicTracingChannel.start.runStores(ctx, () => {
47
+ let apiPromise
48
+ try {
49
+ apiPromise = create.apply(this, arguments)
50
+ } catch (error) {
51
+ finish(ctx, null, error)
52
+ throw error
53
+ }
54
+
55
+ shimmer.wrap(apiPromise, 'parse', parse => function () {
56
+ return parse.apply(this, arguments)
57
+ .then(response => {
58
+ if (stream) {
59
+ shimmer.wrap(response, Symbol.asyncIterator, iterator => wrapStreamIterator(iterator, ctx))
60
+ } else {
61
+ finish(ctx, response, null)
62
+ }
63
+
64
+ return response
65
+ }).catch(error => {
66
+ finish(ctx, null, error)
67
+ throw error
68
+ })
69
+ })
70
+
71
+ anthropicTracingChannel.end.publish(ctx)
72
+
73
+ return apiPromise
74
+ })
75
+ }
76
+ }
77
+
78
+ function finish (ctx, result, error) {
79
+ if (error) {
80
+ ctx.error = error
81
+ anthropicTracingChannel.error.publish(ctx)
82
+ }
83
+
84
+ // streamed responses are handled and set separately
85
+ ctx.result ??= result
86
+
87
+ anthropicTracingChannel.asyncEnd.publish(ctx)
88
+ }
89
+
90
+ const extensions = ['js', 'mjs']
91
+ for (const extension of extensions) {
92
+ addHook({
93
+ name: '@anthropic-ai/sdk',
94
+ file: `resources/messages.${extension}`,
95
+ versions: ['>=0.14.0 <0.33.0']
96
+ }, exports => {
97
+ const Messages = exports.Messages
98
+
99
+ shimmer.wrap(Messages.prototype, 'create', wrapCreate)
100
+
101
+ return exports
102
+ })
103
+
104
+ addHook({
105
+ name: '@anthropic-ai/sdk',
106
+ file: `resources/messages/messages.${extension}`,
107
+ versions: ['>=0.33.0']
108
+ }, exports => {
109
+ const Messages = exports.Messages
110
+
111
+ shimmer.wrap(Messages.prototype, 'create', wrapCreate)
112
+
113
+ return exports
114
+ })
115
+ }
@@ -0,0 +1,37 @@
1
+ 'use strict'
2
+
3
+ const {
4
+ addHook
5
+ } = require('./helpers/instrument')
6
+ const shimmer = require('../../datadog-shimmer')
7
+ const dc = require('dc-polyfill')
8
+
9
+ const producerCh = dc.tracingChannel('apm:azure-event-hubs:send')
10
+
11
+ addHook({
12
+ name: '@azure/event-hubs',
13
+ versions: ['>=6.0.0']
14
+ }, obj => {
15
+ const EventHubProducerClient = obj.EventHubProducerClient
16
+ shimmer.wrap(EventHubProducerClient.prototype, 'createBatch',
17
+ createBatch => async function () {
18
+ const batch = await createBatch.apply(this, arguments)
19
+ shimmer.wrap(batch, 'tryAdd',
20
+ tryAdd => function (eventData) {
21
+ const config = this._context.config
22
+ const functionName = tryAdd.name
23
+ return producerCh.tracePromise(
24
+ tryAdd,
25
+ { functionName, eventData, batch: this, config },
26
+ this, ...arguments)
27
+ })
28
+ return batch
29
+ })
30
+ shimmer.wrap(EventHubProducerClient.prototype, 'sendBatch',
31
+ sendBatch => function (eventData) {
32
+ const config = this._context.config
33
+ const functionName = sendBatch.name
34
+ return producerCh.tracePromise(sendBatch, { functionName, eventData, config }, this, ...arguments)
35
+ })
36
+ return obj
37
+ })
@@ -23,6 +23,9 @@ addHook({ name: '@azure/functions', versions: ['>=4'], patchDefault: false }, (a
23
23
  shimmer.wrap(app, 'serviceBusQueue', wrapHandler)
24
24
  shimmer.wrap(app, 'serviceBusTopic', wrapHandler)
25
25
 
26
+ // Event Hub triggers
27
+ shimmer.wrap(app, 'eventHub', wrapHandler)
28
+
26
29
  return azureFunction
27
30
  })
28
31
 
@@ -25,7 +25,7 @@ const skippableSuitesCh = channel('ci:cucumber:test-suite:skippable')
25
25
  const sessionStartCh = channel('ci:cucumber:session:start')
26
26
  const sessionFinishCh = channel('ci:cucumber:session:finish')
27
27
  const testManagementTestsCh = channel('ci:cucumber:test-management-tests')
28
- const impactedTestsCh = channel('ci:cucumber:modified-tests')
28
+ const modifiedFilesCh = channel('ci:cucumber:modified-files')
29
29
  const isModifiedCh = channel('ci:cucumber:is-modified-test')
30
30
 
31
31
  const workerReportTraceCh = channel('ci:cucumber:worker-report:trace')
@@ -80,7 +80,7 @@ let isTestManagementTestsEnabled = false
80
80
  let isImpactedTestsEnabled = false
81
81
  let testManagementAttemptToFixRetries = 0
82
82
  let testManagementTests = {}
83
- let modifiedTests = {}
83
+ let modifiedFiles = {}
84
84
  let numTestRetries = 0
85
85
  let knownTests = {}
86
86
  let skippedSuites = []
@@ -537,9 +537,9 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
537
537
  }
538
538
 
539
539
  if (isImpactedTestsEnabled) {
540
- const impactedTestsResponse = await getChannelPromise(impactedTestsCh)
540
+ const impactedTestsResponse = await getChannelPromise(modifiedFilesCh)
541
541
  if (!impactedTestsResponse.err) {
542
- modifiedTests = impactedTestsResponse.modifiedTests
542
+ modifiedFiles = impactedTestsResponse.modifiedFiles
543
543
  }
544
544
  }
545
545
 
@@ -655,7 +655,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
655
655
  isModifiedCh.publish({
656
656
  scenarios,
657
657
  testFileAbsolutePath: gherkinDocument.uri,
658
- modifiedTests,
658
+ modifiedFiles,
659
659
  stepIds,
660
660
  stepDefinitions: this.supportCodeLibrary.stepDefinitions,
661
661
  setIsModified
@@ -1000,7 +1000,7 @@ addHook({
1000
1000
 
1001
1001
  if (isImpactedTestsEnabled) {
1002
1002
  this.options.worldParameters._ddImpactedTestsEnabled = isImpactedTestsEnabled
1003
- this.options.worldParameters._ddModifiedTests = modifiedTests
1003
+ this.options.worldParameters._ddModifiedFiles = modifiedFiles
1004
1004
  }
1005
1005
 
1006
1006
  return startWorker.apply(this, arguments)
@@ -1036,7 +1036,7 @@ addHook({
1036
1036
  }
1037
1037
  isImpactedTestsEnabled = !!this.options.worldParameters._ddImpactedTestsEnabled
1038
1038
  if (isImpactedTestsEnabled) {
1039
- modifiedTests = this.options.worldParameters._ddModifiedTests
1039
+ modifiedFiles = this.options.worldParameters._ddModifiedFiles
1040
1040
  }
1041
1041
  }
1042
1042
  )
@@ -1,10 +1,12 @@
1
1
  'use strict'
2
2
 
3
3
  module.exports = {
4
+ '@anthropic-ai/sdk': { esmFirst: true, fn: () => require('../anthropic') },
4
5
  '@apollo/server': () => require('../apollo-server'),
5
6
  '@apollo/gateway': () => require('../apollo'),
6
7
  'apollo-server-core': () => require('../apollo-server-core'),
7
8
  '@aws-sdk/smithy-client': () => require('../aws-sdk'),
9
+ '@azure/event-hubs': () => require('../azure-event-hubs'),
8
10
  '@azure/functions': () => require('../azure-functions'),
9
11
  '@azure/service-bus': () => require('../azure-service-bus'),
10
12
  '@cucumber/cucumber': () => require('../cucumber'),