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