-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtrace.service.ts
53 lines (46 loc) · 1.47 KB
/
trace.service.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
import { Attributes, Context, Span, SpanOptions, Tracer } from '@opentelemetry/api'
export const TraceService = Symbol('TraceService')
/**
* OpenTelemetry Trace/Span Name Conventions
*
* Format: `<operation_type>.<entity>.<action>`
*
* Common Operation Types:
* - http: Web operations
* - db: Database operations
* - rpc: Remote procedure calls
* - messaging: Queue/pub-sub operations
* - process: Business logic/processing
*
* Examples:
* - http.server.request
* - db.query.execute
* - process.payment.validate
* - auth.user.login
* - file.document.upload
* - cache.item.get
*
* Rules:
* - Use dot.case notation
* - Be specific but not overly granular
* - Operation type should come first
* - Action verb should be last
* - Keep names stable/consistent
*
* @see https://opentelemetry.io/docs/specs/semconv/general/trace
*/
export interface TraceService {
getTracer(): Tracer
getSpan(context: Context): Span | undefined
getActiveSpan(): Span | undefined
startSpan(name: string, options?: SpanOptions, context?: Context): Span
startActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, fn: F): ReturnType<F>
startActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, options: SpanOptions, fn: F): ReturnType<F>
startActiveSpan<F extends (span: Span) => ReturnType<F>>(
name: string,
options: SpanOptions,
context: Context,
fn: F
): ReturnType<F>
setAttributesOnActiveSpan(attributes: Attributes): Span | undefined
}