forked from autotelic/fastify-opentelemetry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastify-opentelemetry.d.ts
38 lines (33 loc) · 1.34 KB
/
fastify-opentelemetry.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
import { FastifyPluginCallback, FastifyReply, FastifyRequest } from 'fastify'
import { Context, Span, SpanAttributes, TextMapGetter, TextMapSetter, Tracer } from '@opentelemetry/api'
/**
* Object exposed as part of the "openTelemetry" object on the fastify request.
*/
export interface OpenTelemetryReqInstance {
readonly activeSpan: Span | undefined,
readonly context: Context,
readonly tracer: Tracer,
readonly inject: <Carrier> (carrier: Carrier, setter?: TextMapSetter) => void,
readonly extract: <Carrier> (carrier: Carrier, getter?: TextMapGetter) => Context,
}
declare module 'fastify' {
interface FastifyRequest {
readonly openTelemetry: () => OpenTelemetryReqInstance,
}
}
/**
* Options for the OpenTelemetry plugin.
*/
export interface OpenTelemetryPluginOptions {
readonly exposeApi?: boolean,
readonly formatSpanName?: (request: FastifyRequest) => string,
readonly formatSpanAttributes?: {
readonly request?: (request: FastifyRequest) => SpanAttributes,
readonly reply?: (reply: FastifyReply) => SpanAttributes,
readonly error?: (error: Error) => SpanAttributes,
},
readonly wrapRoutes?: boolean | string[],
readonly ignoreRoutes?: string[] | ((path: string, method: string) => boolean),
}
declare const fastifyOpenTelemetry: FastifyPluginCallback<OpenTelemetryPluginOptions>
export default fastifyOpenTelemetry