forked from DataDog/dd-trace-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
1259 lines (1106 loc) · 35.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, ServerResponse } from "http";
import { LookupFunction } from 'net';
import * as opentracing from "opentracing";
import { SpanOptions } from "opentracing/lib/tracer";
export { SpanOptions };
/**
* Tracer is the entry-point of the Datadog tracing implementation.
*/
export declare interface Tracer extends opentracing.Tracer {
/**
* Starts and returns a new Span representing a logical unit of work.
* @param {string} name The name of the operation.
* @param {SpanOptions} [options] Options for the newly created span.
* @returns {Span} A new Span object.
*/
startSpan(name: string, options?: SpanOptions): 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: SpanContext | 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): SpanContext | null;
/**
* Initializes the tracer. This should be called before importing other libraries.
*/
init(options?: 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(): 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.
*/
trace<T>(name: string, fn: (span?: Span, fn?: (error?: Error) => any) => T): T;
trace<T>(name: string, options: TraceOptions & SpanOptions, fn: (span?: Span, done?: (error?: Error) => string) => 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, requiresParent?: boolean): T;
wrap<T = (...args: any[]) => any>(name: string, options: TraceOptions & SpanOptions, fn: T): T;
wrap<T = (...args: any[]) => any>(name: string, options: (...args: any[]) => TraceOptions & SpanOptions, fn: T): T;
/**
* Create and return a string that can be included in the <head> of a
* document to enable RUM tracing to include it. The resulting string
* should not be cached.
*/
getRumData(): string;
}
export declare 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
}
/**
* 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 declare interface Span extends opentracing.Span {
context(): SpanContext;
}
/**
* 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 declare 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;
}
/**
* Sampling rule to configure on the priority sampler.
*/
export declare 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
}
/**
* List of options available to the tracer.
*/
export declare interface TracerOptions {
/**
* Whether to enable the tracer.
* @default true
*/
enabled?: boolean;
/**
* Enable debug logging in the tracer.
* @default false
*/
debug?: boolean;
/**
* 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,
/**
* Enable Trace Analytics.
* @default false
*/
analytics?: 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;
/**
* 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;
/**
* 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;
/**
* Percentage of spans to sample as a float between 0 and 1.
* @default 1
*/
sampleRate?: number;
/**
* Interval in milliseconds at which the tracer will submit traces to the agent.
* @default 2000
*/
flushInterval?: number;
/**
* Whether to enable runtime metrics.
* @default false
*/
runtimeMetrics?: boolean
/**
* Whether to track the scope of async functions. This is needed for async/await to work with non-native promises (thenables). Only disable this if you are sure only native promises are used with async/await, or if you are using Node >=14.5 since the issue has been fixed in that version.
* @default true
*/
trackAsyncScope?: 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
/**
* Configuration of the ingestion between the agent and the backend.
*/
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.
*/
rateLimit?: number
};
/**
* Experimental features can be enabled all at once by using true or individually using key / value pairs.
* @default {}
*/
experimental?: boolean | {
b3?: boolean
/**
* Whether to add an auto-generated `runtime-id` tag to spans and metrics.
* @default false
*/
runtimeId?: boolean
/**
* Whether to write traces to log output, rather than send to an agent
* @default false
*/
exporter?: 'log' | 'browser' | 'agent'
/**
* List of origins to allow for distributed tracing. This is used to determine whether to propagate context from the browser for CORS.
* @default []
*/
distributedTracingOriginAllowlist?: (string|RegExp)[]
/**
* Deprecated in favor of `distributedTracingOriginAllowlist`.
*
* @deprecated
* @hidden
*/
distributedTracingOriginWhitelist?: (string|RegExp)[]
/**
* Configuration of the priority sampler. Supports a global config and rules by span name or service name. The first matching rule is applied, and if no rule matches it falls back to the global config or on the rates provided by the agent if there is no global config.
*/
sampler?: {
/**
* Sample rate to apply globally when no other rule is matched. Omit to fallback on the dynamic rates returned by the agent instead.
*/
sampleRate?: Number,
/**
* Global rate limit that is applied on the global sample rate and all rules.
* @default 100
*/
rateLimit?: Number,
/**
* Sampling rules to apply to priority sampling.
* @default []
*/
rules?: SamplingRule[]
}
/**
* Whether to enable the experimental `getRumData` method.
* @default false
*/
enableGetRumData?: boolean
/**
* Whether to set the error flag when an error occurs in an internal span.
* @default false
*/
internalErrors?: 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' | '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
/**
* Client token for browser tracing. Can be generated in the UI at `Integrations -> APIs`.
*/
clientToken?: string
/**
* 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
*/
orphanable?: boolean
}
/** @hidden */
interface EventEmitter {
emit(eventName: string | symbol, ...args: any[]): any;
on?(eventName: string | symbol, listener: (...args: any[]) => any): any;
off?(eventName: string | symbol, listener: (...args: any[]) => any): any;
addListener?(eventName: string | symbol, listener: (...args: any[]) => any): any;
removeListener?(eventName: string | symbol, listener: (...args: any[]) => any): any;
}
/** @hidden */
declare 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 declare 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|EventEmitter} target 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>;
bind(emitter: EventEmitter, span?: Span | null): EventEmitter;
}
/** @hidden */
interface Plugins {
"amqp10": plugins.amqp10;
"amqplib": plugins.amqplib;
"aws-sdk": plugins.aws_sdk;
"bluebird": plugins.bluebird;
"bunyan": plugins.bunyan;
"cassandra-driver": plugins.cassandra_driver;
"connect": plugins.connect;
"couchbase": plugins.couchbase;
"dns": plugins.dns;
"elasticsearch": plugins.elasticsearch;
"express": plugins.express;
"fastify": plugins.fastify;
"fs": plugins.fs;
"generic-pool": plugins.generic_pool;
"google-cloud-pubsub": plugins.google_cloud_pubsub;
"graphql": plugins.graphql;
"grpc": plugins.grpc;
"hapi": plugins.hapi;
"http": plugins.http;
"http2": plugins.http2;
"ioredis": plugins.ioredis;
"jest": plugins.jest;
"kafkajs": plugins.kafkajs
"knex": plugins.knex;
"koa": plugins.koa;
"limitd-client": plugins.limitd_client;
"memcached": plugins.memcached;
"microgateway-core": plugins.microgateway_core;
"mocha": plugins.mocha;
"mongodb-core": plugins.mongodb_core;
"mongoose": plugins.mongoose;
"mysql": plugins.mysql;
"mysql2": plugins.mysql2;
"net": plugins.net;
"paperplane": plugins.paperplane;
"pg": plugins.pg;
"pino": plugins.pino;
"promise-js": plugins.promise_js;
"promise": plugins.promise;
"q": plugins.q;
"redis": plugins.redis;
"restify": plugins.restify;
"rhea": plugins.rhea;
"router": plugins.router;
"tedious": plugins.tedious;
"when": plugins.when;
"winston": plugins.winston;
}
/** @hidden */
interface Analyzable {
/**
* Whether to enable App Analytics. Can also be set to a number instead to
* control the sample rate, or to an key-value pair with span names as keys
* and booleans or sample rates as values for more granular control.
*/
analytics?: boolean | number | { [key: string]: boolean | number };
}
declare 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 that should be instrumented.
*
* @default /^.*$/
*/
allowlist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
/**
* Deprecated in favor of `allowlist`.
*
* @deprecated
* @hidden
*/
whitelist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
/**
* List of URLs that should not be instrumented. Takes precedence over
* allowlist if a URL matches an entry in both.
*
* @default []
*/
blocklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
/**
* Deprecated in favor of `blocklist`.
*
* @deprecated
* @hidden
*/
blacklist?: string | RegExp | ((url: string) => boolean) | (string | RegExp | ((url: string) => boolean))[];
/**
* An array of headers to include in the span metadata.
*
* @default []
*/
headers?: string[];
/**
* Callback function to determine if there was an error. It should take a
* status code as its only parameter and return `true` for success or `false`
* for errors.
*
* @default code => code < 500
*/
validateStatus?: (code: number) => boolean;
}
/** @hidden */
interface HttpServer extends Http {
/**
* Callback function to determine if there was an error. It should take a
* status code as its only parameter and return `true` for success or `false`
* for errors.
*
* @default code => code < 500
*/
validateStatus?: (code: number) => boolean;
/**
* Hooks to run before spans are finished.
*/
hooks?: {
/**
* Hook to execute just before the request span finishes.
*/
request?: (span?: opentracing.Span, req?: IncomingMessage, res?: ServerResponse) => any;
};
/**
* Whether to enable instrumention of <plugin>.middleware spans
*
* @default true
*/
middleware?: boolean;
}
/** @hidden */
interface HttpClient extends Http {
/**
* Use the remote endpoint host as the service name instead of the default.
*
* @default false
*/
splitByDomain?: boolean;
/**
* Callback function to determine if there was an error. It should take a
* status code as its only parameter and return `true` for success or `false`
* for errors.
*
* @default code => code < 400
*/
validateStatus?: (code: number) => boolean;
/**
* Hooks to run before spans are finished.
*/
hooks?: {
/**
* Hook to execute just before the request span finishes.
*/
request?: (span?: opentracing.Span, req?: ClientRequest, res?: IncomingMessage) => any;
};
}
/** @hidden */
interface Http2Client extends Http {
/**
* Use the remote endpoint host as the service name instead of the default.
*
* @default false
*/
splitByDomain?: boolean;
/**
* Callback function to determine if there was an error. It should take a
* status code as its only parameter and return `true` for success or `false`
* for errors.
*
* @default code => code < 400
*/
validateStatus?: (code: number) => boolean;
}
/** @hidden */
interface Http2Server extends Http {
/**
* Callback function to determine if there was an error. It should take a
* status code as its only parameter and return `true` for success or `false`
* for errors.
*
* @default code => code < 500
*/
validateStatus?: (code: number) => boolean;
}
/** @hidden */
interface Grpc extends Instrumentation {
/**
* An array of metadata entries to record. Can also be a callback that returns
* the key/value pairs to record. For example, using
* `variables => variables` would record all variables.
*/
metadata?: string[] | ((variables: { [key: string]: any }) => { [key: string]: any });
}
/**
* This plugin automatically instruments the
* [amqp10](https://github.com/noodlefrenzy/node-amqp10) module.
*/
interface amqp10 extends Instrumentation {}
/**
* This plugin automatically instruments the
* [amqplib](https://github.com/squaremo/amqp.node) module.
*/
interface amqplib extends Instrumentation {}
/**
* This plugin automatically instruments the
* [aws-sdk](https://github.com/aws/aws-sdk-js) module.
*/
interface aws_sdk extends Instrumentation {
/**
* Whether to add a suffix to the service name so that each AWS service has its own service name.
* @default true
*/
splitByAwsService?: boolean;
/**
* Hooks to run before spans are finished.
*/
hooks?: {
/**
* Hook to execute just before the aws span finishes.
*/
request?: (span?: opentracing.Span, response?: anyObject) => any;
};
/**
* Configuration for individual services to enable/disable them. Message
* queue services can also configure the producer and consumer individually
* by passing an object with a `producer` and `consumer` properties. The
* list of valid service keys is in the service-specific section of
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html
*/
[key: string]: boolean | Object | undefined;
}
/**
* This plugin patches the [bluebird](https://github.com/petkaantonov/bluebird)
* module to bind the promise callback the the caller context.
*/
interface bluebird extends Integration {}
/**
* This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
* to automatically inject trace identifiers in log records when the
* [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
* on the tracer.
*/
interface bunyan extends Integration {}
/**
* This plugin automatically instruments the
* [cassandra-driver](https://github.com/datastax/nodejs-driver) module.
*/
interface cassandra_driver extends Instrumentation {}
/**
* This plugin automatically instruments the
* [connect](https://github.com/senchalabs/connect) module.
*/
interface connect extends HttpServer {}
/**
* This plugin automatically instruments the
* [couchbase](https://www.npmjs.com/package/couchbase) module.
*/
interface couchbase extends Instrumentation {}
/**
* This plugin automatically instruments the
* [dns](https://nodejs.org/api/dns.html) module.
*/
interface dns extends Instrumentation {}
/**
* This plugin automatically instruments the
* [elasticsearch](https://github.com/elastic/elasticsearch-js) module.
*/
interface elasticsearch extends Instrumentation {
/**
* Hooks to run before spans are finished.
*/
hooks?: {
/**
* Hook to execute just before the query span finishes.
*/
query?: (span?: opentracing.Span, params?: TransportRequestParams) => any;
};
}
/**
* This plugin automatically instruments the
* [express](http://expressjs.com/) module.
*/
interface express extends HttpServer {}
/**
* This plugin automatically instruments the
* [fastify](https://www.fastify.io/) module.
*/
interface fastify extends HttpServer {}
/**
* This plugin automatically instruments the
* [fs](https://nodejs.org/api/fs.html) module.
*/
interface fs extends Instrumentation {}
/**
* This plugin patches the [generic-pool](https://github.com/coopernurse/node-pool)
* module to bind the callbacks the the caller context.
*/
interface generic_pool extends Integration {}
/**
* This plugin automatically instruments the
* [@google-cloud/pubsub](https://github.com/googleapis/nodejs-pubsub) module.
*/
interface google_cloud_pubsub extends Integration {}
/** @hidden */
interface ExecutionArgs {
schema: any,
document: any,
rootValue?: any,
contextValue?: any,
variableValues?: any,
operationName?: string,
fieldResolver?: any,
typeResolver?: any,
}
/**
* This plugin automatically instruments the
* [graphql](https://github.com/graphql/graphql-js) module.
*
* The `graphql` integration uses the operation name as the span resource name.
* If no operation name is set, the resource name will always be just `query`,
* `mutation` or `subscription`.
*
* For example:
*
* ```graphql
* # good, the resource name will be `query HelloWorld`
* query HelloWorld {
* hello
* world
* }
*
* # bad, the resource name will be `query`
* {
* hello
* world
* }
* ```
*/
interface graphql extends Instrumentation {
/**
* The maximum depth of fields/resolvers to instrument. Set to `0` to only
* instrument the operation or to `-1` to instrument all fields/resolvers.
*
* @default -1
*/
depth?: number;
/**
* An array of variable names to record. Can also be a callback that returns
* the key/value pairs to record. For example, using
* `variables => variables` would record all variables.
*/
variables?: string[] | ((variables: { [key: string]: any }) => { [key: string]: any });
/**
* Whether to collapse list items into a single element. (i.e. single
* `users.*.name` span instead of `users.0.name`, `users.1.name`, etc)
*
* @default true
*/
collapse?: boolean;
/**
* Whether to enable signature calculation for the resource name. This can
* be disabled if your GraphQL operations always have a name.
*
* @default true
*/
signature?: boolean;
/**
* An object of optional callbacks to be executed during the respective
* phase of a GraphQL operation. Undefined callbacks default to a noop
* function.
*
* @default {}
*/
hooks?: {
execute?: (span?: Span, args?: ExecutionArgs, res?: any) => void;
}
}
/**
* This plugin automatically instruments the
* [grpc](https://github.com/grpc/grpc-node) module.
*/
interface grpc extends Grpc {
/**
* Configuration for gRPC clients.
*/
client?: Grpc,
/**
* Configuration for gRPC servers.
*/
server?: Grpc
}
/**
* This plugin automatically instruments the
* [hapi](https://hapijs.com/) module.
*/
interface hapi extends HttpServer {}
/**
* This plugin automatically instruments the
* [http](https://nodejs.org/api/http.html) module.
*
* By default any option set at the root will apply to both clients and
* servers. To configure only one or the other, use the `client` and `server`
* options.
*/
interface http extends HttpClient, HttpServer {
/**
* Configuration for HTTP clients.
*/
client?: HttpClient,
/**
* Configuration for HTTP servers.
*/
server?: HttpServer
/**
* Hooks to run before spans are finished.
*/
hooks?: {
/**
* Hook to execute just before the request span finishes.
*/
request?: (
span?: opentracing.Span,
req?: IncomingMessage | ClientRequest,
res?: ServerResponse | IncomingMessage
) => any;
};
}
/**
* This plugin automatically instruments the
* [http2](https://nodejs.org/api/http2.html) module.
*
* By default any option set at the root will apply to both clients and
* servers. To configure only one or the other, use the `client` and `server`
* options.
*/
interface http2 extends Http2Client, Http2Server {
/**
* Configuration for HTTP clients.