dd-trace 5.5.0 → 5.7.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 (80) hide show
  1. package/README.md +7 -0
  2. package/ci/cypress/after-spec.js +1 -0
  3. package/index.d.ts +1502 -1488
  4. package/package.json +4 -4
  5. package/packages/datadog-core/src/utils/src/get.js +11 -0
  6. package/packages/datadog-core/src/utils/src/has.js +14 -0
  7. package/packages/datadog-core/src/utils/src/set.js +16 -0
  8. package/packages/datadog-instrumentations/src/amqplib.js +1 -1
  9. package/packages/datadog-instrumentations/src/cucumber.js +2 -1
  10. package/packages/datadog-instrumentations/src/grpc/server.js +3 -1
  11. package/packages/datadog-instrumentations/src/jest.js +11 -5
  12. package/packages/datadog-instrumentations/src/mocha.js +4 -1
  13. package/packages/datadog-instrumentations/src/mongodb-core.js +34 -3
  14. package/packages/datadog-instrumentations/src/playwright.js +78 -16
  15. package/packages/datadog-plugin-amqplib/src/consumer.js +5 -4
  16. package/packages/datadog-plugin-amqplib/src/producer.js +3 -4
  17. package/packages/datadog-plugin-aws-sdk/src/base.js +3 -2
  18. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +4 -11
  19. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +3 -6
  20. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +5 -7
  21. package/packages/datadog-plugin-cucumber/src/index.js +2 -2
  22. package/packages/datadog-plugin-cypress/src/after-spec.js +3 -0
  23. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +123 -58
  24. package/packages/datadog-plugin-cypress/src/support.js +50 -3
  25. package/packages/datadog-plugin-graphql/src/index.js +1 -1
  26. package/packages/datadog-plugin-graphql/src/resolve.js +10 -8
  27. package/packages/datadog-plugin-grpc/src/util.js +1 -1
  28. package/packages/datadog-plugin-jest/src/index.js +13 -4
  29. package/packages/datadog-plugin-kafkajs/src/consumer.js +4 -3
  30. package/packages/datadog-plugin-kafkajs/src/producer.js +3 -5
  31. package/packages/datadog-plugin-mocha/src/index.js +2 -2
  32. package/packages/datadog-plugin-playwright/src/index.js +34 -3
  33. package/packages/datadog-plugin-rhea/src/consumer.js +5 -3
  34. package/packages/datadog-plugin-rhea/src/producer.js +3 -4
  35. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +23 -12
  36. package/packages/dd-trace/src/appsec/iast/index.js +10 -0
  37. package/packages/dd-trace/src/appsec/iast/path-line.js +9 -6
  38. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +1 -1
  39. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +6 -2
  40. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-telemetry.js +1 -1
  41. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +14 -2
  42. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
  43. package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +34 -27
  44. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +39 -11
  45. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +7 -6
  46. package/packages/dd-trace/src/appsec/recommended.json +67 -27
  47. package/packages/dd-trace/src/appsec/remote_config/index.js +1 -1
  48. package/packages/dd-trace/src/appsec/reporter.js +24 -11
  49. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +1 -3
  50. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +6 -1
  51. package/packages/dd-trace/src/config.js +451 -460
  52. package/packages/dd-trace/src/data_streams_context.js +1 -1
  53. package/packages/dd-trace/src/datastreams/pathway.js +58 -1
  54. package/packages/dd-trace/src/datastreams/processor.js +3 -5
  55. package/packages/dd-trace/src/format.js +0 -1
  56. package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -1
  57. package/packages/dd-trace/src/opentracing/propagation/text_map.js +22 -3
  58. package/packages/dd-trace/src/opentracing/span.js +2 -0
  59. package/packages/dd-trace/src/opentracing/span_context.js +1 -0
  60. package/packages/dd-trace/src/plugins/util/test.js +4 -2
  61. package/packages/dd-trace/src/plugins/util/web.js +1 -1
  62. package/packages/dd-trace/src/priority_sampler.js +11 -6
  63. package/packages/dd-trace/src/profiling/exporters/agent.js +38 -2
  64. package/packages/dd-trace/src/telemetry/index.js +32 -33
  65. package/packages/dd-trace/src/tracer.js +3 -3
  66. package/register.js +4 -0
  67. package/CONTRIBUTING.md +0 -171
  68. package/MIGRATING.md +0 -224
  69. package/packages/dd-trace/src/external-logger/test/index.spec.js +0 -147
  70. package/scripts/check-proposal-labels.js +0 -71
  71. package/scripts/check_licenses.js +0 -69
  72. package/scripts/helpers/color.js +0 -8
  73. package/scripts/helpers/exec.js +0 -22
  74. package/scripts/helpers/title.js +0 -15
  75. package/scripts/install_plugin_modules.js +0 -248
  76. package/scripts/publish_docs.js +0 -21
  77. package/scripts/st.js +0 -105
  78. /package/packages/{utils → datadog-core/src/utils}/src/kebabcase.js +0 -0
  79. /package/packages/{utils → datadog-core/src/utils}/src/pick.js +0 -0
  80. /package/packages/{utils → datadog-core/src/utils}/src/uniq.js +0 -0
package/index.d.ts CHANGED
@@ -1,22 +1,29 @@
1
1
  import { ClientRequest, IncomingMessage, OutgoingMessage, ServerResponse } from "http";
2
2
  import { LookupFunction } from 'net';
3
3
  import * as opentracing from "opentracing";
4
- import { SpanOptions } from "opentracing/lib/tracer";
5
4
  import * as otel from "@opentelemetry/api";
6
5
 
7
- export { SpanOptions };
8
-
9
6
  /**
10
7
  * Tracer is the entry-point of the Datadog tracing implementation.
11
8
  */
