2020-03-23 22:41:10 -07:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-06-26 22:03:09 -07:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package trace
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-09-25 08:12:22 +02:00
|
|
|
"time"
|
2019-06-26 22:03:09 -07:00
|
|
|
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
|
2019-11-01 11:40:29 -07:00
|
|
|
"go.opentelemetry.io/otel/api/core"
|
2019-06-26 22:03:09 -07:00
|
|
|
)
|
|
|
|
|
2019-08-13 16:03:41 -07:00
|
|
|
type NoopSpan struct {
|
2019-06-28 13:59:13 +08:00
|
|
|
}
|
|
|
|
|
2019-08-13 16:03:41 -07:00
|
|
|
var _ Span = (*NoopSpan)(nil)
|
2019-06-26 22:03:09 -07:00
|
|
|
|
2020-01-03 18:38:05 +01:00
|
|
|
// SpanContext returns an invalid span context.
|
2020-05-02 20:17:11 +08:00
|
|
|
func (NoopSpan) SpanContext() SpanContext {
|
|
|
|
return EmptySpanContext()
|
2019-06-26 22:03:09 -07:00
|
|
|
}
|
|
|
|
|
2019-10-10 18:07:35 -07:00
|
|
|
// IsRecording always returns false for NoopSpan.
|
|
|
|
func (NoopSpan) IsRecording() bool {
|
2019-06-26 22:03:09 -07:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetStatus does nothing.
|
2020-03-07 10:38:59 -08:00
|
|
|
func (NoopSpan) SetStatus(status codes.Code, msg string) {
|
2019-06-26 22:03:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetError does nothing.
|
2019-08-13 16:03:41 -07:00
|
|
|
func (NoopSpan) SetError(v bool) {
|
2019-06-26 22:03:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetAttributes does nothing.
|
2019-08-13 16:03:41 -07:00
|
|
|
func (NoopSpan) SetAttributes(attributes ...core.KeyValue) {
|
2019-06-26 22:03:09 -07:00
|
|
|
}
|
|
|
|
|
2020-04-28 17:24:47 -04:00
|
|
|
// SetAttribute does nothing.
|
|
|
|
func (NoopSpan) SetAttribute(k string, v interface{}) {
|
|
|
|
}
|
|
|
|
|
2019-09-27 10:48:10 -07:00
|
|
|
// End does nothing.
|
|
|
|
func (NoopSpan) End(options ...EndOption) {
|
2019-06-26 22:03:09 -07:00
|
|
|
}
|
|
|
|
|
2020-02-28 16:44:53 -05:00
|
|
|
// RecordError does nothing.
|
|
|
|
func (NoopSpan) RecordError(ctx context.Context, err error, opts ...ErrorOption) {
|
|
|
|
}
|
|
|
|
|
2019-06-26 22:03:09 -07:00
|
|
|
// Tracer returns noop implementation of Tracer.
|
2019-08-13 16:03:41 -07:00
|
|
|
func (NoopSpan) Tracer() Tracer {
|
|
|
|
return NoopTracer{}
|
2019-06-26 22:03:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddEvent does nothing.
|
2019-12-19 02:13:05 +08:00
|
|
|
func (NoopSpan) AddEvent(ctx context.Context, name string, attrs ...core.KeyValue) {
|
2019-06-26 22:03:09 -07:00
|
|
|
}
|
2019-08-26 20:53:12 +02:00
|
|
|
|
2019-09-25 08:12:22 +02:00
|
|
|
// AddEventWithTimestamp does nothing.
|
2019-12-19 02:13:05 +08:00
|
|
|
func (NoopSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...core.KeyValue) {
|
2019-09-25 08:12:22 +02:00
|
|
|
}
|
|
|
|
|
2019-08-26 20:53:12 +02:00
|
|
|
// SetName does nothing.
|
|
|
|
func (NoopSpan) SetName(name string) {
|
2019-11-28 08:20:34 +01:00
|
|
|
}
|