-
-
Notifications
You must be signed in to change notification settings - Fork 223
/
sentry_span_context.dart
68 lines (58 loc) · 1.71 KB
/
sentry_span_context.dart
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
import 'package:meta/meta.dart';
import '../sentry.dart';
@immutable
class SentrySpanContext {
/// Determines which trace the Span belongs to
late final SentryId traceId;
/// Span id
late final SpanId spanId;
/// Id of a parent span
final SpanId? parentSpanId;
/// Short code identifying the type of operation the span is measuring
final String operation;
/// Longer description of the span's operation, which uniquely identifies the span but is
/// consistent across instances of the span.
final String? description;
/// The origin of the span indicates what created the span.
///
/// Gets set by the SDK. It is not expected to be set manually by users.
///
/// See https://develop.sentry.dev/sdk/performance/trace-origin
final String? origin;
/// Item encoded as JSON
Map<String, dynamic> toJson() {
return {
'span_id': spanId.toString(),
'trace_id': traceId.toString(),
'op': operation,
if (parentSpanId != null) 'parent_span_id': parentSpanId.toString(),
if (description != null) 'description': description,
if (origin != null) 'origin': origin,
};
}
SentrySpanContext({
SentryId? traceId,
SpanId? spanId,
this.parentSpanId,
required this.operation,
this.description,
this.origin,
}) : traceId = traceId ?? SentryId.newId(),
spanId = spanId ?? SpanId.newId();
@internal
SentryTraceContext toTraceContext({
bool? sampled,
SpanStatus? status,
}) {
return SentryTraceContext(
operation: operation,
traceId: traceId,
spanId: spanId,
description: description,
parentSpanId: parentSpanId,
sampled: sampled,
status: status,
origin: origin,
);
}
}