-
Notifications
You must be signed in to change notification settings - Fork 35
/
nonrecording_span.dart
69 lines (49 loc) · 1.79 KB
/
nonrecording_span.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
69
// Copyright 2021-2022 Workiva.
// Licensed under the Apache License, Version 2.0. Please see https://github.com/Workiva/opentelemetry-dart/blob/master/LICENSE for more information
import 'package:fixnum/fixnum.dart';
import '../../../api.dart' as api;
/// A class representing a [api.Span] which should not be sampled or recorded.
///
/// See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#wrapping-a-spancontext-in-a-span
/// for more information.
///
/// This class should not be exposed to consumers and is used internally to wrap
/// [api.SpanContext] being injected or extracted for external calls.
class NonRecordingSpan implements api.Span {
final api.SpanStatus _status = api.SpanStatus()..code = api.StatusCode.ok;
final api.SpanContext _spanContext;
NonRecordingSpan(this._spanContext);
@override
void setAttribute(api.Attribute attribute) {}
@override
void setAttributes(List<api.Attribute> attributes) {}
@override
void end() {}
@override
Int64 get endTime => null;
@override
String get name => 'NON_RECORDING';
@override
set name(String _name) {}
@override
bool get isRecording => false;
@override
api.SpanId get parentSpanId => api.SpanId.invalid();
@override
void setStatus(api.StatusCode status, {String description}) {}
@override
api.SpanContext get spanContext => _spanContext;
@override
Int64 get startTime => null;
@override
api.SpanStatus get status => _status;
@override
api.InstrumentationLibrary get instrumentationLibrary => null;
@override
void recordException(dynamic exception, {StackTrace stackTrace}) {}
@override
void addEvent(String name, Int64 timestamp,
{List<api.Attribute> attributes}) {}
@override
api.SpanKind get kind => api.SpanKind.internal;
}