1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00
opentelemetry-go/api/trace/noop_span.go

94 lines
2.3 KiB
Go
Raw Normal View History

// Copyright 2019, OpenTelemetry Authors
//
// 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"
"google.golang.org/grpc/codes"
"github.com/open-telemetry/opentelemetry-go/api/core"
"github.com/open-telemetry/opentelemetry-go/api/event"
2019-07-01 21:11:24 +02:00
"github.com/open-telemetry/opentelemetry-go/api/scope"
"github.com/open-telemetry/opentelemetry-go/api/stats"
)
2019-06-28 07:59:13 +02:00
type noopSpan struct {
}
var _ Span = (*noopSpan)(nil)
2019-07-01 21:11:24 +02:00
var _ stats.Interface = (*noopSpan)(nil)
var _ scope.Mutable = (*noopSpan)(nil)
// SpancContext returns an invalid span context.
func (sp *noopSpan) SpanContext() core.SpanContext {
return core.INVALID_SPAN_CONTEXT
}
// IsRecordingEvents always returns false for noopSpan.
func (sp *noopSpan) IsRecordingEvents() bool {
return false
}
// SetStatus does nothing.
func (sp *noopSpan) SetStatus(status codes.Code) {
}
// ScopeID returns and empty ScopeID.
func (sp *noopSpan) ScopeID() core.ScopeID {
return core.ScopeID{}
}
// SetError does nothing.
func (sp *noopSpan) SetError(v bool) {
}
// SetAttribute does nothing.
func (sp *noopSpan) SetAttribute(attribute core.KeyValue) {
}
// SetAttributes does nothing.
func (sp *noopSpan) SetAttributes(attributes ...core.KeyValue) {
}
// ModifyAttribute does nothing.
func (sp *noopSpan) ModifyAttribute(mutator core.Mutator) {
}
// ModifyAttributes does nothing.
func (sp *noopSpan) ModifyAttributes(mutators ...core.Mutator) {
}
// Finish does nothing.
func (sp *noopSpan) Finish() {
}
// Tracer returns noop implementation of Tracer.
func (sp *noopSpan) Tracer() Tracer {
return nt
}
// AddEvent does nothing.
func (sp *noopSpan) AddEvent(ctx context.Context, event event.Event) {
}
// Record does nothing.
func (sp *noopSpan) Record(ctx context.Context, m ...core.Measurement) {
}
// RecordSingle does nothing.
func (sp *noopSpan) RecordSingle(ctx context.Context, m core.Measurement) {
}