-
Notifications
You must be signed in to change notification settings - Fork 310
/
index.d.ts
2572 lines (2268 loc) · 80.3 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { ClientRequest, IncomingMessage, OutgoingMessage, ServerResponse } from "http";
import { LookupFunction } from 'net';
import * as opentracing from "opentracing";
import * as otel from "@opentelemetry/api";
/**
* Tracer is the entry-point of the Datadog tracing implementation.
*/
interface Tracer extends opentracing.Tracer {
/**
* Add tracer as a named export
*/
tracer: Tracer;
/**
* For compatibility with NodeNext + esModuleInterop: false
*/
default: Tracer;
/**
* Starts and returns a new Span representing a logical unit of work.
* @param {string} name The name of the operation.
* @param {tracer.SpanOptions} [options] Options for the newly created span.
* @returns {Span} A new Span object.
*/
startSpan (name: string, options?: tracer.SpanOptions): tracer.Span;
/**
* Injects the given SpanContext instance for cross-process propagation
* within `carrier`
* @param {SpanContext} spanContext The SpanContext to inject into the
* carrier object. As a convenience, a Span instance may be passed
* in instead (in which case its .context() is used for the
* inject()).
* @param {string} format The format of the carrier.
* @param {any} carrier The carrier object.
*/
inject (spanContext: tracer.SpanContext | tracer.Span, format: string, carrier: any): void;
/**
* Returns a SpanContext instance extracted from `carrier` in the given
* `format`.
* @param {string} format The format of the carrier.
* @param {any} carrier The carrier object.
* @return {SpanContext}
* The extracted SpanContext, or null if no such SpanContext could
* be found in `carrier`
*/
extract (format: string, carrier: any): tracer.SpanContext | null;
/**
* Initializes the tracer. This should be called before importing other libraries.
*/
init (options?: tracer.TracerOptions): this;
/**
* Sets the URL for the trace agent. This should only be called _after_
* init() is called, only in cases where the URL needs to be set after
* initialization.
*/
setUrl (url: string): this;
/**
* Enable and optionally configure a plugin.
* @param plugin The name of a built-in plugin.
* @param config Configuration options. Can also be `false` to disable the plugin.
*/
use<P extends keyof Plugins> (plugin: P, config?: Plugins[P] | boolean): this;
/**
* Returns a reference to the current scope.
*/
scope (): tracer.Scope;
/**
* Instruments a function by automatically creating a span activated on its
* scope.
*
* The span will automatically be finished when one of these conditions is
* met:
*
* * The function returns a promise, in which case the span will finish when
* the promise is resolved or rejected.
* * The function takes a callback as its second parameter, in which case the
* span will finish when that callback is called.
* * The function doesn't accept a callback and doesn't return a promise, in
* which case the span will finish at the end of the function execution.
*
* If the `orphanable` option is set to false, the function will not be traced
* unless there is already an active span or `childOf` option. Note that this
* option is deprecated and has been removed in version 4.0.
*/
trace<T> (name: string, fn: (span: tracer.Span) => T): T;
trace<T> (name: string, fn: (span: tracer.Span, done: (error?: Error) => void) => T): T;
trace<T> (name: string, options: tracer.TraceOptions & tracer.SpanOptions, fn: (span?: tracer.Span, done?: (error?: Error) => void) => T): T;
/**
* Wrap a function to automatically create a span activated on its
* scope when it's called.
*
* The span will automatically be finished when one of these conditions is
* met:
*
* * The function returns a promise, in which case the span will finish when
* the promise is resolved or rejected.
* * The function takes a callback as its last parameter, in which case the
* span will finish when that callback is called.
* * The function doesn't accept a callback and doesn't return a promise, in
* which case the span will finish at the end of the function execution.
*/
wrap<T = (...args: any[]) => any> (name: string, fn: T): T;
wrap<T = (...args: any[]) => any> (name: string, options: tracer.TraceOptions & tracer.SpanOptions, fn: T): T;
wrap<T = (...args: any[]) => any> (name: string, options: (...args: any[]) => tracer.TraceOptions & tracer.SpanOptions, fn: T): T;
/**
* Returns an HTML string containing <meta> tags that should be included in
* the <head> of a document to enable correlating the current trace with the
* RUM view. Otherwise, it is not possible to associate the trace used to
* generate the initial HTML document with a given RUM view. The resulting
* HTML document should not be cached as the meta tags are time-sensitive
* and are associated with a specific user.
*
* Note that this feature is currently not supported by the backend and
* using it will have no effect.
*/
getRumData (): string;
/**
* Links an authenticated user to the current trace.
* @param {User} user Properties of the authenticated user. Accepts custom fields.
* @returns {Tracer} The Tracer instance for chaining.
*/
setUser (user: tracer.User): Tracer;
appsec: tracer.Appsec;
TracerProvider: tracer.opentelemetry.TracerProvider;
dogstatsd: tracer.DogStatsD;
/**
* LLM Observability SDK
*/
llmobs: tracer.llmobs.LLMObs;
}
// left out of the namespace, so it
// is doesn't need to be exported for Tracer
/** @hidden */
interface Plugins {
"aerospike": tracer.plugins.aerospike;
"amqp10": tracer.plugins.amqp10;
"amqplib": tracer.plugins.amqplib;
"apollo": tracer.plugins.apollo;
"avsc": tracer.plugins.avsc;
"aws-sdk": tracer.plugins.aws_sdk;
"azure-functions": tracer.plugins.azure_functions;
"bunyan": tracer.plugins.bunyan;
"cassandra-driver": tracer.plugins.cassandra_driver;
"child_process": tracer.plugins.child_process;
"connect": tracer.plugins.connect;
"couchbase": tracer.plugins.couchbase;
"cucumber": tracer.plugins.cucumber;
"cypress": tracer.plugins.cypress;
"dns": tracer.plugins.dns;
"elasticsearch": tracer.plugins.elasticsearch;
"express": tracer.plugins.express;
"fastify": tracer.plugins.fastify;
"fetch": tracer.plugins.fetch;
"generic-pool": tracer.plugins.generic_pool;
"google-cloud-pubsub": tracer.plugins.google_cloud_pubsub;
"graphql": tracer.plugins.graphql;
"grpc": tracer.plugins.grpc;
"hapi": tracer.plugins.hapi;
"http": tracer.plugins.http;
"http2": tracer.plugins.http2;
"ioredis": tracer.plugins.ioredis;
"jest": tracer.plugins.jest;
"kafkajs": tracer.plugins.kafkajs
"knex": tracer.plugins.knex;
"koa": tracer.plugins.koa;
"langchain": tracer.plugins.langchain;
"mariadb": tracer.plugins.mariadb;
"memcached": tracer.plugins.memcached;
"microgateway-core": tracer.plugins.microgateway_core;
"mocha": tracer.plugins.mocha;
"moleculer": tracer.plugins.moleculer;
"mongodb-core": tracer.plugins.mongodb_core;
"mongoose": tracer.plugins.mongoose;
"mysql": tracer.plugins.mysql;
"mysql2": tracer.plugins.mysql2;
"net": tracer.plugins.net;
"next": tracer.plugins.next;
"openai": tracer.plugins.openai;
"opensearch": tracer.plugins.opensearch;
"oracledb": tracer.plugins.oracledb;
"paperplane": tracer.plugins.paperplane;
"playwright": tracer.plugins.playwright;
"pg": tracer.plugins.pg;
"pino": tracer.plugins.pino;
"protobufjs": tracer.plugins.protobufjs;
"redis": tracer.plugins.redis;
"restify": tracer.plugins.restify;
"rhea": tracer.plugins.rhea;
"router": tracer.plugins.router;
"selenium": tracer.plugins.selenium;
"sharedb": tracer.plugins.sharedb;
"tedious": tracer.plugins.tedious;
"undici": tracer.plugins.undici;
"vitest": tracer.plugins.vitest;
"winston": tracer.plugins.winston;
}
declare namespace tracer {
export type SpanOptions = opentracing.SpanOptions;
export { Tracer };
export interface TraceOptions extends Analyzable {
/**
* The resource you are tracing. The resource name must not be longer than
* 5000 characters.
*/
resource?: string,
/**
* The service you are tracing. The service name must not be longer than
* 100 characters.
*/
service?: string,
/**
* The type of request.
*/
type?: string
/**
* An array of span links
*/
links?: Array<{ context: SpanContext, attributes?: Object }>
}
/**
* Span represents a logical unit of work as part of a broader Trace.
* Examples of span might include remote procedure calls or a in-process
* function calls to sub-components. A Trace has a single, top-level "root"
* Span that in turn may have zero or more child Spans, which in turn may
* have children.
*/
export interface Span extends opentracing.Span {
context (): SpanContext;
/**
* Causally links another span to the current span
* @param {SpanContext} context The context of the span to link to.
* @param {Object} attributes An optional key value pair of arbitrary values.
* @returns {void}
*/
addLink (context: SpanContext, attributes?: Object): void;
}
/**
* SpanContext represents Span state that must propagate to descendant Spans
* and across process boundaries.
*
* SpanContext is logically divided into two pieces: the user-level "Baggage"
* (see setBaggageItem and getBaggageItem) that propagates across Span
* boundaries and any Tracer-implementation-specific fields that are needed to
* identify or otherwise contextualize the associated Span instance (e.g., a
* <trace_id, span_id, sampled> tuple).
*/
export interface SpanContext extends opentracing.SpanContext {
/**
* Returns the string representation of the internal trace ID.
*/
toTraceId (): string;
/**
* Returns the string representation of the internal span ID.
*/
toSpanId (): string;
/**
* Returns the string representation used for DBM integration.
*/
toTraceparent (): string;
}
/**
* Sampling rule to configure on the priority sampler.
*/
export interface SamplingRule {
/**
* Sampling rate for this rule.
*/
sampleRate: number
/**
* Service on which to apply this rule. The rule will apply to all services if not provided.
*/
service?: string | RegExp
/**
* Operation name on which to apply this rule. The rule will apply to all operation names if not provided.
*/
name?: string | RegExp
}
/**
* Span sampling rules to ingest single spans where the enclosing trace is dropped
*/
export interface SpanSamplingRule {
/**
* Sampling rate for this rule. Will default to 1.0 (always) if not provided.
*/
sampleRate?: number
/**
* Maximum number of spans matching a span sampling rule to be allowed per second.
*/
maxPerSecond?: number
/**
* Service name or pattern on which to apply this rule. The rule will apply to all services if not provided.
*/
service?: string
/**
* Operation name or pattern on which to apply this rule. The rule will apply to all operation names if not provided.
*/
name?: string
}
/**
* Selection and priority order of context propagation injection and extraction mechanisms.
*/
export interface PropagationStyle {
/**
* Selection of context propagation injection mechanisms.
*/
inject: string[],
/**
* Selection and priority order of context propagation extraction mechanisms.
*/
extract: string[]
}
/**
* List of options available to the tracer.
*/
export interface TracerOptions {
/**
* Whether to enable trace ID injection in log records to be able to correlate
* traces with logs.
* @default false
*/
logInjection?: boolean,
/**
* Whether to enable startup logs.
* @default true
*/
startupLogs?: boolean,
/**
* The service name to be used for this program. If not set, the service name
* will attempted to be inferred from package.json
*/
service?: string;
/**
* Provide service name mappings for each plugin.
*/
serviceMapping?: { [key: string]: string };
/**
* The url of the trace agent that the tracer will submit to.
* Takes priority over hostname and port, if set.
*/
url?: string;
/**
* The address of the trace agent that the tracer will submit to.
* @default 'localhost'
*/
hostname?: string;
/**
* The port of the trace agent that the tracer will submit to.
* @default 8126
*/
port?: number | string;
/**
* Whether to enable profiling.
*/
profiling?: boolean
/**
* Options specific for the Dogstatsd agent.
*/
dogstatsd?: {
/**
* The hostname of the Dogstatsd agent that the metrics will submitted to.
*/
hostname?: string
/**
* The port of the Dogstatsd agent that the metrics will submitted to.
* @default 8125
*/
port?: number
};
/**
* Set an application’s environment e.g. prod, pre-prod, stage.
*/
env?: string;
/**
* The version number of the application. If not set, the version
* will attempted to be inferred from package.json.
*/
version?: string;
/**
* Controls the ingestion sample rate (between 0 and 1) between the agent and the backend.
*/
sampleRate?: number;
/**
* Global rate limit that is applied on the global sample rate and all rules,
* and controls the ingestion rate limit between the agent and the backend.
* Defaults to deferring the decision to the agent.
*/
rateLimit?: number,
/**
* Sampling rules to apply to priority samplin. Each rule is a JSON,
* consisting of `service` and `name`, which are regexes to match against
* a trace's `service` and `name`, and a corresponding `sampleRate`. If not
* specified, will defer to global sampling rate for all spans.
* @default []
*/
samplingRules?: SamplingRule[]
/**
* Span sampling rules that take effect when the enclosing trace is dropped, to ingest single spans
* @default []
*/
spanSamplingRules?: SpanSamplingRule[]
/**
* Interval in milliseconds at which the tracer will submit traces to the agent.
* @default 2000
*/
flushInterval?: number;
/**
* Number of spans before partially exporting a trace. This prevents keeping all the spans in memory for very large traces.
* @default 1000
*/
flushMinSpans?: number;
/**
* Whether to enable runtime metrics.
* @default false
*/
runtimeMetrics?: boolean
/**
* Custom function for DNS lookups when sending requests to the agent.
* @default dns.lookup()
*/
lookup?: LookupFunction
/**
* 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.
* @default 0.4
*/
protocolVersion?: string
/**
* Deprecated in favor of the global versions of the variables provided under this option
*
* @deprecated
* @hidden
*/
ingestion?: {
/**
* Controls the ingestion sample rate (between 0 and 1) between the agent and the backend.
*/
sampleRate?: number
/**
* Controls the ingestion rate limit between the agent and the backend. Defaults to deferring the decision to the agent.
*/
rateLimit?: number
};
/**
* Experimental features can be enabled individually using key / value pairs.
* @default {}
*/
experimental?: {
b3?: boolean
traceparent?: boolean
/**
* Whether to add an auto-generated `runtime-id` tag to metrics.
* @default false
*/
runtimeId?: boolean
/**
* Whether to write traces to log output or agentless, rather than send to an agent
* @default false
*/
exporter?: 'log' | 'agent' | 'datadog'
/**
* Whether to enable the experimental `getRumData` method.
* @default false
*/
enableGetRumData?: boolean
/**
* Configuration of the IAST. Can be a boolean as an alias to `iast.enabled`.
*/
iast?: boolean | IastOptions
appsec?: {
/**
* Configuration of Standalone ASM mode
*/
standalone?: {
/**
* Whether to enable Standalone ASM.
* @default false
*/
enabled?: boolean
}
}
};
/**
* Whether to load all built-in plugins.
* @default true
*/
plugins?: boolean;
/**
* Custom logger to be used by the tracer (if debug = true),
* should support error(), warn(), info(), and debug() methods
* see https://datadog.github.io/dd-trace-js/#custom-logging
*/
logger?: {
error: (err: Error | string) => void;
warn: (message: string) => void;
info: (message: string) => void;
debug: (message: string) => void;
};
/**
* Global tags that should be assigned to every span.
*/
tags?: { [key: string]: any };
/**
* Specifies which scope implementation to use. The default is to use the best
* implementation for the runtime. Only change this if you know what you are
* doing.
*/
scope?: 'async_hooks' | 'async_local_storage' | 'async_resource' | 'sync' | 'noop'
/**
* 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.
* @default false
*/
reportHostname?: boolean
/**
* A string representing the minimum tracer log level to use when debug logging is enabled
* @default 'debug'
*/
logLevel?: 'error' | 'debug'
/**
* If false, require a parent in order to trace.
* @default true
* @deprecated since version 4.0
*/
orphanable?: boolean
/**
* Enables DBM to APM link using tag injection.
* @default 'disabled'
*/
dbmPropagationMode?: 'disabled' | 'service' | 'full'
/**
* Configuration of the AppSec protection. Can be a boolean as an alias to `appsec.enabled`.
*/
appsec?: boolean | {
/**
* Whether to enable AppSec.
* @default false
*/
enabled?: boolean,
/**
* Specifies a path to a custom rules file.
*/
rules?: string,
/**
* Controls the maximum amount of traces sampled by AppSec attacks, per second.
* @default 100
*/
rateLimit?: number,
/**
* Controls the maximum amount of time in microseconds the WAF is allowed to run synchronously for.
* @default 5000
*/
wafTimeout?: number,
/**
* Specifies a regex that will redact sensitive data by its key in attack reports.
*/
obfuscatorKeyRegex?: string,
/**
* Specifies a regex that will redact sensitive data by its value in attack reports.
*/
obfuscatorValueRegex?: string,
/**
* Specifies a path to a custom blocking template html file.
*/
blockedTemplateHtml?: string,
/**
* Specifies a path to a custom blocking template json file.
*/
blockedTemplateJson?: string,
/**
* Specifies a path to a custom blocking template json file for graphql requests
*/
blockedTemplateGraphql?: string,
/**
* Controls the automated user event tracking configuration
*/
eventTracking?: {
/**
* Controls the automated user tracking mode for user IDs and logins collections. Possible values:
* * 'anonymous': will hash user IDs and user logins before collecting them
* * 'anon': alias for 'anonymous'
* * 'safe': deprecated alias for 'anonymous'
*
* * 'identification': will collect user IDs and logins without redaction
* * 'ident': alias for 'identification'
* * 'extended': deprecated alias for 'identification'
*
* * 'disabled': will not collect user IDs and logins
*
* Unknown values will be considered as 'disabled'
* @default 'identification'
*/
mode?:
'anonymous' | 'anon' | 'safe' |
'identification' | 'ident' | 'extended' |
'disabled'
},
/**
* Configuration for Api Security
*/
apiSecurity?: {
/** Whether to enable Api Security.
* @default true
*/
enabled?: boolean,
},
/**
* Configuration for RASP
*/
rasp?: {
/** Whether to enable RASP.
* @default false
*/
enabled?: boolean
},
/**
* Configuration for stack trace reporting
*/
stackTrace?: {
/** Whether to enable stack trace reporting.
* @default true
*/
enabled?: boolean,
/** Specifies the maximum number of stack traces to be reported.
* @default 2
*/
maxStackTraces?: number,
/** Specifies the maximum depth of a stack trace to be reported.
* @default 32
*/
maxDepth?: number,
}
};
/**
* Configuration of the IAST. Can be a boolean as an alias to `iast.enabled`.
*/
iast?: boolean | IastOptions
/**
* Configuration of ASM Remote Configuration
*/
remoteConfig?: {
/**
* Specifies the remote configuration polling interval in seconds
* @default 5
*/
pollInterval?: number,
}
/**
* Whether to enable client IP collection from relevant IP headers
* @default false
*/
clientIpEnabled?: boolean
/**
* Custom header name to source the http.client_ip tag from.
*/
clientIpHeader?: string,
/**
* The selection and priority order of context propagation injection and extraction mechanisms.
*/
propagationStyle?: string[] | PropagationStyle
/**
* Cloud payload report as tags
*/
cloudPayloadTagging?: {
/**
* Additional JSONPath queries to replace with `redacted` in request payloads
* Undefined or invalid JSONPath queries disable the feature for requests.
*/
request?: string,
/**
* Additional JSONPath queries to replace with `redacted` in response payloads
* Undefined or invalid JSONPath queries disable the feature for responses.
*/
response?: string,
/**
* Maximum depth of payload traversal for tags
*/
maxDepth?: number
}
/**
* Configuration enabling LLM Observability. Enablement is superceded by the DD_LLMOBS_ENABLED environment variable.
*/
llmobs?: llmobs.LLMObsEnableOptions
}
/**
* User object that can be passed to `tracer.setUser()`.
*/
export interface User {
/**
* Unique identifier of the user.
* Mandatory.
*/
id: string,
/**
* Email of the user.
*/
email?: string,
/**
* User-friendly name of the user.
*/
name?: string,
/**
* Session ID of the user.
*/
session_id?: string,
/**
* Role the user is making the request under.
*/
role?: string,
/**
* Scopes or granted authorizations the user currently possesses.
* The value could come from the scope associated with an OAuth2
* Access Token or an attribute value in a SAML 2 Assertion.
*/
scope?: string,
/**
* Custom fields to attach to the user (RBAC, Oauth, etc…).
*/
[key: string]: string | undefined
}
export interface DogStatsD {
/**
* Increments a metric by the specified value, optionally specifying tags.
* @param {string} stat The dot-separated metric name.
* @param {number} value The amount to increment the stat by.
* @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
*/
increment(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
/**
* Decrements a metric by the specified value, optionally specifying tags.
* @param {string} stat The dot-separated metric name.
* @param {number} value The amount to decrement the stat by.
* @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
*/
decrement(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
/**
* Sets a distribution value, optionally specifying tags.
* @param {string} stat The dot-separated metric name.
* @param {number} value The amount to increment the stat by.
* @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
*/
distribution(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
/**
* Sets a gauge value, optionally specifying tags.
* @param {string} stat The dot-separated metric name.
* @param {number} value The amount to increment the stat by.
* @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
*/
gauge(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
/**
* Sets a histogram value, optionally specifying tags.
* @param {string} stat The dot-separated metric name.
* @param {number} value The amount to increment the stat by.
* @param {[tag:string]:string|number} tags Tags to pass along, such as `{ foo: 'bar' }`. Values are combined with config.tags.
*/
histogram(stat: string, value?: number, tags?: { [tag: string]: string|number }): void
/**
* Forces any unsent metrics to be sent
*
* @beta This method is experimental and could be removed in future versions.
*/
flush(): void
}
export interface Appsec {
/**
* Links a successful login event to the current trace. Will link the passed user to the current trace with Appsec.setUser() internally.
* @param {User} user Properties of the authenticated user. Accepts custom fields.
* @param {[key: string]: string} metadata Custom fields to link to the login success event.
*
* @beta This method is in beta and could change in future versions.
*/
trackUserLoginSuccessEvent(user: User, metadata?: { [key: string]: string }): void
/**
* Links a failed login event to the current trace.
* @param {string} userId The user id of the attemped login.
* @param {boolean} exists If the user id exists.
* @param {[key: string]: string} metadata Custom fields to link to the login failure event.
*
* @beta This method is in beta and could change in future versions.
*/
trackUserLoginFailureEvent(userId: string, exists: boolean, metadata?: { [key: string]: string }): void
/**
* Links a custom event to the current trace.
* @param {string} eventName The name of the event.
* @param {[key: string]: string} metadata Custom fields to link to the event.
*
* @beta This method is in beta and could change in future versions.
*/
trackCustomEvent(eventName: string, metadata?: { [key: string]: string }): void
/**
* Checks if the passed user should be blocked according to AppSec rules.
* If no user is linked to the current trace, will link the passed user to it.
* @param {User} user Properties of the authenticated user. Accepts custom fields.
* @return {boolean} Indicates whether the user should be blocked.
*
* @beta This method is in beta and could change in the future
*/
isUserBlocked(user: User): boolean
/**
* Sends a "blocked" template response based on the request accept header and ends the response.
* **You should stop processing the request after calling this function!**
* @param {IncomingMessage} req Can be passed to force which request to act on. Optional.
* @param {OutgoingMessage} res Can be passed to force which response to act on. Optional.
* @return {boolean} Indicates if the action was successful.
*
* @beta This method is in beta and could change in the future
*/
blockRequest(req?: IncomingMessage, res?: OutgoingMessage): boolean
/**
* Links an authenticated user to the current trace.
* @param {User} user Properties of the authenticated user. Accepts custom fields.
*
* @beta This method is in beta and could change in the future
*/
setUser(user: User): void
}
/** @hidden */
type anyObject = {
[key: string]: any;
};
/** @hidden */
interface TransportRequestParams {
method: string;
path: string;
body?: anyObject;
bulkBody?: anyObject;
querystring?: anyObject;
}
/**
* The Datadog Scope Manager. This is used for context propagation.
*/
export interface Scope {
/**
* Get the current active span or null if there is none.
*
* @returns {Span} The active span.
*/
active (): Span | null;
/**
* Activate a span in the scope of a function.
*
* @param {Span} span The span to activate.
* @param {Function} fn Function that will have the span activated on its scope.
* @returns The return value of the provided function.
*/
activate<T> (span: Span, fn: ((...args: any[]) => T)): T;
/**
* Binds a target to the provided span, or the active span if omitted.
*
* @param {Function|Promise} fn Target that will have the span activated on its scope.
* @param {Span} [span=scope.active()] The span to activate.
* @returns The bound target.
*/
bind<T extends (...args: any[]) => void> (fn: T, span?: Span | null): T;
bind<V, T extends (...args: any[]) => V> (fn: T, span?: Span | null): T;
bind<T> (fn: Promise<T>, span?: Span | null): Promise<T>;
}
/** @hidden */
interface Analyzable {
/**
* Whether to measure the span. Can also be set to a key-value pair with span
* names as keys and booleans as values for more granular control.
*/
measured?: boolean | { [key: string]: boolean };
}
export namespace plugins {
/** @hidden */
interface Integration {
/**
* The service name to be used for this plugin.
*/
service?: string | any;
/** Whether to enable the plugin.
* @default true
*/
enabled?: boolean;
}
/** @hidden */
interface Instrumentation extends Integration, Analyzable {}
/** @hidden */
interface Http extends Instrumentation {
/**
* List of URLs/paths that should be instrumented.