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