UNPKG

3.86 kBTypeScriptView Raw
1import { TraceTags, TypeSpanContext, HttpRequestOptions } from "./model/EventMessage";
2import { Span, ContextOptions, Recorders } from "./Span";
3/**
4 * Describes Event SDK methods from Tracer perspective
5 */
6declare abstract class ATracer {
7 static createSpan: (service: string, tags?: TraceTags, recorders?: Recorders, defaultTagsSetter?: Span['defaultTagsSetter']) => Span;
8 static createChildSpanFromContext: (service: string, context: TypeSpanContext, recorders?: Recorders) => {};
9 static injectContextToMessage: (context: TypeSpanContext, message: {
10 [key: string]: any;
11 }, path?: string) => {
12 [key: string]: any;
13 };
14 static injectContextToHttpRequest: (context: TypeSpanContext, request: {
15 [key: string]: any;
16 }, type?: HttpRequestOptions) => {
17 [key: string]: any;
18 };
19 static extractContextFromMessage: (message: {
20 [key: string]: any;
21 }, path?: string) => TypeSpanContext;
22 static extractContextFromHttpRequest: (request: any, type?: HttpRequestOptions, tracestateDecoder?: (tracestate: string) => string | {
23 [key: string]: string;
24 }) => TypeSpanContext | undefined;
25}
26declare class Tracer implements ATracer {
27 /**
28 * Creates new span from new trace
29 * @param service name of the service which will be asociated with the newly created span
30 * @param tags optional tags for the span
31 * @param recorders optional recorders. Defaults to defaultRecorder, which is either logger or sidecar client, based on default.json DISABLE_SIDECAR value
32 * @param defaultTagsSetter optional default tags setter method.
33 */
34 static createSpan(service: string, tags?: TraceTags, recorders?: Recorders, defaultTagsSetter?: Span['defaultTagsSetter']): Span;
35 /**
36 * Creates new child span from context with new service name
37 * @param service the name of the service of the new child span
38 * @param spanContext context of the previous span
39 * @param recorders optional recorders. Defaults to defaultRecorder, which is either logger or sidecar client, based on default.json DISABLE_SIDECAR value
40 */
41 static createChildSpanFromContext(service: string, spanContext: TypeSpanContext, recorders?: Recorders): Span;
42 /**
43 * Injects trace context into a carrier with optional path.
44 * @param context span context to be injected
45 * @param carrier any kind of message or other object with keys of type String.
46 * @param injectOptions type and path of the carrier. Type is not implemented yet. Path is the path to the trace context.
47 */
48 static injectContextToMessage(context: TypeSpanContext, carrier: {
49 [key: string]: any;
50 }, injectOptions?: ContextOptions): {
51 [key: string]: any;
52 };
53 /**
54 * Injects trace context into a http request headers.
55 * @param context span context to be injected
56 * @param request HTTP request.
57 * @param type type of the headers that will be created - 'w3c' or 'xb3'.
58 */
59 static injectContextToHttpRequest(context: TypeSpanContext, request: {
60 [key: string]: any;
61 }, type?: HttpRequestOptions): {
62 [key: string]: any;
63 };
64 /**
65 * Extracts trace context from a carrier (ex: kafka message, event message, metadata, trace)
66 * with optional path for the trace context to be extracted.
67 * @param carrier any kind of message or other object with keys of type String.
68 * @param extractOptions type and path of the carrier. Type is not implemented yet. Path is the path to the trace context.
69 */
70 static extractContextFromMessage(carrier: {
71 [key: string]: any;
72 }, extractOptions?: ContextOptions): TypeSpanContext;
73 static extractContextFromHttpRequest(request: {
74 [key: string]: any;
75 }, type?: HttpRequestOptions): TypeSpanContext | undefined;
76}
77export { Tracer };