@zerotal/telemetry 1.6.2 → 1.7.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.
- package/api-surface.md +159 -0
- package/package.json +3 -2
package/api-surface.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# @zerotal/telemetry — public API surface
|
|
2
|
+
|
|
3
|
+
<!-- AUTO-GENERATED by scripts/api-surface.ts. Do not edit by hand.
|
|
4
|
+
Run `bun run api:surface` to regenerate after an intentional API change. -->
|
|
5
|
+
|
|
6
|
+
## . `(./src/index.ts)`
|
|
7
|
+
|
|
8
|
+
class ConsoleExporter = {
|
|
9
|
+
new (): ConsoleExporter
|
|
10
|
+
export: (span: SpanData) => Promise<void>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class NoopExporter = {
|
|
14
|
+
new (): NoopExporter
|
|
15
|
+
export: (_span: SpanData) => Promise<void>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class NoopSpan = {
|
|
19
|
+
new (): NoopSpan
|
|
20
|
+
addEvent: (_name: string, _attributes?: Record<string, unknown>) => NoopSpan
|
|
21
|
+
durationMs: number
|
|
22
|
+
end: () => void
|
|
23
|
+
isEnded: boolean
|
|
24
|
+
readonly data: SpanData
|
|
25
|
+
recordException: (_error: Error) => NoopSpan
|
|
26
|
+
setAttribute: (_key: string, _value: string | number | boolean) => NoopSpan
|
|
27
|
+
setAttributes: (_attrs: Record<string, string | number | boolean>) => NoopSpan
|
|
28
|
+
setStatus: (_code: 'ok' | 'error', _message?: string) => NoopSpan
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class OtlpExporter = {
|
|
32
|
+
new (options?: OtlpExporterOptions): OtlpExporter
|
|
33
|
+
export: (span: SpanData) => Promise<void>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class Span = {
|
|
37
|
+
new (name: string, parentId?: string, traceId?: string, kind?: SpanKind): Span
|
|
38
|
+
addEvent: (name: string, attributes?: Record<string, unknown>) => Span
|
|
39
|
+
durationMs: number
|
|
40
|
+
end: () => void
|
|
41
|
+
isEnded: boolean
|
|
42
|
+
readonly data: SpanData
|
|
43
|
+
recordException: (error: Error) => Span
|
|
44
|
+
setAttribute: (key: string, value: string | number | boolean) => Span
|
|
45
|
+
setAttributes: (attrs: Record<string, string | number | boolean>) => Span
|
|
46
|
+
setStatus: (code: 'ok' | 'error', message?: string) => Span
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class TelemetryMiddleware = {
|
|
50
|
+
new (): TelemetryMiddleware
|
|
51
|
+
static with: <T extends new (...args: any[]) => BaseMiddleware<any>, Opts = T extends new (...args: any[]) => BaseMiddleware<infer U> ? U : object>(this: T, options: DeepPartial<NoInfer<Opts>>) => new () => InstanceType<T>
|
|
52
|
+
afterResponse?: (ctx: HttpContext) => Promise<void>
|
|
53
|
+
handle: (http: HttpContext, next: NextFn) => Promise<Response | void>
|
|
54
|
+
onError?: (ctx: HttpContext, error: Error) => Promise<void>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class TelemetryProvider = {
|
|
58
|
+
new (app: Application): TelemetryProvider
|
|
59
|
+
static dependsOn?: (new (app: Application) => ServiceProvider)[]
|
|
60
|
+
static environments: AppEnvironment[]
|
|
61
|
+
static priority?: number
|
|
62
|
+
static provides: readonly ['telemetry']
|
|
63
|
+
devProcesses: () => DevProcessDefinition[]
|
|
64
|
+
doctorChecks: () => DoctorCheck[]
|
|
65
|
+
onBooted: () => Promise<void>
|
|
66
|
+
onBooting: () => Promise<void>
|
|
67
|
+
onRegister: () => void
|
|
68
|
+
onRequestProcessed: (_ctx: HttpContext) => Promise<void>
|
|
69
|
+
onRequestReceived: (_ctx: HttpContext) => Promise<void>
|
|
70
|
+
onResponseSent: (_ctx: HttpContext) => Promise<void>
|
|
71
|
+
onStarted: () => Promise<void>
|
|
72
|
+
onStarting: () => Promise<void>
|
|
73
|
+
onStopped: () => Promise<void>
|
|
74
|
+
onStopping: () => Promise<void>
|
|
75
|
+
replContext: () => Record<string, unknown>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class Tracer = {
|
|
79
|
+
new (options: TracerOptions): Tracer
|
|
80
|
+
recordCompleted: (name: string, durationMs: number, options?: SpanOptions & { status?: 'ok' | 'error'; errorMessage?: string;}) => Promise<void>
|
|
81
|
+
shutdown: () => Promise<void>
|
|
82
|
+
startSpan: (name: string, options?: SpanOptions) => Span
|
|
83
|
+
withSpan: <T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions) => Promise<T>
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const SpanContext = AsyncLocalStorage<ActiveContext>
|
|
87
|
+
|
|
88
|
+
function _randomHex = (bytes: number) => string
|
|
89
|
+
|
|
90
|
+
function currentSpan = () => Span | undefined
|
|
91
|
+
|
|
92
|
+
function installEventBridge = (tracer: Tracer) => () => void
|
|
93
|
+
|
|
94
|
+
function TelemetryConfig = (options?: Partial<TelemetryConfigShape>) => TelemetryConfigShape
|
|
95
|
+
|
|
96
|
+
function withSpan = <T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions) => Promise<T>
|
|
97
|
+
|
|
98
|
+
interface OtlpExporterOptions = {
|
|
99
|
+
endpoint?: string
|
|
100
|
+
headers?: Record<string, string>
|
|
101
|
+
serviceName?: string
|
|
102
|
+
serviceVersion?: string
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface SpanData = {
|
|
106
|
+
attributes: Record<string, string | number | boolean>
|
|
107
|
+
endMs: number | undefined
|
|
108
|
+
events: SpanEvent[]
|
|
109
|
+
kind: SpanKind
|
|
110
|
+
name: string
|
|
111
|
+
parentId: string | undefined
|
|
112
|
+
spanId: string
|
|
113
|
+
startMs: number
|
|
114
|
+
status: SpanStatus
|
|
115
|
+
traceId: string
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface SpanEvent = {
|
|
119
|
+
attributes?: Record<string, unknown>
|
|
120
|
+
name: string
|
|
121
|
+
timeMs: number
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface SpanExporter = {
|
|
125
|
+
export: (span: SpanData) => Promise<void>
|
|
126
|
+
shutdown?: () => Promise<void>
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface SpanOptions = {
|
|
130
|
+
attributes?: Record<string, string | number | boolean>
|
|
131
|
+
kind?: SpanKind
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface SpanStatus = {
|
|
135
|
+
code: SpanStatusCode
|
|
136
|
+
message?: string
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface TelemetryConfigShape = {
|
|
140
|
+
exporter?: 'console' | 'noop' | 'otlp'
|
|
141
|
+
minDurationMs?: number
|
|
142
|
+
otlp?: { endpoint?: string; headers?: Record<string, string>;}
|
|
143
|
+
serviceName?: string
|
|
144
|
+
serviceVersion?: string
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
interface TelemetryOptions = {
|
|
148
|
+
spanName?: (ctx: HttpContext) => string
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface TracerOptions = {
|
|
152
|
+
exporter: SpanExporter
|
|
153
|
+
minDurationMs?: number
|
|
154
|
+
rethrowExportErrors?: boolean
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type SpanKind = 'client' | 'internal' | 'server' | 'producer' | 'consumer'
|
|
158
|
+
|
|
159
|
+
type SpanStatusCode = 'error' | 'ok' | 'unset'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerotal/telemetry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"maturity": "stable",
|
|
6
6
|
"private": false,
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"CHANGELOG.md",
|
|
15
|
+
"api-surface.md",
|
|
15
16
|
"src",
|
|
16
17
|
"!src/**/*.test.ts",
|
|
17
18
|
"!src/**/*.test.tsx",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"typecheck": "tsc --noEmit"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@zerotal/core": "1.
|
|
33
|
+
"@zerotal/core": "1.7.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"typescript": "^5.8.0"
|