12
- export declare interface Tracer extends opentracing.Tracer {
9
+ interface Tracer extends opentracing.Tracer {
10
+ /**
11
+ * Add tracer as a named export
12
+ */
13
+ tracer: Tracer;
14
+
15
+ /**
16
+ * For compatibility with NodeNext + esModuleInterop: false
17
+ */
18
+ default: Tracer;
19
+
13
20
  /**
14
21
  * Starts and returns a new Span representing a logical unit of work.
15
22
  * @param {string} name The name of the operation.
16
- * @param {SpanOptions} [options] Options for the newly created span.
23
+ * @param {tracer.SpanOptions} [options] Options for the newly created span.
17
24
  * @returns {Span} A new Span object.
18
25
  */
19
- startSpan (name: string, options?: SpanOptions): Span;
26
+ startSpan (name: string, options?: tracer.SpanOptions): tracer.Span;
20
27
 
21
28
  /**
22
29
  * Injects the given SpanContext instance for cross-process propagation
@@ -28,7 +35,7 @@ export declare interface Tracer extends opentracing.Tracer {
28
35
  * @param {string} format The format of the carrier.
29
36
  * @param {any} carrier The carrier object.
30
37
  */
31
- inject (spanContext: SpanContext | Span, format: string, carrier: any): void;
38
+ inject (spanContext: tracer.SpanContext | tracer.Span, format: string, carrier: any): void;
32
39
 
33
40
  /**
34
41
  * Returns a SpanContext instance extracted from `carrier` in the given
@@ -39,12 +46,12 @@ export declare interface Tracer extends opentracing.Tracer {
39
46
  * The extracted SpanContext, or null if no such SpanContext could
40
47
  * be found in `carrier`
41
48
  */
42
- extract (format: string, carrier: any): SpanContext | null;
49
+ extract (format: string, carrier: any): tracer.SpanContext | null;
43
50
 
44
51
  /**
45
52
  * Initializes the tracer. This should be called before importing other libraries.
46
53
  */
47
- init (options?: TracerOptions): this;
54
+ init (options?: tracer.TracerOptions): this;
48
55
 
49
56
  /**
50
57
  * Sets the URL for the trace agent. This should only be called _after_
@@ -63,7 +70,7 @@ export declare interface Tracer extends opentracing.Tracer {
63
70
  /**
64
71
  * Returns a reference to the current scope.
65
72
  */
66
- scope (): Scope;
73
+ scope (): tracer.Scope;
67
74
 
68
75
  /**
69
76
  * Instruments a function by automatically creating a span activated on its
@@ -83,9 +90,9 @@ export declare interface Tracer extends opentracing.Tracer {
83
90
  * unless there is already an active span or `childOf` option. Note that this
84
91
  * option is deprecated and has been removed in version 4.0.
85
92
  */
86
- trace<T> (name: string, fn: (span: Span) => T): T;
87
- trace<T> (name: string, fn: (span: Span, done: (error?: Error) => void) => T): T;
88
- trace<T> (name: string, options: TraceOptions & SpanOptions, fn: (span?: Span, done?: (error?: Error) => void) => T): T;
93
+ trace<T> (name: string, fn: (span: tracer.Span) => T): T;
94
+ trace<T> (name: string, fn: (span: tracer.Span, done: (error?: Error) => void) => T): T;
95
+ trace<T> (name: string, options: tracer.TraceOptions & tracer.SpanOptions, fn: (span?: tracer.Span, done?: (error?: Error) => void) => T): T;
89
96
 
90
97
  /**
91
98
  * Wrap a function to automatically create a span activated on its
@@ -102,8 +109,8 @@ export declare interface Tracer extends opentracing.Tracer {
102
109
  * which case the span will finish at the end of the function execution.
103
110
  */
104
111
  wrap<T = (...args: any[]) => any> (name: string, fn: T): T;
105
- wrap<T = (...args: any[]) => any> (name: string, options: TraceOptions & SpanOptions, fn: T): T;
106
- wrap<T = (...args: any[]) => any> (name: string, options: (...args: any[]) => TraceOptions & SpanOptions, fn: T): T;
112
+ wrap<T = (...args: any[]) => any> (name: string, options: tracer.TraceOptions & tracer.SpanOptions, fn: T): T;
113
+ wrap<T = (...args: any[]) => any> (name: string, options: (...args: any[]) => tracer.TraceOptions & tracer.SpanOptions, fn: T): T;
107
114
 
108
115
  /**
109
116
  * Create and return a string that can be included in the <head> of a
@@ -117,1879 +124,1886 @@ export declare interface Tracer extends opentracing.Tracer {
117
124
  * @param {User} user Properties of the authenticated user. Accepts custom fields.
118
125
  * @returns {Tracer} The Tracer instance for chaining.
119
126
  */
120
- setUser (user: User): Tracer;
127
+ setUser (user: tracer.User): Tracer;
121
128
 
122
- appsec: Appsec;
129
+ appsec: tracer.Appsec;
123
130
 
124
- TracerProvider: opentelemetry.TracerProvider;
131
+ TracerProvider: tracer.opentelemetry.TracerProvider;
125
132
 
126
- dogstatsd: DogStatsD;
133
+ dogstatsd: tracer.DogStatsD;
127
134
  }
128
135
 
129
- export declare interface TraceOptions extends Analyzable {
130
- /**
131
- * The resource you are tracing. The resource name must not be longer than
132
- * 5000 characters.
133
- */
134
- resource?: string,
135
-
136
- /**
137
- * The service you are tracing. The service name must not be longer than
138
- * 100 characters.
139
- */
140
- service?: string,
141
-
142
- /**
143
- * The type of request.
144
- */
145
- type?: string
146
-
147
- /**
148
- * An array of span links
149
- */
150
- links?: Array<{ context: SpanContext, attributes?: Object }>
136
+ // left out of the namespace, so it
137
+ // is doesn't need to be exported for Tracer
138
+ /** @hidden */
139
+ interface Plugins {
140
+ "amqp10": tracer.plugins.amqp10;
141
+ "amqplib": tracer.plugins.amqplib;
142
+ "aws-sdk": tracer.plugins.aws_sdk;
143
+ "bunyan": tracer.plugins.bunyan;
144
+ "cassandra-driver": tracer.plugins.cassandra_driver;
145
+ "connect": tracer.plugins.connect;
146
+ "couchbase": tracer.plugins.couchbase;
147
+ "cucumber": tracer.plugins.cucumber;
148
+ "cypress": tracer.plugins.cypress;
149
+ "dns": tracer.plugins.dns;
150
+ "elasticsearch": tracer.plugins.elasticsearch;
151
+ "express": tracer.plugins.express;
152
+ "fastify": tracer.plugins.fastify;
153
+ "fetch": tracer.plugins.fetch;
154
+ "generic-pool": tracer.plugins.generic_pool;
155
+ "google-cloud-pubsub": tracer.plugins.google_cloud_pubsub;
156
+ "graphql": tracer.plugins.graphql;
157
+ "grpc": tracer.plugins.grpc;
158
+ "hapi": tracer.plugins.hapi;
159
+ "http": tracer.plugins.http;
160
+ "http2": tracer.plugins.http2;
161
+ "ioredis": tracer.plugins.ioredis;
162
+ "jest": tracer.plugins.jest;
163
+ "kafkajs": tracer.plugins.kafkajs
164
+ "knex": tracer.plugins.knex;
165
+ "koa": tracer.plugins.koa;
166
+ "mariadb": tracer.plugins.mariadb;
167
+ "memcached": tracer.plugins.memcached;
168
+ "microgateway-core": tracer.plugins.microgateway_core;
169
+ "mocha": tracer.plugins.mocha;
170
+ "moleculer": tracer.plugins.moleculer;
171
+ "mongodb-core": tracer.plugins.mongodb_core;
172
+ "mongoose": tracer.plugins.mongoose;
173
+ "mysql": tracer.plugins.mysql;
174
+ "mysql2": tracer.plugins.mysql2;
175
+ "net": tracer.plugins.net;
176
+ "next": tracer.plugins.next;
177
+ "openai": tracer.plugins.openai;
178
+ "opensearch": tracer.plugins.opensearch;
179
+ "oracledb": tracer.plugins.oracledb;
180
+ "paperplane": tracer.plugins.paperplane;
181
+ "playwright": tracer.plugins.playwright;
182
+ "pg": tracer.plugins.pg;
183
+ "pino": tracer.plugins.pino;
184
+ "redis": tracer.plugins.redis;
185
+ "restify": tracer.plugins.restify;
186
+ "rhea": tracer.plugins.rhea;
187
+ "router": tracer.plugins.router;
188
+ "sharedb": tracer.plugins.sharedb;
189
+ "tedious": tracer.plugins.tedious;
190
+ "winston": tracer.plugins.winston;
151
191
  }
152
192
 
153
- /**
154
- * Span represents a logical unit of work as part of a broader Trace.
155
- * Examples of span might include remote procedure calls or a in-process
156
- * function calls to sub-components. A Trace has a single, top-level "root"
157
- * Span that in turn may have zero or more child Spans, which in turn may
158
- * have children.
159
- */
160
- export declare interface Span extends opentracing.Span {
161
- context (): SpanContext;
162
-
163
- /**
164
- * Causally links another span to the current span
165
- * @param {SpanContext} context The context of the span to link to.
166
- * @param {Object} attributes An optional key value pair of arbitrary values.
167
- * @returns {void}
168
- */
169
- addLink (context: SpanContext, attributes?: Object): void;
170
- }
193
+ declare namespace tracer {
194
+ export type SpanOptions = opentracing.SpanOptions;
195
+ export { Tracer };
171
196
 
172
- /**
173
- * SpanContext represents Span state that must propagate to descendant Spans
174
- * and across process boundaries.
175
- *
176
- * SpanContext is logically divided into two pieces: the user-level "Baggage"
177
- * (see setBaggageItem and getBaggageItem) that propagates across Span
178
- * boundaries and any Tracer-implementation-specific fields that are needed to
179
- * identify or otherwise contextualize the associated Span instance (e.g., a
180
- * <trace_id, span_id, sampled> tuple).
181
- */
182
- export declare interface SpanContext extends opentracing.SpanContext {
183
- /**
184
- * Returns the string representation of the internal trace ID.
185
- */
186
- toTraceId (): string;
197
+ export interface TraceOptions extends Analyzable {
198
+ /**
199
+ * The resource you are tracing. The resource name must not be longer than
200
+ * 5000 characters.
201
+ */
202
+ resource?: string,
187
203
 
188
- /**
189
- * Returns the string representation of the internal span ID.
190
- */
191
- toSpanId (): string;
204
+ /**
205
+ * The service you are tracing. The service name must not be longer than
206
+ * 100 characters.
207
+ */
208
+ service?: string,
192
209
 
193
- /**
194
- * Returns the string representation used for DBM integration.
195
- */
196
- toTraceparent (): string;
197
- }
210
+ /**
211
+ * The type of request.
212
+ */
213
+ type?: string
198
214
 
199
- /**
200
- * Sampling rule to configure on the priority sampler.
201
- */
202
- export declare interface SamplingRule {
203
- /**
204
- * Sampling rate for this rule.
205
- */
206
- sampleRate: number
215
+ /**
216
+ * An array of span links
217
+ */
218
+ links?: Array<{ context: SpanContext, attributes?: Object }>
219
+ }
207
220
 
208
221
  /**
209
- * Service on which to apply this rule. The rule will apply to all services if not provided.
222
+ * Span represents a logical unit of work as part of a broader Trace.
223
+ * Examples of span might include remote procedure calls or a in-process
224
+ * function calls to sub-components. A Trace has a single, top-level "root"
225
+ * Span that in turn may have zero or more child Spans, which in turn may
226
+ * have children.
210
227
  */
211
- service?: string | RegExp
228
+ export interface Span extends opentracing.Span {
229
+ context (): SpanContext;
212
230
 
213
- /**
214
- * Operation name on which to apply this rule. The rule will apply to all operation names if not provided.
215
- */
216
- name?: string | RegExp
217
- }
231
+ /**
232
+ * Causally links another span to the current span
233
+ * @param {SpanContext} context The context of the span to link to.
234
+ * @param {Object} attributes An optional key value pair of arbitrary values.
235
+ * @returns {void}
236
+ */
237
+ addLink (context: SpanContext, attributes?: Object): void;
238
+ }
218
239
 
219
- /**
220
- * Span sampling rules to ingest single spans where the enclosing trace is dropped
221
- */
222
- export declare interface SpanSamplingRule {
223
240
  /**
224
- * Sampling rate for this rule. Will default to 1.0 (always) if not provided.
241
+ * SpanContext represents Span state that must propagate to descendant Spans
242
+ * and across process boundaries.
243
+ *
244
+ * SpanContext is logically divided into two pieces: the user-level "Baggage"
245
+ * (see setBaggageItem and getBaggageItem) that propagates across Span
246
+ * boundaries and any Tracer-implementation-specific fields that are needed to
247
+ * identify or otherwise contextualize the associated Span instance (e.g., a
248
+ * <trace_id, span_id, sampled> tuple).
225
249
  */
226
- sampleRate?: number
250
+ export interface SpanContext extends opentracing.SpanContext {
251
+ /**
252
+ * Returns the string representation of the internal trace ID.
253
+ */
254
+ toTraceId (): string;
227
255
 
228
- /**
229
- * Maximum number of spans matching a span sampling rule to be allowed per second.
230
- */
231
- maxPerSecond?: number
256
+ /**
257
+ * Returns the string representation of the internal span ID.
258
+ */
259
+ toSpanId (): string;
232
260
 
233
- /**
234
- * Service name or pattern on which to apply this rule. The rule will apply to all services if not provided.
235
- */
236
- service?: string
261
+ /**
262
+ * Returns the string representation used for DBM integration.
263
+ */
264
+ toTraceparent (): string;
265
+ }
237
266
 
238
267
  /**
239
- * Operation name or pattern on which to apply this rule. The rule will apply to all operation names if not provided.
268
+ * Sampling rule to configure on the priority sampler.
240
269
  */
241
- name?: string
242
- }
270
+ export interface SamplingRule {
271
+ /**
272
+ * Sampling rate for this rule.
273
+ */
274
+ sampleRate: number
243
275
 
244
- /**
245
- * Selection and priority order of context propagation injection and extraction mechanisms.
246
- */
247
- export declare interface PropagationStyle {
248
- /**
249
- * Selection of context propagation injection mechanisms.
250
- */
251
- inject: string[],
276
+ /**
277
+ * Service on which to apply this rule. The rule will apply to all services if not provided.
278
+ */
279
+ service?: string | RegExp
252
280
 
253
- /**
254
- * Selection and priority order of context propagation extraction mechanisms.
255
- */
256
- extract: string[]
257
- }
281
+ /**
282
+ * Operation name on which to apply this rule. The rule will apply to all operation names if not provided.
283
+ */
284
+ name?: string | RegExp
285
+ }
258
286
 
259
- /**
260
- * List of options available to the tracer.
261
- */
262
- export declare interface TracerOptions {
263
287
  /**
264
- * Whether to enable trace ID injection in log records to be able to correlate
265
- * traces with logs.
266
- * @default false
288
+ * Span sampling rules to ingest single spans where the enclosing trace is dropped
267
289
  */
268
- logInjection?: boolean,
290
+ export interface SpanSamplingRule {
291
+ /**
292
+ * Sampling rate for this rule. Will default to 1.0 (always) if not provided.
293
+ */
294
+ sampleRate?: number
269
295
 
270
- /**
271
- * Whether to enable startup logs.
272
- * @default true
273
- */
274
- startupLogs?: boolean,
296
+ /**
297
+ * Maximum number of spans matching a span sampling rule to be allowed per second.
298
+ */
299
+ maxPerSecond?: number
275
300
 
276
- /**
277
- * The service name to be used for this program. If not set, the service name
278
- * will attempted to be inferred from package.json
279
- */
280
- service?: string;
301
+ /**
302
+ * Service name or pattern on which to apply this rule. The rule will apply to all services if not provided.
303
+ */
304
+ service?: string
281
305
 
282
- /**
283
- * Provide service name mappings for each plugin.
284
- */
285
- serviceMapping?: { [key: string]: string };
306
+ /**
307
+ * Operation name or pattern on which to apply this rule. The rule will apply to all operation names if not provided.
308
+ */
309
+ name?: string
310
+ }
286
311
 
287
312
  /**
288
- * The url of the trace agent that the tracer will submit to.
289
- * Takes priority over hostname and port, if set.
313
+ * Selection and priority order of context propagation injection and extraction mechanisms.
290
314
  */
291
- url?: string;
315
+ export interface PropagationStyle {
316
+ /**
317
+ * Selection of context propagation injection mechanisms.
318
+ */
319
+ inject: string[],
292
320
 
293
- /**
294
- * The address of the trace agent that the tracer will submit to.
295
- * @default 'localhost'
296
- */
297
- hostname?: string;
321
+ /**
322
+ * Selection and priority order of context propagation extraction mechanisms.
323
+ */
324
+ extract: string[]
325
+ }
298
326
 
299
327
  /**
300
- * The port of the trace agent that the tracer will submit to.
301
- * @default 8126
328
+ * List of options available to the tracer.
302
329
  */
303
- port?: number | string;
330
+ export interface TracerOptions {
331
+ /**
332
+ * Whether to enable trace ID injection in log records to be able to correlate
333
+ * traces with logs.
334
+ * @default false
335
+ */
336
+ logInjection?: boolean,
304
337
 
305
- /**
306
- * Whether to enable profiling.
307
- */
308
- profiling?: boolean
338
+ /**
339
+ * Whether to enable startup logs.
340
+ * @default true
341
+ */
342
+ startupLogs?: boolean,
309
343
 
310
- /**
311
- * Options specific for the Dogstatsd agent.
312
- */
313
- dogstatsd?: {
314
344
  /**
315
- * The hostname of the Dogstatsd agent that the metrics will submitted to.
345
+ * The service name to be used for this program. If not set, the service name
346
+ * will attempted to be inferred from package.json
316
347
  */
317
- hostname?: string
348
+ service?: string;
318
349
 
319
350
  /**
320
- * The port of the Dogstatsd agent that the metrics will submitted to.
321
- * @default 8125
351
+ * Provide service name mappings for each plugin.
322
352
  */
323
- port?: number
324
- };
353
+ serviceMapping?: { [key: string]: string };
325
354
 
326
- /**
327
- * Set an application’s environment e.g. prod, pre-prod, stage.
328
- */
329
- env?: string;
355
+ /**
356
+ * The url of the trace agent that the tracer will submit to.
357
+ * Takes priority over hostname and port, if set.
358
+ */
359
+ url?: string;
330
360
 
331
- /**
332
- * The version number of the application. If not set, the version
333
- * will attempted to be inferred from package.json.
334
- */
335
- version?: string;
361
+ /**
362
+ * The address of the trace agent that the tracer will submit to.
363
+ * @default 'localhost'
364
+ */
365
+ hostname?: string;
336
366
 
337
- /**
338
- * Controls the ingestion sample rate (between 0 and 1) between the agent and the backend.
339
- */
340
- sampleRate?: number;
367
+ /**
368
+ * The port of the trace agent that the tracer will submit to.
369
+ * @default 8126
370
+ */
371
+ port?: number | string;
341
372
 
342
- /**
343
- * Global rate limit that is applied on the global sample rate and all rules,
344
- * and controls the ingestion rate limit between the agent and the backend.
345
- * Defaults to deferring the decision to the agent.
346
- */
347
- rateLimit?: number,
373
+ /**
374
+ * Whether to enable profiling.
375
+ */
376
+ profiling?: boolean
348
377
 
349
- /**
350
- * Sampling rules to apply to priority samplin. Each rule is a JSON,
351
- * consisting of `service` and `name`, which are regexes to match against
352
- * a trace's `service` and `name`, and a corresponding `sampleRate`. If not
353
- * specified, will defer to global sampling rate for all spans.
354
- * @default []
355
- */
356
- samplingRules?: SamplingRule[]
378
+ /**
379
+ * Options specific for the Dogstatsd agent.
380
+ */
381
+ dogstatsd?: {
382
+ /**
383
+ * The hostname of the Dogstatsd agent that the metrics will submitted to.
384
+ */
385
+ hostname?: string
357
386
 
358
- /**
359
- * Span sampling rules that take effect when the enclosing trace is dropped, to ingest single spans
360
- * @default []
361
- */
362
- spanSamplingRules?: SpanSamplingRule[]
387
+ /**
388
+ * The port of the Dogstatsd agent that the metrics will submitted to.
389
+ * @default 8125
390
+ */
391
+ port?: number
392
+ };
363
393
 
364
- /**
365
- * Interval in milliseconds at which the tracer will submit traces to the agent.
366
- * @default 2000
367
- */
368
- flushInterval?: number;
394
+ /**
395
+ * Set an application’s environment e.g. prod, pre-prod, stage.
396
+ */
397
+ env?: string;
369
398
 
370
- /**
371
- * Number of spans before partially exporting a trace. This prevents keeping all the spans in memory for very large traces.
372
- * @default 1000
373
- */
374
- flushMinSpans?: number;
399
+ /**
400
+ * The version number of the application. If not set, the version
401
+ * will attempted to be inferred from package.json.
402
+ */
403
+ version?: string;
375
404
 
376
- /**
377
- * Whether to enable runtime metrics.
378
- * @default false
379
- */
380
- runtimeMetrics?: boolean
405
+ /**
406
+ * Controls the ingestion sample rate (between 0 and 1) between the agent and the backend.
407
+ */
408
+ sampleRate?: number;
381
409
 
382
- /**
383
- * Custom function for DNS lookups when sending requests to the agent.
384
- * @default dns.lookup()
385
- */
386
- lookup?: LookupFunction
410
+ /**
411
+ * Global rate limit that is applied on the global sample rate and all rules,
412
+ * and controls the ingestion rate limit between the agent and the backend.
413
+ * Defaults to deferring the decision to the agent.
414
+ */
415
+ rateLimit?: number,
387
416
 
388
- /**
389
- * Protocol version to use for requests to the agent. The version configured must be supported by the agent version installed or all traces will be dropped.
390
- * @default 0.4
391
- */
392
- protocolVersion?: string
417
+ /**
418
+ * Sampling rules to apply to priority samplin. Each rule is a JSON,
419
+ * consisting of `service` and `name`, which are regexes to match against
420
+ * a trace's `service` and `name`, and a corresponding `sampleRate`. If not
421
+ * specified, will defer to global sampling rate for all spans.
422
+ * @default []
423
+ */
424
+ samplingRules?: SamplingRule[]
393
425
 
394
- /**
395
- * Deprecated in favor of the global versions of the variables provided under this option
396
- *
397
- * @deprecated
398
- * @hidden
399
- */
400
- ingestion?: {
401
426
  /**
402
- * Controls the ingestion sample rate (between 0 and 1) between the agent and the backend.
427
+ * Span sampling rules that take effect when the enclosing trace is dropped, to ingest single spans
428
+ * @default []
403
429
  */
404
- sampleRate?: number
430
+ spanSamplingRules?: SpanSamplingRule[]
405
431
 
406
432
  /**
407
- * Controls the ingestion rate limit between the agent and the backend. Defaults to deferring the decision to the agent.
433
+ * Interval in milliseconds at which the tracer will submit traces to the agent.
434
+ * @default 2000
408
435
  */
409
- rateLimit?: number
410
- };
436
+ flushInterval?: number;
411
437
 
412
- /**
413
- * Experimental features can be enabled individually using key / value pairs.
414
- * @default {}
415
- */
416
- experimental?: {
417
- b3?: boolean
418
- traceparent?: boolean
438
+ /**
439
+ * Number of spans before partially exporting a trace. This prevents keeping all the spans in memory for very large traces.
440
+ * @default 1000
441
+ */
442
+ flushMinSpans?: number;
419
443
 
420
444
  /**
421
- * Whether to add an auto-generated `runtime-id` tag to metrics.
445
+ * Whether to enable runtime metrics.
422
446
  * @default false
423
447
  */
424
- runtimeId?: boolean
448
+ runtimeMetrics?: boolean
425
449
 
426
450
  /**
427
- * Whether to write traces to log output or agentless, rather than send to an agent
428
- * @default false
451
+ * Custom function for DNS lookups when sending requests to the agent.
452
+ * @default dns.lookup()
429
453
  */
430
- exporter?: 'log' | 'agent' | 'datadog'
454
+ lookup?: LookupFunction
431
455
 
432
456
  /**
433
- * Whether to enable the experimental `getRumData` method.
434
- * @default false
457
+ * Protocol version to use for requests to the agent. The version configured must be supported by the agent version installed or all traces will be dropped.
458
+ * @default 0.4
435
459
  */
436
- enableGetRumData?: boolean
460
+ protocolVersion?: string
437
461
 
438
462
  /**
439
- * Configuration of the IAST. Can be a boolean as an alias to `iast.enabled`.
463
+ * Deprecated in favor of the global versions of the variables provided under this option
464
+ *
465
+ * @deprecated
466
+ * @hidden
440
467
  */
441
- iast?: boolean | {
442
- /**
443
- * Whether to enable IAST.
444
- * @default false
445
- */
446
- enabled?: boolean,
447
- /**
448
- * Controls the percentage of requests that iast will analyze
449
- * @default 30
450
- */
451
- requestSampling?: number,
468
+ ingestion?: {
452
469
  /**
453
- * Controls how many request can be analyzing code vulnerabilities at the same time
454
- * @default 2
470
+ * Controls the ingestion sample rate (between 0 and 1) between the agent and the backend.
455
471
  */
456
- maxConcurrentRequests?: number,
472
+ sampleRate?: number
473
+
457
474
  /**
458
- * Controls how many code vulnerabilities can be detected in the same request
459
- * @default 2
475
+ * Controls the ingestion rate limit between the agent and the backend. Defaults to deferring the decision to the agent.
460
476
  */
461
- maxContextOperations?: number,
477
+ rateLimit?: number
478
+ };
479
+
480
+ /**
481
+ * Experimental features can be enabled individually using key / value pairs.
482
+ * @default {}
483
+ */
484
+ experimental?: {
485
+ b3?: boolean
486
+ traceparent?: boolean
487
+
462
488
  /**
463
- * Whether to enable vulnerability deduplication
489
+ * Whether to add an auto-generated `runtime-id` tag to metrics.
490
+ * @default false
464
491
  */
465
- deduplicationEnabled?: boolean
492
+ runtimeId?: boolean
493
+
466
494
  /**
467
- * Whether to enable vulnerability redaction
468
- * @default true
495
+ * Whether to write traces to log output or agentless, rather than send to an agent
496
+ * @default false
469
497
  */
470
- redactionEnabled?: boolean,
498
+ exporter?: 'log' | 'agent' | 'datadog'
499
+
471
500
  /**
472
- * Specifies a regex that will redact sensitive source names in vulnerability reports.
501
+ * Whether to enable the experimental `getRumData` method.
502
+ * @default false
473
503
  */
474
- redactionNamePattern?: string,
504
+ enableGetRumData?: boolean
505
+
475
506
  /**
476
- * Specifies a regex that will redact sensitive source values in vulnerability reports.
507
+ * Configuration of the IAST. Can be a boolean as an alias to `iast.enabled`.
477
508
  */
478
- redactionValuePattern?: string
479
- }
480
- };
481
-
482
- /**
483
- * Whether to load all built-in plugins.
484
- * @default true
485
- */
486
- plugins?: boolean;
487
-
488
- /**
489
- * Custom logger to be used by the tracer (if debug = true),
490
- * should support error(), warn(), info(), and debug() methods
491
- * see https://datadog.github.io/dd-trace-js/#custom-logging
492
- */
493
- logger?: {
494
- error: (err: Error | string) => void;
495
- warn: (message: string) => void;
496
- info: (message: string) => void;
497
- debug: (message: string) => void;
498
- };
499
-
500
- /**
501
- * Global tags that should be assigned to every span.
502
- */
503
- tags?: { [key: string]: any };
504
-
505
- /**
506
- * Specifies which scope implementation to use. The default is to use the best
507
- * implementation for the runtime. Only change this if you know what you are
508
- * doing.
509
- */
510
- scope?: 'async_hooks' | 'async_local_storage' | 'async_resource' | 'sync' | 'noop'
511
-
512
- /**
513
- * Whether to report the hostname of the service host. This is used when the agent is deployed on a different host and cannot determine the hostname automatically.
514
- * @default false
515
- */
516
- reportHostname?: boolean
517
-
518
- /**
519
- * A string representing the minimum tracer log level to use when debug logging is enabled
520
- * @default 'debug'
521
- */
522
- logLevel?: 'error' | 'debug'
523
-
524
- /**
525
- * If false, require a parent in order to trace.
526
- * @default true
527
- * @deprecated since version 4.0
528
- */
529
- orphanable?: boolean
530
-
531
- /**
532
- * Enables DBM to APM link using tag injection.
533
- * @default 'disabled'
534
- */
535
- dbmPropagationMode?: 'disabled' | 'service' | 'full'
536
-
537
- /**
538
- * Configuration of the AppSec protection. Can be a boolean as an alias to `appsec.enabled`.
539
- */
540
- appsec?: boolean | {
541
- /**
542
- * Whether to enable AppSec.
543
- * @default false
544
- */
545
- enabled?: boolean,
509
+ iast?: boolean | {
510
+ /**
511
+ * Whether to enable IAST.
512
+ * @default false
513
+ */
514
+ enabled?: boolean,
515
+ /**
516
+ * Controls the percentage of requests that iast will analyze
517
+ * @default 30
518
+ */
519
+ requestSampling?: number,
520
+ /**
521
+ * Controls how many request can be analyzing code vulnerabilities at the same time
522
+ * @default 2
523
+ */
524
+ maxConcurrentRequests?: number,
525
+ /**
526
+ * Controls how many code vulnerabilities can be detected in the same request
527
+ * @default 2
528
+ */
529
+ maxContextOperations?: number,
530
+ /**
531
+ * Whether to enable vulnerability deduplication
532
+ */
533
+ deduplicationEnabled?: boolean,
534
+ /**
535
+ * Whether to enable vulnerability redaction
536
+ * @default true
537
+ */
538
+ redactionEnabled?: boolean,
539
+ /**
540
+ * Specifies a regex that will redact sensitive source names in vulnerability reports.
541
+ */
542
+ redactionNamePattern?: string,
543
+ /**
544
+ * Specifies a regex that will redact sensitive source values in vulnerability reports.
545
+ */
546
+ redactionValuePattern?: string
547
+ }
548
+ };
546
549
 
547
550
  /**
548
- * Specifies a path to a custom rules file.
551
+ * Whether to load all built-in plugins.
552
+ * @default true
549
553
  */
550
- rules?: string,
554
+ plugins?: boolean;
551
555
 
552
556
  /**
553
- * Controls the maximum amount of traces sampled by AppSec attacks, per second.
554
- * @default 100
557
+ * Custom logger to be used by the tracer (if debug = true),
558
+ * should support error(), warn(), info(), and debug() methods
559
+ * see https://datadog.github.io/dd-trace-js/#custom-logging
555
560
  */
556
- rateLimit?: number,
561
+ logger?: {
562
+ error: (err: Error | string) => void;
563
+ warn: (message: string) => void;
564
+ info: (message: string) => void;
565
+ debug: (message: string) => void;
566
+ };
557
567
 
558
568
  /**
559
- * Controls the maximum amount of time in microseconds the WAF is allowed to run synchronously for.
560
- * @default 5000
569
+ * Global tags that should be assigned to every span.
561
570
  */
562
- wafTimeout?: number,
571
+ tags?: { [key: string]: any };
563
572
 
564
573
  /**
565
- * Specifies a regex that will redact sensitive data by its key in attack reports.
574
+ * Specifies which scope implementation to use. The default is to use the best
575
+ * implementation for the runtime. Only change this if you know what you are
576
+ * doing.
566
577
  */
567
- obfuscatorKeyRegex?: string,
578
+ scope?: 'async_hooks' | 'async_local_storage' | 'async_resource' | 'sync' | 'noop'
568
579
 
569
580
  /**
570
- * Specifies a regex that will redact sensitive data by its value in attack reports.
581
+ * Whether to report the hostname of the service host. This is used when the agent is deployed on a different host and cannot determine the hostname automatically.
582
+ * @default false
571
583
  */
572
- obfuscatorValueRegex?: string,
584
+ reportHostname?: boolean
573
585
 
574
586
  /**
575
- * Specifies a path to a custom blocking template html file.
587
+ * A string representing the minimum tracer log level to use when debug logging is enabled
588
+ * @default 'debug'
576
589
  */
577
- blockedTemplateHtml?: string,
590
+ logLevel?: 'error' | 'debug'
578
591
 
579
592
  /**
580
- * Specifies a path to a custom blocking template json file.
593
+ * If false, require a parent in order to trace.
594
+ * @default true
595
+ * @deprecated since version 4.0
581
596
  */
582
- blockedTemplateJson?: string,
597
+ orphanable?: boolean
583
598
 
584
599
  /**
585
- * Specifies a path to a custom blocking template json file for graphql requests
600
+ * Enables DBM to APM link using tag injection.
601
+ * @default 'disabled'
586
602
  */
587
- blockedTemplateGraphql?: string,
603
+ dbmPropagationMode?: 'disabled' | 'service' | 'full'
588
604
 
589
605
  /**
590
- * Controls the automated user event tracking configuration
606
+ * Configuration of the AppSec protection. Can be a boolean as an alias to `appsec.enabled`.
591
607
  */
592
- eventTracking?: {
608
+ appsec?: boolean | {
593
609
  /**
594
- * Controls the automated user event tracking mode. Possible values are disabled, safe and extended.
595
- * On safe mode, any detected Personally Identifiable Information (PII) about the user will be redacted from the event.
596
- * On extended mode, no redaction will take place.
597
- * @default 'safe'
598
- */
599
- mode?: 'safe' | 'extended' | 'disabled'
600
- },
601
-
602
- /**
603
- * Configuration for Api Security sampling
604
- */
605
- apiSecurity?: {
606
- /** Whether to enable Api Security.
610
+ * Whether to enable AppSec.
607
611
  * @default false
608
612
  */
609
613
  enabled?: boolean,
610
614
 
611
- /** Controls the request sampling rate (between 0 and 1) in which Api Security is triggered.
612
- * The value will be coerced back if it's outside of the 0-1 range.
613
- * @default 0.1
615
+ /**
616
+ * Specifies a path to a custom rules file.
614
617
  */
615
- requestSampling?: number
616
- }
617
- };
618
+ rules?: string,
618
619
 
619
- /**
620
- * Configuration of ASM Remote Configuration
621
- */
622
- remoteConfig?: {
623
- /**
624
- * Specifies the remote configuration polling interval in seconds
625
- * @default 5
626
- */
627
- pollInterval?: number,
628
- }
629
-
630
- /**
631
- * Whether to enable client IP collection from relevant IP headers
632
- * @default false
633
- */
634
- clientIpEnabled?: boolean
635
-
636
- /**
637
- * Custom header name to source the http.client_ip tag from.
638
- */
639
- clientIpHeader?: string,
640
-
641
- /**
642
- * The selection and priority order of context propagation injection and extraction mechanisms.
643
- */
644
- propagationStyle?: string[] | PropagationStyle
645
- }
646
-
647
- /**
648
- * User object that can be passed to `tracer.setUser()`.
649
- */
650
- export declare interface User {
651
- /**
652
- * Unique identifier of the user.
653
- * Mandatory.
654
- */
655
- id: string,
656
-
657
- /**
658
- * Email of the user.
659
- */
660
- email?: string,
661
-
662
- /**
663
- * User-friendly name of the user.
664
- */
665
- name?: string,
666
-
667
- /**
668
- * Session ID of the user.
669
- */
670
- session_id?: string,
671
-
672
- /**
673
- * Role the user is making the request under.
674
- */
675
- role?: string,
676
-
677
- /**
678
- * Scopes or granted authorizations the user currently possesses.
679
- * The value could come from the scope associated with an OAuth2
680
- * Access Token or an attribute value in a SAML 2 Assertion.
681
- */
682
- scope?: string,
683
-
684
- /**
685
- * Custom fields to attach to the user (RBAC, Oauth, etc…).
686
- */
687
- [key: string]: string | undefined
688
- }
689
-
690
- export declare interface DogStatsD {
691
- /**
692
- * Increments a metric by the specified value, optionally specifying tags.
693
- * @param {string} stat The dot-separated metric name.
694
- * @param {number} value The amount to increment the stat by.
695
- * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
696
- */
697
- increment(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
698
-
699
- /**
700
- * Decrements a metric by the specified value, optionally specifying tags.
701
- * @param {string} stat The dot-separated metric name.
702
- * @param {number} value The amount to decrement the stat by.
703
- * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
704
- */
705
- decrement(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
706
-
707
- /**
708
- * Sets a distribution value, optionally specifying tags.
709
- * @param {string} stat The dot-separated metric name.
710
- * @param {number} value The amount to increment the stat by.
711
- * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
712
- */
713
- distribution(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
714
-
715
- /**
716
- * Sets a gauge value, optionally specifying tags.
717
- * @param {string} stat The dot-separated metric name.
718
- * @param {number} value The amount to increment the stat by.
719
- * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
720
- */
721
- gauge(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
722
-
723
- /**
724
- * Forces any unsent metrics to be sent
725
- *
726
- * @beta This method is experimental and could be removed in future versions.
727
- */
728
- flush(): void
729
- }
730
-
731
- export declare interface Appsec {
732
- /**
733
- * Links a successful login event to the current trace. Will link the passed user to the current trace with Appsec.setUser() internally.
734
- * @param {User} user Properties of the authenticated user. Accepts custom fields.
735
- * @param {[key: string]: string} metadata Custom fields to link to the login success event.
736
- *
737
- * @beta This method is in beta and could change in future versions.
738
- */
739
- trackUserLoginSuccessEvent(user: User, metadata?: { [key: string]: string }): void
620
+ /**
621
+ * Controls the maximum amount of traces sampled by AppSec attacks, per second.
622
+ * @default 100
623
+ */
624
+ rateLimit?: number,
740
625
 
741
- /**
742
- * Links a failed login event to the current trace.
743
- * @param {string} userId The user id of the attemped login.
744
- * @param {boolean} exists If the user id exists.
745
- * @param {[key: string]: string} metadata Custom fields to link to the login failure event.
746
- *
747
- * @beta This method is in beta and could change in future versions.
748
- */
749
- trackUserLoginFailureEvent(userId: string, exists: boolean, metadata?: { [key: string]: string }): void
626
+ /**
627
+ * Controls the maximum amount of time in microseconds the WAF is allowed to run synchronously for.
628
+ * @default 5000
629
+ */
630
+ wafTimeout?: number,
750
631
 
751
- /**
752
- * Links a custom event to the current trace.
753
- * @param {string} eventName The name of the event.
754
- * @param {[key: string]: string} metadata Custom fields to link to the event.
755
- *
756
- * @beta This method is in beta and could change in future versions.
757
- */
758
- trackCustomEvent(eventName: string, metadata?: { [key: string]: string }): void
632
+ /**
633
+ * Specifies a regex that will redact sensitive data by its key in attack reports.
634
+ */
635
+ obfuscatorKeyRegex?: string,
759
636
 
760
- /**
761
- * Checks if the passed user should be blocked according to AppSec rules.
762
- * If no user is linked to the current trace, will link the passed user to it.
763
- * @param {User} user Properties of the authenticated user. Accepts custom fields.
764
- * @return {boolean} Indicates whether the user should be blocked.
765
- *
766
- * @beta This method is in beta and could change in the future
767
- */
768
- isUserBlocked(user: User): boolean
637
+ /**
638
+ * Specifies a regex that will redact sensitive data by its value in attack reports.
639
+ */
640
+ obfuscatorValueRegex?: string,
769
641
 
770
- /**
771
- * Sends a "blocked" template response based on the request accept header and ends the response.
772
- * **You should stop processing the request after calling this function!**
773
- * @param {IncomingMessage} req Can be passed to force which request to act on. Optional.
774
- * @param {OutgoingMessage} res Can be passed to force which response to act on. Optional.
775
- * @return {boolean} Indicates if the action was successful.
776
- *
777
- * @beta This method is in beta and could change in the future
778
- */
779
- blockRequest(req?: IncomingMessage, res?: OutgoingMessage): boolean
642
+ /**
643
+ * Specifies a path to a custom blocking template html file.
644
+ */
645
+ blockedTemplateHtml?: string,
780
646
 
781
- /**
782
- * Links an authenticated user to the current trace.
783
- * @param {User} user Properties of the authenticated user. Accepts custom fields.
784
- *
785
- * @beta This method is in beta and could change in the future
786
- */
787
- setUser(user: User): void
788
- }
647
+ /**
648
+ * Specifies a path to a custom blocking template json file.
649
+ */
650
+ blockedTemplateJson?: string,
789
651
 
790
- /** @hidden */
791
- declare type anyObject = {
792
- [key: string]: any;
793
- };
652
+ /**
653
+ * Specifies a path to a custom blocking template json file for graphql requests
654
+ */
655
+ blockedTemplateGraphql?: string,
794
656
 
795
- /** @hidden */
796
- interface TransportRequestParams {
797
- method: string;
798
- path: string;
799
- body?: anyObject;
800
- bulkBody?: anyObject;
801
- querystring?: anyObject;
802
- }
657
+ /**
658
+ * Controls the automated user event tracking configuration
659
+ */
660
+ eventTracking?: {
661
+ /**
662
+ * Controls the automated user event tracking mode. Possible values are disabled, safe and extended.
663
+ * On safe mode, any detected Personally Identifiable Information (PII) about the user will be redacted from the event.
664
+ * On extended mode, no redaction will take place.
665
+ * @default 'safe'
666
+ */
667
+ mode?: 'safe' | 'extended' | 'disabled'
668
+ },
669
+ /**
670
+ * Configuration for Api Security sampling
671
+ */
672
+ apiSecurity?: {
673
+ /** Whether to enable Api Security.
674
+ * @default false
675
+ */
676
+ enabled?: boolean,
677
+
678
+ /** Controls the request sampling rate (between 0 and 1) in which Api Security is triggered.
679
+ * The value will be coerced back if it's outside of the 0-1 range.
680
+ * @default 0.1
681
+ */
682
+ requestSampling?: number
683
+ }
684
+ };
803
685
 
804
- /**
805
- * The Datadog Scope Manager. This is used for context propagation.
806
- */
807
- export declare interface Scope {
808
- /**
809
- * Get the current active span or null if there is none.
810
- *
811
- * @returns {Span} The active span.
812
- */
813
- active (): Span | null;
686
+ /**
687
+ * Configuration of ASM Remote Configuration
688
+ */
689
+ remoteConfig?: {
690
+ /**
691
+ * Specifies the remote configuration polling interval in seconds
692
+ * @default 5
693
+ */
694
+ pollInterval?: number,
695
+ }
814
696
 
815
- /**
816
- * Activate a span in the scope of a function.
817
- *
818
- * @param {Span} span The span to activate.
819
- * @param {Function} fn Function that will have the span activated on its scope.
820
- * @returns The return value of the provided function.
821
- */
822
- activate<T> (span: Span, fn: ((...args: any[]) => T)): T;
697
+ /**
698
+ * Whether to enable client IP collection from relevant IP headers
699
+ * @default false
700
+ */
701
+ clientIpEnabled?: boolean
823
702
 
824
- /**
825
- * Binds a target to the provided span, or the active span if omitted.
826
- *
827
- * @param {Function|Promise} target Target that will have the span activated on its scope.
828
- * @param {Span} [span=scope.active()] The span to activate.
829
- * @returns The bound target.
830
- */
831
- bind<T extends (...args: any[]) => void> (fn: T, span?: Span | null): T;
832
- bind<V, T extends (...args: any[]) => V> (fn: T, span?: Span | null): T;
833
- bind<T> (fn: Promise<T>, span?: Span | null): Promise<T>;
834
- }
703
+ /**
704
+ * Custom header name to source the http.client_ip tag from.
705
+ */
706
+ clientIpHeader?: string,
835
707
 
836
- /** @hidden */
837
- interface Plugins {
838
- "amqp10": plugins.amqp10;
839
- "amqplib": plugins.amqplib;
840
- "aws-sdk": plugins.aws_sdk;
841
- "bunyan": plugins.bunyan;
842
- "cassandra-driver": plugins.cassandra_driver;
843
- "connect": plugins.connect;
844
- "couchbase": plugins.couchbase;
845
- "cucumber": plugins.cucumber;
846
- "cypress": plugins.cypress;
847
- "dns": plugins.dns;
848
- "elasticsearch": plugins.elasticsearch;
849
- "express": plugins.express;
850
- "fastify": plugins.fastify;
851
- "fetch": plugins.fetch;
852
- "generic-pool": plugins.generic_pool;
853
- "google-cloud-pubsub": plugins.google_cloud_pubsub;
854
- "graphql": plugins.graphql;
855
- "grpc": plugins.grpc;
856
- "hapi": plugins.hapi;
857
- "http": plugins.http;
858
- "http2": plugins.http2;
859
- "ioredis": plugins.ioredis;
860
- "jest": plugins.jest;
861
- "kafkajs": plugins.kafkajs
862
- "knex": plugins.knex;
863
- "koa": plugins.koa;
864
- "mariadb": plugins.mariadb;
865
- "memcached": plugins.memcached;
866
- "microgateway-core": plugins.microgateway_core;
867
- "mocha": plugins.mocha;
868
- "moleculer": plugins.moleculer;
869
- "mongodb-core": plugins.mongodb_core;
870
- "mongoose": plugins.mongoose;
871
- "mysql": plugins.mysql;
872
- "mysql2": plugins.mysql2;
873
- "net": plugins.net;
874
- "next": plugins.next;
875
- "openai": plugins.openai;
876
- "opensearch": plugins.opensearch;
877
- "oracledb": plugins.oracledb;
878
- "paperplane": plugins.paperplane;
879
- "playwright": plugins.playwright;
880
- "pg": plugins.pg;
881
- "pino": plugins.pino;
882
- "redis": plugins.redis;
883
- "restify": plugins.restify;
884
- "rhea": plugins.rhea;
885
- "router": plugins.router;
886
- "sharedb": plugins.sharedb;
887
- "tedious": plugins.tedious;
888
- "winston": plugins.winston;
889
- }
708
+ /**
709
+ * The selection and priority order of context propagation injection and extraction mechanisms.
710
+ */
711
+ propagationStyle?: string[] | PropagationStyle
712
+ }
890
713
 
891
- /** @hidden */
892
- interface Analyzable {
893
714
  /**
894
- * Whether to measure the span. Can also be set to a key-value pair with span
895
- * names as keys and booleans as values for more granular control.
715
+ * User object that can be passed to `tracer.setUser()`.
896
716
  */
897
- measured?: boolean | { [key: string]: boolean };
898
- }
899
-
900
- export declare namespace plugins {
901
- /** @hidden */
902
- interface Integration {
717
+ export interface User {
903
718
  /**
904
- * The service name to be used for this plugin.
719
+ * Unique identifier of the user.
720
+ * Mandatory.
905
721
  */
906
- service?: string | any;
722
+ id: string,
907
723
 
908
- /** Whether to enable the plugin.
909
- * @default true
724
+ /**
725
+ * Email of the user.
910
726
  */
911
- enabled?: boolean;
912
- }
727
+ email?: string,
913
728
 
914
- /** @hidden */
915
- interface Instrumentation extends Integration, Analyzable {}
916
-
917
- /** @hidden */
918
- interface Http extends Instrumentation {
919
729
  /**
920
- * List of URLs that should be instrumented.
921
- *
922
- * @default /^.*$/
730
+ * User-friendly name of the user.
923
731
  */
924
- allowlist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
732
+ name?: string,
925
733
 
926
734
  /**
927
- * Deprecated in favor of `allowlist`.
928
- *
929
- * @deprecated
930
- * @hidden
735
+ * Session ID of the user.
931
736
  */
932
- whitelist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
737
+ session_id?: string,
933
738
 
934
739
  /**
935
- * List of URLs that should not be instrumented. Takes precedence over
936
- * allowlist if a URL matches an entry in both.
937
- *
938
- * @default []
740
+ * Role the user is making the request under.
939
741
  */
940
- blocklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
742
+ role?: string,
941
743
 
942
744
  /**
943
- * Deprecated in favor of `blocklist`.
944
- *
945
- * @deprecated
946
- * @hidden
745
+ * Scopes or granted authorizations the user currently possesses.
746
+ * The value could come from the scope associated with an OAuth2
747
+ * Access Token or an attribute value in a SAML 2 Assertion.
947
748
  */
948
- blacklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
749
+ scope?: string,
949
750
 
950
751
  /**
951
- * An array of headers to include in the span metadata.
952
- *
953
- * @default []
752
+ * Custom fields to attach to the user (RBAC, Oauth, etc…).
954
753
  */
955
- headers?: string[];
754
+ [key: string]: string | undefined
755
+ }
956
756
 
757
+ export interface DogStatsD {
957
758
  /**
958
- * Callback function to determine if there was an error. It should take a
959
- * status code as its only parameter and return `true` for success or `false`
960
- * for errors.
961
- *
962
- * @default code => code < 500
759
+ * Increments a metric by the specified value, optionally specifying tags.
760
+ * @param {string} stat The dot-separated metric name.
761
+ * @param {number} value The amount to increment the stat by.
762
+ * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
963
763
  */
964
- validateStatus?: (code: number) => boolean;
764
+ increment(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
965
765
 
966
766
  /**
967
- * Enable injection of tracing headers into requests signed with AWS IAM headers.
968
- * Disable this if you get AWS signature errors (HTTP 403).
969
- *
970
- * @default false
767
+ * Decrements a metric by the specified value, optionally specifying tags.
768
+ * @param {string} stat The dot-separated metric name.
769
+ * @param {number} value The amount to decrement the stat by.
770
+ * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
971
771
  */
972
- enablePropagationWithAmazonHeaders?: boolean;
973
- }
772
+ decrement(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
974
773
 
975
- /** @hidden */
976
- interface HttpServer extends Http {
977
774
  /**
978
- * Callback function to determine if there was an error. It should take a
979
- * status code as its only parameter and return `true` for success or `false`
980
- * for errors.
981
- *
982
- * @default code => code < 500
775
+ * Sets a distribution value, optionally specifying tags.
776
+ * @param {string} stat The dot-separated metric name.
777
+ * @param {number} value The amount to increment the stat by.
778
+ * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
983
779
  */
984
- validateStatus?: (code: number) => boolean;
780
+ distribution(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
985
781
 
986
782
  /**
987
- * Hooks to run before spans are finished.
783
+ * Sets a gauge value, optionally specifying tags.
784
+ * @param {string} stat The dot-separated metric name.
785
+ * @param {number} value The amount to increment the stat by.
786
+ * @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
988
787
  */
989
- hooks?: {
990
- /**
991
- * Hook to execute just before the request span finishes.
992
- */
993
- request?: (span?: Span, req?: IncomingMessage, res?: ServerResponse) => any;
994
- };
788
+ gauge(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
995
789
 
996
790
  /**
997
- * Whether to enable instrumentation of <plugin>.middleware spans
791
+ * Forces any unsent metrics to be sent
998
792
  *
999
- * @default true
793
+ * @beta This method is experimental and could be removed in future versions.
1000
794
  */
1001
- middleware?: boolean;
795
+ flush(): void
1002
796
  }
1003
797
 
1004
- /** @hidden */
1005
- interface HttpClient extends Http {
798
+ export interface Appsec {
1006
799
  /**
1007
- * Use the remote endpoint host as the service name instead of the default.
800
+ * Links a successful login event to the current trace. Will link the passed user to the current trace with Appsec.setUser() internally.
801
+ * @param {User} user Properties of the authenticated user. Accepts custom fields.
802
+ * @param {[key: string]: string} metadata Custom fields to link to the login success event.
1008
803
  *
1009
- * @default false
804
+ * @beta This method is in beta and could change in future versions.
1010
805
  */
1011
- splitByDomain?: boolean;
806
+ trackUserLoginSuccessEvent(user: User, metadata?: { [key: string]: string }): void
1012
807
 
1013
808
  /**
1014
- * Callback function to determine if there was an error. It should take a
1015
- * status code as its only parameter and return `true` for success or `false`
1016
- * for errors.
809
+ * Links a failed login event to the current trace.
810
+ * @param {string} userId The user id of the attemped login.
811
+ * @param {boolean} exists If the user id exists.
812
+ * @param {[key: string]: string} metadata Custom fields to link to the login failure event.
1017
813
  *
1018
- * @default code => code < 400 || code >= 500
814
+ * @beta This method is in beta and could change in future versions.
1019
815
  */
1020
- validateStatus?: (code: number) => boolean;
816
+ trackUserLoginFailureEvent(userId: string, exists: boolean, metadata?: { [key: string]: string }): void
1021
817
 
1022
818
  /**
1023
- * Hooks to run before spans are finished.
819
+ * Links a custom event to the current trace.
820
+ * @param {string} eventName The name of the event.
821
+ * @param {[key: string]: string} metadata Custom fields to link to the event.
822
+ *
823
+ * @beta This method is in beta and could change in future versions.
1024
824
  */
1025
- hooks?: {
1026
- /**
1027
- * Hook to execute just before the request span finishes.
1028
- */
1029
- request?: (span?: Span, req?: ClientRequest, res?: IncomingMessage) => any;
1030
- };
825
+ trackCustomEvent(eventName: string, metadata?: { [key: string]: string }): void
1031
826
 
1032
827
  /**
1033
- * List of urls to which propagation headers should not be injected
828
+ * Checks if the passed user should be blocked according to AppSec rules.
829
+ * If no user is linked to the current trace, will link the passed user to it.
830
+ * @param {User} user Properties of the authenticated user. Accepts custom fields.
831
+ * @return {boolean} Indicates whether the user should be blocked.
832
+ *
833
+ * @beta This method is in beta and could change in the future
1034
834
  */
1035
- propagationBlocklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
1036
- }
835
+ isUserBlocked(user: User): boolean
1037
836
 
1038
- /** @hidden */
1039
- interface Http2Client extends Http {
1040
837
  /**
1041
- * Use the remote endpoint host as the service name instead of the default.
838
+ * Sends a "blocked" template response based on the request accept header and ends the response.
839
+ * **You should stop processing the request after calling this function!**
840
+ * @param {IncomingMessage} req Can be passed to force which request to act on. Optional.
841
+ * @param {OutgoingMessage} res Can be passed to force which response to act on. Optional.
842
+ * @return {boolean} Indicates if the action was successful.
1042
843
  *
1043
- * @default false
844
+ * @beta This method is in beta and could change in the future
1044
845
  */
1045
- splitByDomain?: boolean;
846
+ blockRequest(req?: IncomingMessage, res?: OutgoingMessage): boolean
1046
847
 
1047
848
  /**
1048
- * Callback function to determine if there was an error. It should take a
1049
- * status code as its only parameter and return `true` for success or `false`
1050
- * for errors.
849
+ * Links an authenticated user to the current trace.
850
+ * @param {User} user Properties of the authenticated user. Accepts custom fields.
1051
851
  *
1052
- * @default code => code < 400 || code >= 500
852
+ * @beta This method is in beta and could change in the future
1053
853
  */
1054
- validateStatus?: (code: number) => boolean;
854
+ setUser(user: User): void
1055
855
  }
1056
856
 
1057
857
  /** @hidden */
1058
- interface Http2Server extends Http {
858
+ type anyObject = {
859
+ [key: string]: any;
860
+ };
861
+
862
+ /** @hidden */
863
+ interface TransportRequestParams {
864
+ method: string;
865
+ path: string;
866
+ body?: anyObject;
867
+ bulkBody?: anyObject;
868
+ querystring?: anyObject;
869
+ }
870
+
871
+ /**
872
+ * The Datadog Scope Manager. This is used for context propagation.
873
+ */
874
+ export interface Scope {
1059
875
  /**
1060
- * Callback function to determine if there was an error. It should take a
1061
- * status code as its only parameter and return `true` for success or `false`
1062
- * for errors.
876
+ * Get the current active span or null if there is none.
1063
877
  *
1064
- * @default code => code < 500
878
+ * @returns {Span} The active span.
1065
879
  */
1066
- validateStatus?: (code: number) => boolean;
1067
- }
880
+ active (): Span | null;
1068
881
 
1069
- /** @hidden */
1070
- interface Grpc extends Instrumentation {
1071
882
  /**
1072
- * An array of metadata entries to record. Can also be a callback that returns
1073
- * the key/value pairs to record. For example, using
1074
- * `variables => variables` would record all variables.
883
+ * Activate a span in the scope of a function.
884
+ *
885
+ * @param {Span} span The span to activate.
886
+ * @param {Function} fn Function that will have the span activated on its scope.
887
+ * @returns The return value of the provided function.
1075
888
  */
1076
- metadata?: string[] | ((variables: { [key: string]: any }) => { [key: string]: any });
889
+ activate<T> (span: Span, fn: ((...args: any[]) => T)): T;
890
+
891
+ /**
892
+ * Binds a target to the provided span, or the active span if omitted.
893
+ *
894
+ * @param {Function|Promise} fn Target that will have the span activated on its scope.
895
+ * @param {Span} [span=scope.active()] The span to activate.
896
+ * @returns The bound target.
897
+ */
898
+ bind<T extends (...args: any[]) => void> (fn: T, span?: Span | null): T;
899
+ bind<V, T extends (...args: any[]) => V> (fn: T, span?: Span | null): T;
900
+ bind<T> (fn: Promise<T>, span?: Span | null): Promise<T>;
1077
901
  }
1078
902
 
1079
903
  /** @hidden */
1080
- interface Moleculer extends Instrumentation {
904
+ interface Analyzable {
1081
905
  /**
1082
- * Whether to include context meta as tags.
1083
- *
1084
- * @default false
906
+ * Whether to measure the span. Can also be set to a key-value pair with span
907
+ * names as keys and booleans as values for more granular control.
1085
908
  */
1086
- meta?: boolean;
909
+ measured?: boolean | { [key: string]: boolean };
1087
910
  }
1088
911
 
1089
- /**
1090
- * This plugin automatically instruments the
1091
- * [amqp10](https://github.com/noodlefrenzy/node-amqp10) module.
1092
- */
1093
- interface amqp10 extends Instrumentation {}
912
+ export namespace plugins {
913
+ /** @hidden */
914
+ interface Integration {
915
+ /**
916
+ * The service name to be used for this plugin.
917
+ */
918
+ service?: string | any;
1094
919
 
1095
- /**
1096
- * This plugin automatically instruments the
1097
- * [amqplib](https://github.com/squaremo/amqp.node) module.
1098
- */
1099
- interface amqplib extends Instrumentation {}
920
+ /** Whether to enable the plugin.
921
+ * @default true
922
+ */
923
+ enabled?: boolean;
924
+ }
1100
925
 
1101
- /**
1102
- * This plugin automatically instruments the
1103
- * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
1104
- */
1105
- interface aws_sdk extends Instrumentation {
1106
- /**
1107
- * Whether to add a suffix to the service name so that each AWS service has its own service name.
1108
- * @default true
1109
- */
1110
- splitByAwsService?: boolean;
926
+ /** @hidden */
927
+ interface Instrumentation extends Integration, Analyzable {}
1111
928
 
1112
- /**
1113
- * Hooks to run before spans are finished.
1114
- */
1115
- hooks?: {
929
+ /** @hidden */
930
+ interface Http extends Instrumentation {
1116
931
  /**
1117
- * Hook to execute just before the aws span finishes.
932
+ * List of URLs that should be instrumented.
933
+ *
934
+ * @default /^.*$/
1118
935
  */
1119
- request?: (span?: Span, response?: anyObject) => any;
1120
- };
936
+ allowlist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
1121
937
 
1122
- /**
1123
- * Configuration for individual services to enable/disable them. Message
1124
- * queue services can also configure the producer and consumer individually
1125
- * by passing an object with a `producer` and `consumer` properties. The
1126
- * list of valid service keys is in the service-specific section of
1127
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html
1128
- */
1129
- [key: string]: boolean | Object | undefined;
1130
- }
938
+ /**
939
+ * Deprecated in favor of `allowlist`.
940
+ *
941
+ * @deprecated
942
+ * @hidden
943
+ */
944
+ whitelist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
1131
945
 
1132
- /**
1133
- * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
1134
- * to automatically inject trace identifiers in log records when the
1135
- * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
1136
- * on the tracer.
1137
- */
1138
- interface bunyan extends Integration {}
946
+ /**
947
+ * List of URLs that should not be instrumented. Takes precedence over
948
+ * allowlist if a URL matches an entry in both.
949
+ *
950
+ * @default []
951
+ */
952
+ blocklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
1139
953
 
1140
- /**
1141
- * This plugin automatically instruments the
1142
- * [cassandra-driver](https://github.com/datastax/nodejs-driver) module.
1143
- */
1144
- interface cassandra_driver extends Instrumentation {}
954
+ /**
955
+ * Deprecated in favor of `blocklist`.
956
+ *
957
+ * @deprecated
958
+ * @hidden
959
+ */
960
+ blacklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
1145
961
 
1146
- /**
1147
- * This plugin automatically instruments the
1148
- * [connect](https://github.com/senchalabs/connect) module.
1149
- */
1150
- interface connect extends HttpServer {}
962
+ /**
963
+ * An array of headers to include in the span metadata.
964
+ *
965
+ * @default []
966
+ */
967
+ headers?: string[];
1151
968
 
1152
- /**
1153
- * This plugin automatically instruments the
1154
- * [couchbase](https://www.npmjs.com/package/couchbase) module.
1155
- */
1156
- interface couchbase extends Instrumentation {}
969
+ /**
970
+ * Callback function to determine if there was an error. It should take a
971
+ * status code as its only parameter and return `true` for success or `false`
972
+ * for errors.
973
+ *
974
+ * @default code => code < 500
975
+ */
976
+ validateStatus?: (code: number) => boolean;
1157
977
 
1158
- /**
1159
- * This plugin automatically instruments the
1160
- * [cucumber](https://www.npmjs.com/package/@cucumber/cucumber) module.
1161
- */
1162
- interface cucumber extends Integration {}
978
+ /**
979
+ * Enable injection of tracing headers into requests signed with AWS IAM headers.
980
+ * Disable this if you get AWS signature errors (HTTP 403).
981
+ *
982
+ * @default false
983
+ */
984
+ enablePropagationWithAmazonHeaders?: boolean;
985
+ }
1163
986
 
1164
- /**
1165
- * This plugin automatically instruments the
1166
- * [cypress](https://github.com/cypress-io/cypress) module.
1167
- */
1168
- interface cypress extends Integration {}
987
+ /** @hidden */
988
+ interface HttpServer extends Http {
989
+ /**
990
+ * Callback function to determine if there was an error. It should take a
991
+ * status code as its only parameter and return `true` for success or `false`
992
+ * for errors.
993
+ *
994
+ * @default code => code < 500
995
+ */
996
+ validateStatus?: (code: number) => boolean;
1169
997
 
1170
- /**
1171
- * This plugin automatically instruments the
1172
- * [dns](https://nodejs.org/api/dns.html) module.
1173
- */
1174
- interface dns extends Instrumentation {}
998
+ /**
999
+ * Hooks to run before spans are finished.
1000
+ */
1001
+ hooks?: {
1002
+ /**
1003
+ * Hook to execute just before the request span finishes.
1004
+ */
1005
+ request?: (span?: Span, req?: IncomingMessage, res?: ServerResponse) => any;
1006
+ };
1175
1007
 
1176
- /**
1177
- * This plugin automatically instruments the
1178
- * [elasticsearch](https://github.com/elastic/elasticsearch-js) module.
1179
- */
1180
- interface elasticsearch extends Instrumentation {
1181
- /**
1182
- * Hooks to run before spans are finished.
1183
- */
1184
- hooks?: {
1185
1008
  /**
1186
- * Hook to execute just before the query span finishes.
1009
+ * Whether to enable instrumentation of <plugin>.middleware spans
1010
+ *
1011
+ * @default true
1187
1012
  */
1188
- query?: (span?: Span, params?: TransportRequestParams) => any;
1189
- };
1190
- }
1013
+ middleware?: boolean;
1014
+ }
1191
1015
 
1192
- /**
1193
- * This plugin automatically instruments the
1194
- * [express](http://expressjs.com/) module.
1195
- */
1196
- interface express extends HttpServer {}
1016
+ /** @hidden */
1017
+ interface HttpClient extends Http {
1018
+ /**
1019
+ * Use the remote endpoint host as the service name instead of the default.
1020
+ *
1021
+ * @default false
1022
+ */
1023
+ splitByDomain?: boolean;
1197
1024
 
1198
- /**
1199
- * This plugin automatically instruments the
1200
- * [fastify](https://www.fastify.io/) module.
1201
- */
1202
- interface fastify extends HttpServer {}
1025
+ /**
1026
+ * Callback function to determine if there was an error. It should take a
1027
+ * status code as its only parameter and return `true` for success or `false`
1028
+ * for errors.
1029
+ *
1030
+ * @default code => code < 400 || code >= 500
1031
+ */
1032
+ validateStatus?: (code: number) => boolean;
1203
1033
 
1204
- /**
1205
- * This plugin automatically instruments the
1206
- * [fetch](https://nodejs.org/api/globals.html#fetch) global.
1207
- */
1208
- interface fetch extends HttpClient {}
1034
+ /**
1035
+ * Hooks to run before spans are finished.
1036
+ */
1037
+ hooks?: {
1038
+ /**
1039
+ * Hook to execute just before the request span finishes.
1040
+ */
1041
+ request?: (span?: Span, req?: ClientRequest, res?: IncomingMessage) => any;
1042
+ };
1209
1043
 
1210
- /**
1211
- * This plugin patches the [generic-pool](https://github.com/coopernurse/node-pool)
1212
- * module to bind the callbacks the the caller context.
1213
- */
1214
- interface generic_pool extends Integration {}
1044
+ /**
1045
+ * List of urls to which propagation headers should not be injected
1046
+ */
1047
+ propagationBlocklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
1048
+ }
1215
1049
 
1216
- /**
1217
- * This plugin automatically instruments the
1218
- * [@google-cloud/pubsub](https://github.com/googleapis/nodejs-pubsub) module.
1219
- */
1220
- interface google_cloud_pubsub extends Integration {}
1050
+ /** @hidden */
1051
+ interface Http2Client extends Http {
1052
+ /**
1053
+ * Use the remote endpoint host as the service name instead of the default.
1054
+ *
1055
+ * @default false
1056
+ */
1057
+ splitByDomain?: boolean;
1221
1058
 
1222
- /** @hidden */
1223
- interface ExecutionArgs {
1224
- schema: any,
1225
- document: any,
1226
- rootValue?: any,
1227
- contextValue?: any,
1228
- variableValues?: any,
1229
- operationName?: string,
1230
- fieldResolver?: any,
1231
- typeResolver?: any,
1232
- }
1059
+ /**
1060
+ * Callback function to determine if there was an error. It should take a
1061
+ * status code as its only parameter and return `true` for success or `false`
1062
+ * for errors.
1063
+ *
1064
+ * @default code => code < 400 || code >= 500
1065
+ */
1066
+ validateStatus?: (code: number) => boolean;
1067
+ }
1068
+
1069
+ /** @hidden */
1070
+ interface Http2Server extends Http {
1071
+ /**
1072
+ * Callback function to determine if there was an error. It should take a
1073
+ * status code as its only parameter and return `true` for success or `false`
1074
+ * for errors.
1075
+ *
1076
+ * @default code => code < 500
1077
+ */
1078
+ validateStatus?: (code: number) => boolean;
1079
+ }
1080
+
1081
+ /** @hidden */
1082
+ interface Grpc extends Instrumentation {
1083
+ /**
1084
+ * An array of metadata entries to record. Can also be a callback that returns
1085
+ * the key/value pairs to record. For example, using
1086
+ * `variables => variables` would record all variables.
1087
+ */
1088
+ metadata?: string[] | ((variables: { [key: string]: any }) => { [key: string]: any });
1089
+ }
1090
+
1091
+ /** @hidden */
1092
+ interface Moleculer extends Instrumentation {
1093
+ /**
1094
+ * Whether to include context meta as tags.
1095
+ *
1096
+ * @default false
1097
+ */
1098
+ meta?: boolean;
1099
+ }
1233
1100
 
1234
- /**
1235
- * This plugin automatically instruments the
1236
- * [graphql](https://github.com/graphql/graphql-js) module.
1237
- *
1238
- * The `graphql` integration uses the operation name as the span resource name.
1239
- * If no operation name is set, the resource name will always be just `query`,
1240
- * `mutation` or `subscription`.
1241
- *
1242
- * For example:
1243
- *
1244
- * ```graphql
1245
- * # good, the resource name will be `query HelloWorld`
1246
- * query HelloWorld {
1247
- * hello
1248
- * world
1249
- * }
1250
- *
1251
- * # bad, the resource name will be `query`
1252
- * {
1253
- * hello
1254
- * world
1255
- * }
1256
- * ```
1257
- */
1258
- interface graphql extends Instrumentation {
1259
1101
  /**
1260
- * The maximum depth of fields/resolvers to instrument. Set to `0` to only
1261
- * instrument the operation or to `-1` to instrument all fields/resolvers.
1262
- *
1263
- * @default -1
1102
+ * This plugin automatically instruments the
1103
+ * [amqp10](https://github.com/noodlefrenzy/node-amqp10) module.
1264
1104
  */
1265
- depth?: number;
1105
+ interface amqp10 extends Instrumentation {}
1266
1106
 
1267
1107
  /**
1268
- * Whether to include the source of the operation within the query as a tag
1269
- * on every span. This may contain sensitive information and sould only be
1270
- * enabled if sensitive data is always sent as variables and not in the
1271
- * query text.
1272
- *
1273
- * @default false
1108
+ * This plugin automatically instruments the
1109
+ * [amqplib](https://github.com/squaremo/amqp.node) module.
1274
1110
  */
1275
- source?: boolean;
1111
+ interface amqplib extends Instrumentation {}
1276
1112
 
1277
1113
  /**
1278
- * An array of variable names to record. Can also be a callback that returns
1279
- * the key/value pairs to record. For example, using
1280
- * `variables => variables` would record all variables.
1114
+ * This plugin automatically instruments the
1115
+ * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
1281
1116
  */
1282
- variables?: string[] | ((variables: { [key: string]: any }) => { [key: string]: any });
1117
+ interface aws_sdk extends Instrumentation {
1118
+ /**
1119
+ * Whether to add a suffix to the service name so that each AWS service has its own service name.
1120
+ * @default true
1121
+ */
1122
+ splitByAwsService?: boolean;
1123
+
1124
+ /**
1125
+ * Hooks to run before spans are finished.
1126
+ */
1127
+ hooks?: {
1128
+ /**
1129
+ * Hook to execute just before the aws span finishes.
1130
+ */
1131
+ request?: (span?: Span, response?: anyObject) => any;
1132
+ };
1133
+
1134
+ /**
1135
+ * Configuration for individual services to enable/disable them. Message
1136
+ * queue services can also configure the producer and consumer individually
1137
+ * by passing an object with a `producer` and `consumer` properties. The
1138
+ * list of valid service keys is in the service-specific section of
1139
+ * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html
1140
+ */
1141
+ [key: string]: boolean | Object | undefined;
1142
+ }
1283
1143
 
1284
1144
  /**
1285
- * Whether to collapse list items into a single element. (i.e. single
1286
- * `users.*.name` span instead of `users.0.name`, `users.1.name`, etc)
1287
- *
1288
- * @default true
1145
+ * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
1146
+ * to automatically inject trace identifiers in log records when the
1147
+ * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
1148
+ * on the tracer.
1289
1149
  */
1290
- collapse?: boolean;
1150
+ interface bunyan extends Integration {}
1291
1151
 
1292
1152
  /**
1293
- * Whether to enable signature calculation for the resource name. This can
1294
- * be disabled if your GraphQL operations always have a name. Note that when
1295
- * disabled all queries will need to be named for this to work properly.
1296
- *
1297
- * @default true
1153
+ * This plugin automatically instruments the
1154
+ * [cassandra-driver](https://github.com/datastax/nodejs-driver) module.
1298
1155
  */
1299
- signature?: boolean;
1156
+ interface cassandra_driver extends Instrumentation {}
1300
1157
 
1301
1158
  /**
1302
- * An object of optional callbacks to be executed during the respective
1303
- * phase of a GraphQL operation. Undefined callbacks default to a noop
1304
- * function.
1305
- *
1306
- * @default {}
1159
+ * This plugin automatically instruments the
1160
+ * [connect](https://github.com/senchalabs/connect) module.
1307
1161
  */
1308
- hooks?: {
1309
- execute?: (span?: Span, args?: ExecutionArgs, res?: any) => void;
1310
- validate?: (span?: Span, document?: any, errors?: any) => void;
1311
- parse?: (span?: Span, source?: any, document?: any) => void;
1312
- }
1313
- }
1162
+ interface connect extends HttpServer {}
1314
1163
 
1315
- /**
1316
- * This plugin automatically instruments the
1317
- * [grpc](https://github.com/grpc/grpc-node) module.
1318
- */
1319
- interface grpc extends Grpc {
1320
1164
  /**
1321
- * Configuration for gRPC clients.
1165
+ * This plugin automatically instruments the
1166
+ * [couchbase](https://www.npmjs.com/package/couchbase) module.
1322
1167
  */
1323
- client?: Grpc,
1168
+ interface couchbase extends Instrumentation {}
1324
1169
 
1325
1170
  /**
1326
- * Configuration for gRPC servers.
1171
+ * This plugin automatically instruments the
1172
+ * [cucumber](https://www.npmjs.com/package/@cucumber/cucumber) module.
1327
1173
  */
1328
- server?: Grpc
1329
- }
1330
-
1331
- /**
1332
- * This plugin automatically instruments the
1333
- * [hapi](https://hapijs.com/) module.
1334
- */
1335
- interface hapi extends HttpServer {}
1174
+ interface cucumber extends Integration {}
1336
1175
 
1337
- /**
1338
- * This plugin automatically instruments the
1339
- * [http](https://nodejs.org/api/http.html) module.
1340
- *
1341
- * By default any option set at the root will apply to both clients and
1342
- * servers. To configure only one or the other, use the `client` and `server`
1343
- * options.
1344
- */
1345
- interface http extends HttpClient, HttpServer {
1346
1176
  /**
1347
- * Configuration for HTTP clients.
1177
+ * This plugin automatically instruments the
1178
+ * [cypress](https://github.com/cypress-io/cypress) module.
1348
1179
  */
1349
- client?: HttpClient | boolean,
1180
+ interface cypress extends Integration {}
1350
1181
 
1351
1182
  /**
1352
- * Configuration for HTTP servers.
1183
+ * This plugin automatically instruments the
1184
+ * [dns](https://nodejs.org/api/dns.html) module.
1353
1185
  */
1354
- server?: HttpServer | boolean
1186
+ interface dns extends Instrumentation {}
1355
1187
 
1356
1188
  /**
1357
- * Hooks to run before spans are finished.
1189
+ * This plugin automatically instruments the
1190
+ * [elasticsearch](https://github.com/elastic/elasticsearch-js) module.
1358
1191
  */
1359
- hooks?: {
1192
+ interface elasticsearch extends Instrumentation {
1360
1193
  /**
1361
- * Hook to execute just before the request span finishes.
1194
+ * Hooks to run before spans are finished.
1362
1195
  */
1363
- request?: (
1364
- span?: Span,
1365
- req?: IncomingMessage | ClientRequest,
1366
- res?: ServerResponse | IncomingMessage
1367
- ) => any;
1368
- };
1369
- }
1196
+ hooks?: {
1197
+ /**
1198
+ * Hook to execute just before the query span finishes.
1199
+ */
1200
+ query?: (span?: Span, params?: TransportRequestParams) => any;
1201
+ };
1202
+ }
1370
1203
 
1371
- /**
1372
- * This plugin automatically instruments the
1373
- * [http2](https://nodejs.org/api/http2.html) module.
1374
- *
1375
- * By default any option set at the root will apply to both clients and
1376
- * servers. To configure only one or the other, use the `client` and `server`
1377
- * options.
1378
- */
1379
- interface http2 extends Http2Client, Http2Server {
1380
1204
  /**
1381
- * Configuration for HTTP clients.
1205
+ * This plugin automatically instruments the
1206
+ * [express](http://expressjs.com/) module.
1382
1207
  */
1383
- client?: Http2Client | boolean,
1208
+ interface express extends HttpServer {}
1384
1209
 
1385
1210
  /**
1386
- * Configuration for HTTP servers.
1211
+ * This plugin automatically instruments the
1212
+ * [fastify](https://www.fastify.io/) module.
1387
1213
  */
1388
- server?: Http2Server | boolean
1389
- }
1214
+ interface fastify extends HttpServer {}
1390
1215
 
1391
- /**
1392
- * This plugin automatically instruments the
1393
- * [ioredis](https://github.com/luin/ioredis) module.
1394
- */
1395
- interface ioredis extends Instrumentation {
1396
1216
  /**
1397
- * List of commands that should be instrumented. Commands must be in
1398
- * lowercase for example 'xread'.
1399
- *
1400
- * @default /^.*$/
1217
+ * This plugin automatically instruments the
1218
+ * [fetch](https://nodejs.org/api/globals.html#fetch) global.
1401
1219
  */
1402
- allowlist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1220
+ interface fetch extends HttpClient {}
1403
1221
 
1404
1222
  /**
1405
- * Deprecated in favor of `allowlist`.
1406
- *
1407
- * @deprecated
1408
- * @hidden
1223
+ * This plugin patches the [generic-pool](https://github.com/coopernurse/node-pool)
1224
+ * module to bind the callbacks the the caller context.
1409
1225
  */
1410
- whitelist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1226
+ interface generic_pool extends Integration {}
1411
1227
 
1412
1228
  /**
1413
- * List of commands that should not be instrumented. Takes precedence over
1414
- * allowlist if a command matches an entry in both. Commands must be in
1415
- * lowercase for example 'xread'.
1416
- *
1417
- * @default []
1229
+ * This plugin automatically instruments the
1230
+ * [@google-cloud/pubsub](https://github.com/googleapis/nodejs-pubsub) module.
1418
1231
  */
1419
- blocklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1232
+ interface google_cloud_pubsub extends Integration {}
1420
1233
 
1421
- /**
1422
- * Deprecated in favor of `blocklist`.
1423
- *
1424
- * @deprecated
1425
- * @hidden
1426
- */
1427
- blacklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1234
+ /** @hidden */
1235
+ interface ExecutionArgs {
1236
+ schema: any,
1237
+ document: any,
1238
+ rootValue?: any,
1239
+ contextValue?: any,
1240
+ variableValues?: any,
1241
+ operationName?: string,
1242
+ fieldResolver?: any,
1243
+ typeResolver?: any,
1244
+ }
1428
1245
 
1429
1246
  /**
1430
- * Whether to use a different service name for each Redis instance based
1431
- * on the configured connection name of the client.
1247
+ * This plugin automatically instruments the
1248
+ * [graphql](https://github.com/graphql/graphql-js) module.
1432
1249
  *
1433
- * @default false
1434
- */
1435
- splitByInstance?: boolean;
1436
- }
1437
-
1438
- /**
1439
- * This plugin automatically instruments the
1440
- * [jest](https://github.com/facebook/jest) module.
1441
- */
1442
- interface jest extends Integration {}
1443
-
1444
- /**
1445
- * This plugin patches the [knex](https://knexjs.org/)
1446
- * module to bind the promise callback the the caller context.
1447
- */
1448
- interface knex extends Integration {}
1449
-
1450
- /**
1451
- * This plugin automatically instruments the
1452
- * [koa](https://koajs.com/) module.
1453
- */
1454
- interface koa extends HttpServer {}
1455
-
1456
- /**
1457
- * This plugin automatically instruments the
1458
- * [kafkajs](https://kafka.js.org/) module.
1459
- */
1460
- interface kafkajs extends Instrumentation {}
1250
+ * The `graphql` integration uses the operation name as the span resource name.
1251
+ * If no operation name is set, the resource name will always be just `query`,
1252
+ * `mutation` or `subscription`.
1253
+ *
1254
+ * For example:
1255
+ *
1256
+ * ```graphql
1257
+ * # good, the resource name will be `query HelloWorld`
1258
+ * query HelloWorld {
1259
+ * hello
1260
+ * world
1261
+ * }
1262
+ *
1263
+ * # bad, the resource name will be `query`
1264
+ * {
1265
+ * hello
1266
+ * world
1267
+ * }
1268
+ * ```
1269
+ */
1270
+ interface graphql extends Instrumentation {
1271
+ /**
1272
+ * The maximum depth of fields/resolvers to instrument. Set to `0` to only
1273
+ * instrument the operation or to `-1` to instrument all fields/resolvers.
1274
+ *
1275
+ * @default -1
1276
+ */
1277
+ depth?: number;
1461
1278
 
1462
- /**
1463
- * This plugin automatically instruments the
1464
- * [ldapjs](https://github.com/ldapjs/node-ldapjs/) module.
1465
- */
1466
- interface ldapjs extends Instrumentation {}
1279
+ /**
1280
+ * Whether to include the source of the operation within the query as a tag
1281
+ * on every span. This may contain sensitive information and sould only be
1282
+ * enabled if sensitive data is always sent as variables and not in the
1283
+ * query text.
1284
+ *
1285
+ * @default false
1286
+ */
1287
+ source?: boolean;
1467
1288
 
1468
- /**
1469
- * This plugin automatically instruments the
1470
- * [mariadb](https://github.com/mariadb-corporation/mariadb-connector-nodejs) module.
1471
- */
1472
- interface mariadb extends mysql {}
1289
+ /**
1290
+ * An array of variable names to record. Can also be a callback that returns
1291
+ * the key/value pairs to record. For example, using
1292
+ * `variables => variables` would record all variables.
1293
+ */
1294
+ variables?: string[] | ((variables: { [key: string]: any }) => { [key: string]: any });
1473
1295
 
1474
- /**
1475
- * This plugin automatically instruments the
1476
- * [memcached](https://github.com/3rd-Eden/memcached) module.
1477
- */
1478
- interface memcached extends Instrumentation {}
1296
+ /**
1297
+ * Whether to collapse list items into a single element. (i.e. single
1298
+ * `users.*.name` span instead of `users.0.name`, `users.1.name`, etc)
1299
+ *
1300
+ * @default true
1301
+ */
1302
+ collapse?: boolean;
1479
1303
 
1480
- /**
1481
- * This plugin automatically instruments the
1482
- * [microgateway-core](https://github.com/apigee/microgateway-core) module.
1483
- */
1484
- interface microgateway_core extends HttpServer {}
1304
+ /**
1305
+ * Whether to enable signature calculation for the resource name. This can
1306
+ * be disabled if your GraphQL operations always have a name. Note that when
1307
+ * disabled all queries will need to be named for this to work properly.
1308
+ *
1309
+ * @default true
1310
+ */
1311
+ signature?: boolean;
1485
1312
 
1486
- /**
1487
- * This plugin automatically instruments the
1488
- * [mocha](https://mochajs.org/) module.
1489
- */
1490
- interface mocha extends Integration {}
1313
+ /**
1314
+ * An object of optional callbacks to be executed during the respective
1315
+ * phase of a GraphQL operation. Undefined callbacks default to a noop
1316
+ * function.
1317
+ *
1318
+ * @default {}
1319
+ */
1320
+ hooks?: {
1321
+ execute?: (span?: Span, args?: ExecutionArgs, res?: any) => void;
1322
+ validate?: (span?: Span, document?: any, errors?: any) => void;
1323
+ parse?: (span?: Span, source?: any, document?: any) => void;
1324
+ }
1325
+ }
1491
1326
 
1492
- /**
1493
- * This plugin automatically instruments the
1494
- * [moleculer](https://moleculer.services/) module.
1495
- */
1496
- interface moleculer extends Moleculer {
1497
1327
  /**
1498
- * Configuration for Moleculer clients. Set to false to disable client
1499
- * instrumentation.
1328
+ * This plugin automatically instruments the
1329
+ * [grpc](https://github.com/grpc/grpc-node) module.
1500
1330
  */
1501
- client?: boolean | Moleculer;
1331
+ interface grpc extends Grpc {
1332
+ /**
1333
+ * Configuration for gRPC clients.
1334
+ */
1335
+ client?: Grpc,
1336
+
1337
+ /**
1338
+ * Configuration for gRPC servers.
1339
+ */
1340
+ server?: Grpc
1341
+ }
1502
1342
 
1503
1343
  /**
1504
- * Configuration for Moleculer servers. Set to false to disable server
1505
- * instrumentation.
1344
+ * This plugin automatically instruments the
1345
+ * [hapi](https://hapijs.com/) module.
1506
1346
  */
1507
- server?: boolean | Moleculer;
1508
- }
1347
+ interface hapi extends HttpServer {}
1509
1348
 
1510
- /**
1511
- * This plugin automatically instruments the
1512
- * [mongodb-core](https://github.com/mongodb-js/mongodb-core) module.
1513
- */
1514
- interface mongodb_core extends Instrumentation {
1515
1349
  /**
1516
- * Whether to include the query contents in the resource name.
1350
+ * This plugin automatically instruments the
1351
+ * [http](https://nodejs.org/api/http.html) module.
1352
+ *
1353
+ * By default any option set at the root will apply to both clients and
1354
+ * servers. To configure only one or the other, use the `client` and `server`
1355
+ * options.
1517
1356
  */
1518
- queryInResourceName?: boolean;
1519
- }
1520
-
1521
- /**
1522
- * This plugin automatically instruments the
1523
- * [mongoose](https://mongoosejs.com/) module.
1524
- */
1525
- interface mongoose extends Instrumentation {}
1526
-
1527
- /**
1528
- * This plugin automatically instruments the
1529
- * [mysql](https://github.com/mysqljs/mysql) module.
1530
- */
1531
- interface mysql extends Instrumentation {
1532
- service?: string | ((params: any) => string);
1533
- }
1357
+ interface http extends HttpClient, HttpServer {
1358
+ /**
1359
+ * Configuration for HTTP clients.
1360
+ */
1361
+ client?: HttpClient | boolean,
1534
1362
 
1535
- /**
1536
- * This plugin automatically instruments the
1537
- * [mysql2](https://github.com/sidorares/node-mysql2) module.
1538
- */
1539
- interface mysql2 extends mysql {}
1363
+ /**
1364
+ * Configuration for HTTP servers.
1365
+ */
1366
+ server?: HttpServer | boolean
1540
1367
 
1541
- /**
1542
- * This plugin automatically instruments the
1543
- * [net](https://nodejs.org/api/net.html) module.
1544
- */
1545
- interface net extends Instrumentation {}
1368
+ /**
1369
+ * Hooks to run before spans are finished.
1370
+ */
1371
+ hooks?: {
1372
+ /**
1373
+ * Hook to execute just before the request span finishes.
1374
+ */
1375
+ request?: (
1376
+ span?: Span,
1377
+ req?: IncomingMessage | ClientRequest,
1378
+ res?: ServerResponse | IncomingMessage
1379
+ ) => any;
1380
+ };
1381
+ }
1546
1382
 
1547
- /**
1548
- * This plugin automatically instruments the
1549
- * [next](https://nextjs.org/) module.
1550
- */
1551
- interface next extends Instrumentation {
1552
1383
  /**
1553
- * Hooks to run before spans are finished.
1384
+ * This plugin automatically instruments the
1385
+ * [http2](https://nodejs.org/api/http2.html) module.
1386
+ *
1387
+ * By default any option set at the root will apply to both clients and
1388
+ * servers. To configure only one or the other, use the `client` and `server`
1389
+ * options.
1554
1390
  */
1555
- hooks?: {
1391
+ interface http2 extends Http2Client, Http2Server {
1556
1392
  /**
1557
- * Hook to execute just before the request span finishes.
1393
+ * Configuration for HTTP clients.
1558
1394
  */
1559
- request?: (span?: Span, req?: IncomingMessage, res?: ServerResponse) => any;
1560
- };
1561
- }
1562
-
1563
- /**
1564
- * This plugin automatically instruments the
1565
- * [openai](https://platform.openai.com/docs/api-reference?lang=node.js) module.
1566
- *
1567
- * Note that for logs to work you'll need to set the `DD_API_KEY` environment variable.
1568
- * You'll also need to adjust any firewall settings to allow the tracer to communicate
1569
- * with `http-intake.logs.datadoghq.com`.
1570
- *
1571
- * Note that for metrics to work you'll need to enable
1572
- * [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=hostagent#setup)
1573
- * in the agent.
1574
- */
1575
- interface openai extends Instrumentation {}
1395
+ client?: Http2Client | boolean,
1576
1396
 
1577
- /**
1578
- * This plugin automatically instruments the
1579
- * [opensearch](https://github.com/opensearch-project/opensearch-js) module.
1580
- */
1581
- interface opensearch extends elasticsearch {}
1397
+ /**
1398
+ * Configuration for HTTP servers.
1399
+ */
1400
+ server?: Http2Server | boolean
1401
+ }
1582
1402
 
1583
- /**
1584
- * This plugin automatically instruments the
1585
- * [oracledb](https://github.com/oracle/node-oracledb) module.
1586
- */
1587
- interface oracledb extends Instrumentation {
1588
1403
  /**
1589
- * The service name to be used for this plugin. If a function is used, it will be passed the connection parameters and its return value will be used as the service name.
1404
+ * This plugin automatically instruments the
1405
+ * [ioredis](https://github.com/luin/ioredis) module.
1590
1406
  */
1591
- service?: string | ((params: any) => string);
1592
- }
1407
+ interface ioredis extends Instrumentation {
1408
+ /**
1409
+ * List of commands that should be instrumented. Commands must be in
1410
+ * lowercase for example 'xread'.
1411
+ *
1412
+ * @default /^.*$/
1413
+ */
1414
+ allowlist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1593
1415
 
1594
- /**
1595
- * This plugin automatically instruments the
1596
- * [paperplane](https://github.com/articulate/paperplane) module.
1597
- */
1598
- interface paperplane extends HttpServer {}
1416
+ /**
1417
+ * Deprecated in favor of `allowlist`.
1418
+ *
1419
+ * @deprecated
1420
+ * @hidden
1421
+ */
1422
+ whitelist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1599
1423
 
1600
- /**
1601
- * This plugin automatically instruments the
1602
- * [playwright](https://github.com/microsoft/playwright) module.
1603
- */
1604
- interface playwright extends Integration {}
1424
+ /**
1425
+ * List of commands that should not be instrumented. Takes precedence over
1426
+ * allowlist if a command matches an entry in both. Commands must be in
1427
+ * lowercase for example 'xread'.
1428
+ *
1429
+ * @default []
1430
+ */
1431
+ blocklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1432
+
1433
+ /**
1434
+ * Deprecated in favor of `blocklist`.
1435
+ *
1436
+ * @deprecated
1437
+ * @hidden
1438
+ */
1439
+ blacklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1440
+
1441
+ /**
1442
+ * Whether to use a different service name for each Redis instance based
1443
+ * on the configured connection name of the client.
1444
+ *
1445
+ * @default false
1446
+ */
1447
+ splitByInstance?: boolean;
1448
+ }
1605
1449
 
1606
- /**
1607
- * This plugin automatically instruments the
1608
- * [pg](https://node-postgres.com/) module.
1609
- */
1610
- interface pg extends Instrumentation {
1611
1450
  /**
1612
- * The service name to be used for this plugin. If a function is used, it will be passed the connection parameters and its return value will be used as the service name.
1451
+ * This plugin automatically instruments the
1452
+ * [jest](https://github.com/facebook/jest) module.
1613
1453
  */
1614
- service?: string | ((params: any) => string);
1615
- }
1454
+ interface jest extends Integration {}
1616
1455
 
1617
- /**
1618
- * This plugin patches the [pino](http://getpino.io)
1619
- * to automatically inject trace identifiers in log records when the
1620
- * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
1621
- * on the tracer.
1622
- */
1623
- interface pino extends Integration {}
1456
+ /**
1457
+ * This plugin patches the [knex](https://knexjs.org/)
1458
+ * module to bind the promise callback the the caller context.
1459
+ */
1460
+ interface knex extends Integration {}
1624
1461
 
1625
- /**
1626
- * This plugin automatically instruments the
1627
- * [redis](https://github.com/NodeRedis/node_redis) module.
1628
- */
1629
- interface redis extends Instrumentation {
1630
1462
  /**
1631
- * List of commands that should be instrumented.
1632
- *
1633
- * @default /^.*$/
1463
+ * This plugin automatically instruments the
1464
+ * [koa](https://koajs.com/) module.
1634
1465
  */
1635
- allowlist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1466
+ interface koa extends HttpServer {}
1636
1467
 
1637
1468
  /**
1638
- * Deprecated in favor of `allowlist`.
1639
- *
1640
- * deprecated
1641
- * @hidden
1469
+ * This plugin automatically instruments the
1470
+ * [kafkajs](https://kafka.js.org/) module.
1642
1471
  */
1643
- whitelist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1472
+ interface kafkajs extends Instrumentation {}
1644
1473
 
1645
1474
  /**
1646
- * List of commands that should not be instrumented. Takes precedence over
1647
- * allowlist if a command matches an entry in both.
1648
- *
1649
- * @default []
1475
+ * This plugin automatically instruments the
1476
+ * [ldapjs](https://github.com/ldapjs/node-ldapjs/) module.
1650
1477
  */
1651
- blocklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1478
+ interface ldapjs extends Instrumentation {}
1652
1479
 
1653
1480
  /**
1654
- * Deprecated in favor of `blocklist`.
1655
- *
1656
- * @deprecated
1657
- * @hidden
1481
+ * This plugin automatically instruments the
1482
+ * [mariadb](https://github.com/mariadb-corporation/mariadb-connector-nodejs) module.
1658
1483
  */
1659
- blacklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1660
- }
1484
+ interface mariadb extends mysql {}
1661
1485
 
1662
- /**
1663
- * This plugin automatically instruments the
1664
- * [restify](http://restify.com/) module.
1665
- */
1666
- interface restify extends HttpServer {}
1486
+ /**
1487
+ * This plugin automatically instruments the
1488
+ * [memcached](https://github.com/3rd-Eden/memcached) module.
1489
+ */
1490
+ interface memcached extends Instrumentation {}
1667
1491
 
1668
- /**
1669
- * This plugin automatically instruments the
1670
- * [rhea](https://github.com/amqp/rhea) module.
1671
- */
1672
- interface rhea extends Instrumentation {}
1492
+ /**
1493
+ * This plugin automatically instruments the
1494
+ * [microgateway-core](https://github.com/apigee/microgateway-core) module.
1495
+ */
1496
+ interface microgateway_core extends HttpServer {}
1673
1497
 
1674
- /**
1675
- * This plugin automatically instruments the
1676
- * [router](https://github.com/pillarjs/router) module.
1677
- */
1678
- interface router extends Integration {}
1498
+ /**
1499
+ * This plugin automatically instruments the
1500
+ * [mocha](https://mochajs.org/) module.
1501
+ */
1502
+ interface mocha extends Integration {}
1679
1503
 
1680
- /**
1681
- * This plugin automatically instruments the
1682
- * [sharedb](https://github.com/share/sharedb) module.
1683
- */
1684
- interface sharedb extends Integration {
1685
1504
  /**
1686
- * Hooks to run before spans are finished.
1505
+ * This plugin automatically instruments the
1506
+ * [moleculer](https://moleculer.services/) module.
1687
1507
  */
1688
- hooks?: {
1508
+ interface moleculer extends Moleculer {
1689
1509
  /**
1690
- * Hook to execute just when the span is created.
1510
+ * Configuration for Moleculer clients. Set to false to disable client
1511
+ * instrumentation.
1691
1512
  */
1692
- receive?: (span?: Span, request?: any) => any;
1513
+ client?: boolean | Moleculer;
1693
1514
 
1694
1515
  /**
1695
- * Hook to execute just when the span is finished.
1516
+ * Configuration for Moleculer servers. Set to false to disable server
1517
+ * instrumentation.
1696
1518
  */
1697
- reply?: (span?: Span, request?: any, response?: any) => any;
1698
- };
1699
- }
1519
+ server?: boolean | Moleculer;
1520
+ }
1700
1521
 
1701
- /**
1702
- * This plugin automatically instruments the
1703
- * [tedious](https://github.com/tediousjs/tedious/) module.
1704
- */
1705
- interface tedious extends Instrumentation {}
1522
+ /**
1523
+ * This plugin automatically instruments the
1524
+ * [mongodb-core](https://github.com/mongodb-js/mongodb-core) module.
1525
+ */
1526
+ interface mongodb_core extends Instrumentation {
1527
+ /**
1528
+ * Whether to include the query contents in the resource name.
1529
+ */
1530
+ queryInResourceName?: boolean;
1531
+ }
1706
1532
 
1707
- /**
1708
- * This plugin patches the [winston](https://github.com/winstonjs/winston)
1709
- * to automatically inject trace identifiers in log records when the
1710
- * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
1711
- * on the tracer.
1712
- */
1713
- interface winston extends Integration {}
1714
- }
1533
+ /**
1534
+ * This plugin automatically instruments the
1535
+ * [mongoose](https://mongoosejs.com/) module.
1536
+ */
1537
+ interface mongoose extends Instrumentation {}
1715
1538
 
1716
- export namespace opentelemetry {
1717
- /**
1718
- * A registry for creating named {@link Tracer}s.
1719
- */
1720
- export interface TracerProvider extends otel.TracerProvider {
1721
1539
  /**
1722
- * Construct a new TracerProvider to register with @opentelemetry/api
1723
- *
1724
- * @returns TracerProvider A TracerProvider instance
1540
+ * This plugin automatically instruments the
1541
+ * [mysql](https://github.com/mysqljs/mysql) module.
1725
1542
  */
1726
- new(): TracerProvider;
1543
+ interface mysql extends Instrumentation {
1544
+ service?: string | ((params: any) => string);
1545
+ }
1727
1546
 
1728
1547
  /**
1729
- * Returns a Tracer, creating one if one with the given name and version is
1730
- * not already created.
1731
- *
1732
- * This function may return different Tracer types (e.g.
1733
- * {@link NoopTracerProvider} vs. a functional tracer).
1734
- *
1735
- * @param name The name of the tracer or instrumentation library.
1736
- * @param version The version of the tracer or instrumentation library.
1737
- * @param options The options of the tracer or instrumentation library.
1738
- * @returns Tracer A Tracer with the given name and version
1548
+ * This plugin automatically instruments the
1549
+ * [mysql2](https://github.com/sidorares/node-mysql2) module.
1739
1550
  */
1740
- getTracer(name: string, version?: string): Tracer;
1551
+ interface mysql2 extends mysql {}
1741
1552
 
1742
1553
  /**
1743
- * Register this tracer provider with @opentelemetry/api
1554
+ * This plugin automatically instruments the
1555
+ * [net](https://nodejs.org/api/net.html) module.
1744
1556
  */
1745
- register(): void;
1746
- }
1557
+ interface net extends Instrumentation {}
1747
1558
 
1748
- /**
1749
- * Tracer provides an interface for creating {@link Span}s.
1750
- */
1751
- export interface Tracer extends otel.Tracer {
1752
1559
  /**
1753
- * Starts a new {@link Span}. Start the span without setting it on context.
1754
- *
1755
- * This method do NOT modify the current Context.
1756
- *
1757
- * @param name The name of the span
1758
- * @param [options] SpanOptions used for span creation
1759
- * @param [context] Context to use to extract parent
1760
- * @returns Span The newly created span
1761
- * @example
1762
- * const span = tracer.startSpan('op');
1763
- * span.setAttribute('key', 'value');
1764
- * span.end();
1765
- */
1766
- startSpan(name: string, options?: SpanOptions, context?: Context): Span;
1767
-
1768
- /**
1769
- * Starts a new {@link Span} and calls the given function passing it the
1770
- * created span as first argument.
1771
- * Additionally the new span gets set in context and this context is activated
1772
- * for the duration of the function call.
1773
- *
1774
- * @param name The name of the span
1775
- * @param [options] SpanOptions used for span creation
1776
- * @param [context] Context to use to extract parent
1777
- * @param fn function called in the context of the span and receives the newly created span as an argument
1778
- * @returns return value of fn
1779
- * @example
1780
- * const something = tracer.startActiveSpan('op', span => {
1781
- * try {
1782
- * do some work
1783
- * span.setStatus({code: SpanStatusCode.OK});
1784
- * return something;
1785
- * } catch (err) {
1786
- * span.setStatus({
1787
- * code: SpanStatusCode.ERROR,
1788
- * message: err.message,
1789
- * });
1790
- * throw err;
1791
- * } finally {
1792
- * span.end();
1793
- * }
1794
- * });
1795
- *
1796
- * @example
1797
- * const span = tracer.startActiveSpan('op', span => {
1798
- * try {
1799
- * do some work
1800
- * return span;
1801
- * } catch (err) {
1802
- * span.setStatus({
1803
- * code: SpanStatusCode.ERROR,
1804
- * message: err.message,
1805
- * });
1806
- * throw err;
1807
- * }
1808
- * });
1809
- * do some more work
1810
- * span.end();
1811
- */
1812
- startActiveSpan<F extends (span: Span) => unknown>(name: string, fn: F): ReturnType<F>;
1813
- startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;
1814
- startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, context: otel.Context, fn: F): ReturnType<F>;
1815
- }
1560
+ * This plugin automatically instruments the
1561
+ * [next](https://nextjs.org/) module.
1562
+ */
1563
+ interface next extends Instrumentation {
1564
+ /**
1565
+ * Hooks to run before spans are finished.
1566
+ */
1567
+ hooks?: {
1568
+ /**
1569
+ * Hook to execute just before the request span finishes.
1570
+ */
1571
+ request?: (span?: Span, req?: IncomingMessage, res?: ServerResponse) => any;
1572
+ };
1573
+ }
1816
1574
 
1817
- /**
1818
- * An interface that represents a span. A span represents a single operation
1819
- * within a trace. Examples of span might include remote procedure calls or a
1820
- * in-process function calls to sub-components. A Trace has a single, top-level
1821
- * "root" Span that in turn may have zero or more child Spans, which in turn
1822
- * may have children.
1823
- *
1824
- * Spans are created by the {@link Tracer.startSpan} method.
1825
- */
1826
- export interface Span extends otel.Span {
1827
1575
  /**
1828
- * Returns the {@link SpanContext} object associated with this Span.
1576
+ * This plugin automatically instruments the
1577
+ * [openai](https://platform.openai.com/docs/api-reference?lang=node.js) module.
1829
1578
  *
1830
- * Get an immutable, serializable identifier for this span that can be used
1831
- * to create new child spans. Returned SpanContext is usable even after the
1832
- * span ends.
1579
+ * Note that for logs to work you'll need to set the `DD_API_KEY` environment variable.
1580
+ * You'll also need to adjust any firewall settings to allow the tracer to communicate
1581
+ * with `http-intake.logs.datadoghq.com`.
1833
1582
  *
1834
- * @returns the SpanContext object associated with this Span.
1583
+ * Note that for metrics to work you'll need to enable
1584
+ * [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=hostagent#setup)
1585
+ * in the agent.
1835
1586
  */
1836
- spanContext(): SpanContext;
1587
+ interface openai extends Instrumentation {}
1837
1588
 
1838
1589
  /**
1839
- * Sets an attribute to the span.
1840
- *
1841
- * Sets a single Attribute with the key and value passed as arguments.
1842
- *
1843
- * @param key the key for this attribute.
1844
- * @param value the value for this attribute. Setting a value null or
1845
- * undefined is invalid and will result in undefined behavior.
1590
+ * This plugin automatically instruments the
1591
+ * [opensearch](https://github.com/opensearch-project/opensearch-js) module.
1846
1592
  */
1847
- setAttribute(key: string, value: SpanAttributeValue): this;
1593
+ interface opensearch extends elasticsearch {}
1848
1594
 
1849
1595
  /**
1850
- * Sets attributes to the span.
1851
- *
1852
- * @param attributes the attributes that will be added.
1853
- * null or undefined attribute values
1854
- * are invalid and will result in undefined behavior.
1596
+ * This plugin automatically instruments the
1597
+ * [oracledb](https://github.com/oracle/node-oracledb) module.
1855
1598
  */
1856
- setAttributes(attributes: SpanAttributes): this;
1599
+ interface oracledb extends Instrumentation {
1600
+ /**
1601
+ * The service name to be used for this plugin. If a function is used, it will be passed the connection parameters and its return value will be used as the service name.
1602
+ */
1603
+ service?: string | ((params: any) => string);
1604
+ }
1857
1605
 
1858
1606
  /**
1859
- * Adds an event to the Span.
1860
- *
1861
- * @param name the name of the event.
1862
- * @param [attributesOrStartTime] the attributes that will be added; these are
1863
- * associated with this event. Can be also a start time
1864
- * if type is {@type TimeInput} and 3rd param is undefined
1865
- * @param [startTime] start time of the event.
1607
+ * This plugin automatically instruments the
1608
+ * [paperplane](https://github.com/articulate/paperplane) module.
1866
1609
  */
1867
- addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, startTime?: TimeInput): this;
1610
+ interface paperplane extends HttpServer {}
1868
1611
 
1869
1612
  /**
1870
- * Sets a status to the span. If used, this will override the default Span
1871
- * status. Default is {@link SpanStatusCode.UNSET}. SetStatus overrides the value
1872
- * of previous calls to SetStatus on the Span.
1873
- *
1874
- * @param status the SpanStatus to set.
1613
+ * This plugin automatically instruments the
1614
+ * [playwright](https://github.com/microsoft/playwright) module.
1615
+ */
1616
+ interface playwright extends Integration {}
1617
+
1618
+ /**
1619
+ * This plugin automatically instruments the
1620
+ * [pg](https://node-postgres.com/) module.
1875
1621
  */
1876
- setStatus(status: SpanStatus): this;
1622
+ interface pg extends Instrumentation {
1623
+ /**
1624
+ * The service name to be used for this plugin. If a function is used, it will be passed the connection parameters and its return value will be used as the service name.
1625
+ */
1626
+ service?: string | ((params: any) => string);
1627
+ /**
1628
+ * The database monitoring propagation mode to be used for this plugin.
1629
+ */
1630
+ dbmPropagationMode?: string;
1631
+ }
1877
1632
 
1878
1633
  /**
1879
- * Updates the Span name.
1880
- *
1881
- * This will override the name provided via {@link Tracer.startSpan}.
1882
- *
1883
- * Upon this update, any sampling behavior based on Span name will depend on
1884
- * the implementation.
1885
- *
1886
- * @param name the Span name.
1634
+ * This plugin patches the [pino](http://getpino.io)
1635
+ * to automatically inject trace identifiers in log records when the
1636
+ * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
1637
+ * on the tracer.
1887
1638
  */
1888
- updateName(name: string): this;
1639
+ interface pino extends Integration {}
1889
1640
 
1890
1641
  /**
1891
- * Marks the end of Span execution.
1892
- *
1893
- * Call to End of a Span MUST not have any effects on child spans. Those may
1894
- * still be running and can be ended later.
1895
- *
1896
- * Do not return `this`. The Span generally should not be used after it
1897
- * is ended so chaining is not desired in this context.
1898
- *
1899
- * @param [endTime] the time to set as Span's end time. If not provided,
1900
- * use the current time as the span's end time.
1642
+ * This plugin automatically instruments the
1643
+ * [redis](https://github.com/NodeRedis/node_redis) module.
1901
1644
  */
1902
- end(endTime?: TimeInput): void;
1645
+ interface redis extends Instrumentation {
1646
+ /**
1647
+ * List of commands that should be instrumented.
1648
+ *
1649
+ * @default /^.*$/
1650
+ */
1651
+ allowlist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1652
+
1653
+ /**
1654
+ * Deprecated in favor of `allowlist`.
1655
+ *
1656
+ * deprecated
1657
+ * @hidden
1658
+ */
1659
+ whitelist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1660
+
1661
+ /**
1662
+ * List of commands that should not be instrumented. Takes precedence over
1663
+ * allowlist if a command matches an entry in both.
1664
+ *
1665
+ * @default []
1666
+ */
1667
+ blocklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1668
+
1669
+ /**
1670
+ * Deprecated in favor of `blocklist`.
1671
+ *
1672
+ * @deprecated
1673
+ * @hidden
1674
+ */
1675
+ blacklist?: string | RegExp | ((command: string) => boolean) | (string | RegExp | ((command: string) => boolean))[];
1676
+ }
1903
1677
 
1904
1678
  /**
1905
- * Returns the flag whether this span will be recorded.
1906
- *
1907
- * @returns true if this Span is active and recording information like events
1908
- * with the `AddEvent` operation and attributes using `setAttributes`.
1679
+ * This plugin automatically instruments the
1680
+ * [restify](http://restify.com/) module.
1909
1681
  */
1910
- isRecording(): boolean;
1682
+ interface restify extends HttpServer {}
1911
1683
 
1912
1684
  /**
1913
- * Sets exception as a span event
1914
- * @param exception the exception the only accepted values are string or Error
1915
- * @param [time] the time to set as Span's event time. If not provided,
1916
- * use the current time.
1685
+ * This plugin automatically instruments the
1686
+ * [rhea](https://github.com/amqp/rhea) module.
1917
1687
  */
1918
- recordException(exception: Exception, time?: TimeInput): void;
1688
+ interface rhea extends Instrumentation {}
1919
1689
 
1920
1690
  /**
1921
- * Causally links another span to the current span
1922
- * @param {otel.SpanContext} context The context of the span to link to.
1923
- * @param {SpanAttributes} attributes An optional key value pair of arbitrary values.
1924
- * @returns {void}
1691
+ * This plugin automatically instruments the
1692
+ * [router](https://github.com/pillarjs/router) module.
1925
1693
  */
1926
- addLink (context: otel.SpanContext, attributes?: SpanAttributes): void;
1927
- }
1694
+ interface router extends Integration {}
1928
1695
 
1929
- /**
1930
- * A SpanContext represents the portion of a {@link Span} which must be
1931
- * serialized and propagated along side of a {@link Baggage}.
1932
- */
1933
- export interface SpanContext extends otel.SpanContext {
1934
1696
  /**
1935
- * The ID of the trace that this span belongs to. It is worldwide unique
1936
- * with practically sufficient probability by being made as 16 randomly
1937
- * generated bytes, encoded as a 32 lowercase hex characters corresponding to
1938
- * 128 bits.
1697
+ * This plugin automatically instruments the
1698
+ * [sharedb](https://github.com/share/sharedb) module.
1939
1699
  */
1940
- traceId: string;
1700
+ interface sharedb extends Integration {
1701
+ /**
1702
+ * Hooks to run before spans are finished.
1703
+ */
1704
+ hooks?: {
1705
+ /**
1706
+ * Hook to execute just when the span is created.
1707
+ */
1708
+ receive?: (span?: Span, request?: any) => any;
1709
+
1710
+ /**
1711
+ * Hook to execute just when the span is finished.
1712
+ */
1713
+ reply?: (span?: Span, request?: any, response?: any) => any;
1714
+ };
1715
+ }
1941
1716
 
1942
1717
  /**
1943
- * The ID of the Span. It is globally unique with practically sufficient
1944
- * probability by being made as 8 randomly generated bytes, encoded as a 16
1945
- * lowercase hex characters corresponding to 64 bits.
1718
+ * This plugin automatically instruments the
1719
+ * [tedious](https://github.com/tediousjs/tedious/) module.
1946
1720
  */
1947
- spanId: string;
1721
+ interface tedious extends Instrumentation {}
1948
1722
 
1949
1723
  /**
1950
- * Only true if the SpanContext was propagated from a remote parent.
1724
+ * This plugin patches the [winston](https://github.com/winstonjs/winston)
1725
+ * to automatically inject trace identifiers in log records when the
1726
+ * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
1727
+ * on the tracer.
1951
1728
  */
1952
- isRemote?: boolean;
1729
+ interface winston extends Integration {}
1730
+ }
1953
1731
 
1732
+ export namespace opentelemetry {
1954
1733
  /**
1955
- * Trace flags to propagate.
1956
- *
1957
- * It is represented as 1 byte (bitmap). Bit to represent whether trace is
1958
- * sampled or not. When set, the least significant bit documents that the
1959
- * caller may have recorded trace data. A caller who does not record trace
1960
- * data out-of-band leaves this flag unset.
1961
- *
1962
- * see {@link TraceFlags} for valid flag values.
1734
+ * A registry for creating named {@link Tracer}s.
1735
+ */
1736
+ export interface TracerProvider extends otel.TracerProvider {
1737
+ /**
1738
+ * Construct a new TracerProvider to register with @opentelemetry/api
1739
+ *
1740
+ * @returns TracerProvider A TracerProvider instance
1741
+ */
1742
+ new(): TracerProvider;
1743
+
1744
+ /**
1745
+ * Returns a Tracer, creating one if one with the given name and version is
1746
+ * not already created.
1747
+ *
1748
+ * @param name The name of the tracer or instrumentation library.
1749
+ * @param version The version of the tracer or instrumentation library.
1750
+ * @param options The options of the tracer or instrumentation library.
1751
+ * @returns Tracer A Tracer with the given name and version
1752
+ */
1753
+ getTracer(name: string, version?: string, options?: any): Tracer;
1754
+
1755
+ /**
1756
+ * Register this tracer provider with @opentelemetry/api
1757
+ */
1758
+ register(): void;
1759
+ }
1760
+
1761
+ /**
1762
+ * Tracer provides an interface for creating {@link Span}s.
1963
1763
  */
1964
- traceFlags: number;
1764
+ export interface Tracer extends otel.Tracer {
1765
+ /**
1766
+ * Starts a new {@link Span}. Start the span without setting it on context.
1767
+ *
1768
+ * This method do NOT modify the current Context.
1769
+ *
1770
+ * @param name The name of the span
1771
+ * @param [options] SpanOptions used for span creation
1772
+ * @param [context] Context to use to extract parent
1773
+ * @returns Span The newly created span
1774
+ * @example
1775
+ * const span = tracer.startSpan('op');
1776
+ * span.setAttribute('key', 'value');
1777
+ * span.end();
1778
+ */
1779
+ startSpan(name: string, options?: SpanOptions, context?: Context): Span;
1780
+
1781
+ /**
1782
+ * Starts a new {@link Span} and calls the given function passing it the
1783
+ * created span as first argument.
1784
+ * Additionally the new span gets set in context and this context is activated
1785
+ * for the duration of the function call.
1786
+ *
1787
+ * @param name The name of the span
1788
+ * @param [options] SpanOptions used for span creation
1789
+ * @param [context] Context to use to extract parent
1790
+ * @param fn function called in the context of the span and receives the newly created span as an argument
1791
+ * @returns return value of fn
1792
+ * @example
1793
+ * const something = tracer.startActiveSpan('op', span => {
1794
+ * try {
1795
+ * do some work
1796
+ * span.setStatus({code: SpanStatusCode.OK});
1797
+ * return something;
1798
+ * } catch (err) {
1799
+ * span.setStatus({
1800
+ * code: SpanStatusCode.ERROR,
1801
+ * message: err.message,
1802
+ * });
1803
+ * throw err;
1804
+ * } finally {
1805
+ * span.end();
1806
+ * }
1807
+ * });
1808
+ *
1809
+ * @example
1810
+ * const span = tracer.startActiveSpan('op', span => {
1811
+ * try {
1812
+ * do some work
1813
+ * return span;
1814
+ * } catch (err) {
1815
+ * span.setStatus({
1816
+ * code: SpanStatusCode.ERROR,
1817
+ * message: err.message,
1818
+ * });
1819
+ * throw err;
1820
+ * }
1821
+ * });
1822
+ * do some more work
1823
+ * span.end();
1824
+ */
1825
+ startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, context: otel.Context, fn: F): ReturnType<F>;
1826
+ startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;
1827
+ startActiveSpan<F extends (span: Span) => unknown>(name: string, fn: F): ReturnType<F>;
1828
+ }
1965
1829
 
1966
1830
  /**
1967
- * Tracing-system-specific info to propagate.
1968
- *
1969
- * The tracestate field value is a `list` as defined below. The `list` is a
1970
- * series of `list-members` separated by commas `,`, and a list-member is a
1971
- * key/value pair separated by an equals sign `=`. Spaces and horizontal tabs
1972
- * surrounding `list-members` are ignored. There can be a maximum of 32
1973
- * `list-members` in a `list`.
1974
- * More Info: https://www.w3.org/TR/trace-context/#tracestate-field
1831
+ * An interface that represents a span. A span represents a single operation
1832
+ * within a trace. Examples of span might include remote procedure calls or a
1833
+ * in-process function calls to sub-components. A Trace has a single, top-level
1834
+ * "root" Span that in turn may have zero or more child Spans, which in turn
1835
+ * may have children.
1975
1836
  *
1976
- * Examples:
1977
- * Single tracing system (generic format):
1978
- * tracestate: rojo=00f067aa0ba902b7
1979
- * Multiple tracing systems (with different formatting):
1980
- * tracestate: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE
1837
+ * Spans are created by the {@link Tracer.startSpan} method.
1981
1838
  */
1982
- traceState?: TraceState;
1983
- }
1839
+ export interface Span extends otel.Span {
1840
+ /**
1841
+ * Returns the {@link SpanContext} object associated with this Span.
1842
+ *
1843
+ * Get an immutable, serializable identifier for this span that can be used
1844
+ * to create new child spans. Returned SpanContext is usable even after the
1845
+ * span ends.
1846
+ *
1847
+ * @returns the SpanContext object associated with this Span.
1848
+ */
1849
+ spanContext(): SpanContext;
1850
+
1851
+ /**
1852
+ * Sets an attribute to the span.
1853
+ *
1854
+ * Sets a single Attribute with the key and value passed as arguments.
1855
+ *
1856
+ * @param key the key for this attribute.
1857
+ * @param value the value for this attribute. Setting a value null or
1858
+ * undefined is invalid and will result in undefined behavior.
1859
+ */
1860
+ setAttribute(key: string, value: SpanAttributeValue): this;
1861
+
1862
+ /**
1863
+ * Sets attributes to the span.
1864
+ *
1865
+ * @param attributes the attributes that will be added.
1866
+ * null or undefined attribute values
1867
+ * are invalid and will result in undefined behavior.
1868
+ */
1869
+ setAttributes(attributes: SpanAttributes): this;
1870
+
1871
+ /**
1872
+ * Adds an event to the Span.
1873
+ *
1874
+ * @param name the name of the event.
1875
+ * @param [attributesOrStartTime] the attributes that will be added; these are
1876
+ * associated with this event. Can be also a start time
1877
+ * if type is {@link TimeInput} and 3rd param is undefined
1878
+ * @param [startTime] start time of the event.
1879
+ */
1880
+ addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, startTime?: TimeInput): this;
1881
+
1882
+ /**
1883
+ * Sets a status to the span. If used, this will override the default Span
1884
+ * status. Default is {@link otel.SpanStatusCode.UNSET}. SetStatus overrides the value
1885
+ * of previous calls to SetStatus on the Span.
1886
+ *
1887
+ * @param status the SpanStatus to set.
1888
+ */
1889
+ setStatus(status: SpanStatus): this;
1890
+
1891
+ /**
1892
+ * Updates the Span name.
1893
+ *
1894
+ * This will override the name provided via {@link Tracer.startSpan}.
1895
+ *
1896
+ * Upon this update, any sampling behavior based on Span name will depend on
1897
+ * the implementation.
1898
+ *
1899
+ * @param name the Span name.
1900
+ */
1901
+ updateName(name: string): this;
1984
1902
 
1985
- export type Context = otel.Context;
1986
- export type Exception = otel.Exception;
1987
- export type SpanAttributes = otel.SpanAttributes;
1988
- export type SpanAttributeValue = otel.SpanAttributeValue;
1989
- export type SpanOptions = otel.SpanOptions;
1990
- export type SpanStatus = otel.SpanStatus;
1991
- export type TimeInput = otel.TimeInput;
1992
- export type TraceState = otel.TraceState;
1903
+ /**
1904
+ * Marks the end of Span execution.
1905
+ *
1906
+ * Call to End of a Span MUST not have any effects on child spans. Those may
1907
+ * still be running and can be ended later.
1908
+ *
1909
+ * Do not return `this`. The Span generally should not be used after it
1910
+ * is ended so chaining is not desired in this context.
1911
+ *
1912
+ * @param [endTime] the time to set as Span's end time. If not provided,
1913
+ * use the current time as the span's end time.
1914
+ */
1915
+ end(endTime?: TimeInput): void;
1916
+
1917
+ /**
1918
+ * Returns the flag whether this span will be recorded.
1919
+ *
1920
+ * @returns true if this Span is active and recording information like events
1921
+ * with the `AddEvent` operation and attributes using `setAttributes`.
1922
+ */
1923
+ isRecording(): boolean;
1924
+
1925
+ /**
1926
+ * Sets exception as a span event
1927
+ * @param exception the exception the only accepted values are string or Error
1928
+ * @param [time] the time to set as Span's event time. If not provided,
1929
+ * use the current time.
1930
+ */
1931
+ recordException(exception: Exception, time?: TimeInput): void;
1932
+
1933
+ /**
1934
+ * Causally links another span to the current span
1935
+ * @param {otel.SpanContext} context The context of the span to link to.
1936
+ * @param {SpanAttributes} attributes An optional key value pair of arbitrary values.
1937
+ * @returns {void}
1938
+ */
1939
+ addLink(context: otel.SpanContext, attributes?: SpanAttributes): void;
1940
+ }
1941
+
1942
+ /**
1943
+ * A SpanContext represents the portion of a {@link Span} which must be
1944
+ * serialized and propagated along side of a {@link otel.Baggage}.
1945
+ */
1946
+ export interface SpanContext extends otel.SpanContext {
1947
+ /**
1948
+ * The ID of the trace that this span belongs to. It is worldwide unique
1949
+ * with practically sufficient probability by being made as 16 randomly
1950
+ * generated bytes, encoded as a 32 lowercase hex characters corresponding to
1951
+ * 128 bits.
1952
+ */
1953
+ traceId: string;
1954
+
1955
+ /**
1956
+ * The ID of the Span. It is globally unique with practically sufficient
1957
+ * probability by being made as 8 randomly generated bytes, encoded as a 16
1958
+ * lowercase hex characters corresponding to 64 bits.
1959
+ */
1960
+ spanId: string;
1961
+
1962
+ /**
1963
+ * Only true if the SpanContext was propagated from a remote parent.
1964
+ */
1965
+ isRemote?: boolean;
1966
+
1967
+ /**
1968
+ * Trace flags to propagate.
1969
+ *
1970
+ * It is represented as 1 byte (bitmap). Bit to represent whether trace is
1971
+ * sampled or not. When set, the least significant bit documents that the
1972
+ * caller may have recorded trace data. A caller who does not record trace
1973
+ * data out-of-band leaves this flag unset.
1974
+ *
1975
+ * see {@link otel.TraceFlags} for valid flag values.
1976
+ */
1977
+ traceFlags: number;
1978
+
1979
+ /**
1980
+ * Tracing-system-specific info to propagate.
1981
+ *
1982
+ * The tracestate field value is a `list` as defined below. The `list` is a
1983
+ * series of `list-members` separated by commas `,`, and a list-member is a
1984
+ * key/value pair separated by an equals sign `=`. Spaces and horizontal tabs
1985
+ * surrounding `list-members` are ignored. There can be a maximum of 32
1986
+ * `list-members` in a `list`.
1987
+ * More Info: https://www.w3.org/TR/trace-context/#tracestate-field
1988
+ *
1989
+ * Examples:
1990
+ * Single tracing system (generic format):
1991
+ * tracestate: rojo=00f067aa0ba902b7
1992
+ * Multiple tracing systems (with different formatting):
1993
+ * tracestate: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE
1994
+ */
1995
+ traceState?: TraceState;
1996
+ }
1997
+
1998
+ export type Context = otel.Context;
1999
+ export type Exception = otel.Exception;
2000
+ export type SpanAttributes = otel.SpanAttributes;
2001
+ export type SpanAttributeValue = otel.SpanAttributeValue;
2002
+ export type SpanOptions = otel.SpanOptions;
2003
+ export type SpanStatus = otel.SpanStatus;
2004
+ export type TimeInput = otel.TimeInput;
2005
+ export type TraceState = otel.TraceState;
2006
+ }
1993
2007
  }
1994
2008
 
1995
2009
  /**
@@ -1997,6 +2011,6 @@ export namespace opentelemetry {
1997
2011
  * start tracing. If not initialized, or initialized and disabled, it will use
1998
2012
  * a no-op implementation.
1999
2013
  */
2000
- export declare const tracer: Tracer;
2014
+ declare const tracer: Tracer;
2001
2015
 
2002
- export default tracer;
2016
+ export = tracer;