blob: f014f2106974ffe304c270d20de1eb74a9660864 [file] [log] [blame]
serkant.uluderyae5afeff2021-02-23 18:00:23 +03001// Copyright The OpenTelemetry Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package trace
16
17import (
18 "context"
19 "time"
20
21 "go.opentelemetry.io/otel/codes"
22 "go.opentelemetry.io/otel/label"
23)
24
25type noopSpan struct {
26}
27
28var _ Span = noopSpan{}
29
30// SpanContext returns an invalid span context.
31func (noopSpan) SpanContext() SpanContext {
32 return EmptySpanContext()
33}
34
35// IsRecording always returns false for NoopSpan.
36func (noopSpan) IsRecording() bool {
37 return false
38}
39
40// SetStatus does nothing.
41func (noopSpan) SetStatus(status codes.Code, msg string) {
42}
43
44// SetError does nothing.
45func (noopSpan) SetError(v bool) {
46}
47
48// SetAttributes does nothing.
49func (noopSpan) SetAttributes(attributes ...label.KeyValue) {
50}
51
52// End does nothing.
53func (noopSpan) End(options ...SpanOption) {
54}
55
56// RecordError does nothing.
57func (noopSpan) RecordError(ctx context.Context, err error, opts ...ErrorOption) {
58}
59
60// Tracer returns noop implementation of Tracer.
61func (noopSpan) Tracer() Tracer {
62 return noopTracer{}
63}
64
65// AddEvent does nothing.
66func (noopSpan) AddEvent(ctx context.Context, name string, attrs ...label.KeyValue) {
67}
68
69// AddEventWithTimestamp does nothing.
70func (noopSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue) {
71}
72
73// SetName does nothing.
74func (noopSpan) SetName(name string) {
75}