Joey Armstrong | 5f51f2e | 2023-01-17 17:06:26 -0500 | [diff] [blame] | 1 | // 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 | |
| 15 | package trace |
| 16 | |
| 17 | import ( |
| 18 | "context" |
| 19 | "time" |
| 20 | |
| 21 | "go.opentelemetry.io/otel/codes" |
| 22 | "go.opentelemetry.io/otel/label" |
| 23 | ) |
| 24 | |
| 25 | type noopSpan struct { |
| 26 | } |
| 27 | |
| 28 | var _ Span = noopSpan{} |
| 29 | |
| 30 | // SpanContext returns an invalid span context. |
| 31 | func (noopSpan) SpanContext() SpanContext { |
| 32 | return EmptySpanContext() |
| 33 | } |
| 34 | |
| 35 | // IsRecording always returns false for NoopSpan. |
| 36 | func (noopSpan) IsRecording() bool { |
| 37 | return false |
| 38 | } |
| 39 | |
| 40 | // SetStatus does nothing. |
| 41 | func (noopSpan) SetStatus(status codes.Code, msg string) { |
| 42 | } |
| 43 | |
| 44 | // SetError does nothing. |
| 45 | func (noopSpan) SetError(v bool) { |
| 46 | } |
| 47 | |
| 48 | // SetAttributes does nothing. |
| 49 | func (noopSpan) SetAttributes(attributes ...label.KeyValue) { |
| 50 | } |
| 51 | |
| 52 | // End does nothing. |
| 53 | func (noopSpan) End(options ...SpanOption) { |
| 54 | } |
| 55 | |
| 56 | // RecordError does nothing. |
| 57 | func (noopSpan) RecordError(ctx context.Context, err error, opts ...ErrorOption) { |
| 58 | } |
| 59 | |
| 60 | // Tracer returns noop implementation of Tracer. |
| 61 | func (noopSpan) Tracer() Tracer { |
| 62 | return noopTracer{} |
| 63 | } |
| 64 | |
| 65 | // AddEvent does nothing. |
| 66 | func (noopSpan) AddEvent(ctx context.Context, name string, attrs ...label.KeyValue) { |
| 67 | } |
| 68 | |
| 69 | // AddEventWithTimestamp does nothing. |
| 70 | func (noopSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue) { |
| 71 | } |
| 72 | |
| 73 | // SetName does nothing. |
| 74 | func (noopSpan) SetName(name string) { |
| 75 | } |