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
Krzesimir Nowak 3fc6025071 Allow setting the name of the span after starting it (#102)
* Allow setting the name of the span after starting it

* Add test for setting the name of the span
2019-08-26 11:53:12 -07:00

86 lines
2.0 KiB
Go

// 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"
"go.opentelemetry.io/api/core"
"go.opentelemetry.io/api/event"
"go.opentelemetry.io/api/tag"
)
type NoopSpan struct {
}
var _ Span = (*NoopSpan)(nil)
// SpancContext returns an invalid span context.
func (NoopSpan) SpanContext() core.SpanContext {
return core.EmptySpanContext()
}
// IsRecordingEvents always returns false for NoopSpan.
func (NoopSpan) IsRecordingEvents() bool {
return false
}
// SetStatus does nothing.
func (NoopSpan) SetStatus(status codes.Code) {
}
// SetError does nothing.
func (NoopSpan) SetError(v bool) {
}
// SetAttribute does nothing.
func (NoopSpan) SetAttribute(attribute core.KeyValue) {
}
// SetAttributes does nothing.
func (NoopSpan) SetAttributes(attributes ...core.KeyValue) {
}
// ModifyAttribute does nothing.
func (NoopSpan) ModifyAttribute(mutator tag.Mutator) {
}
// ModifyAttributes does nothing.
func (NoopSpan) ModifyAttributes(mutators ...tag.Mutator) {
}
// Finish does nothing.
func (NoopSpan) Finish() {
}
// Tracer returns noop implementation of Tracer.
func (NoopSpan) Tracer() Tracer {
return NoopTracer{}
}
// AddEvent does nothing.
func (NoopSpan) AddEvent(ctx context.Context, event event.Event) {
}
// Event does nothing.
func (NoopSpan) Event(ctx context.Context, msg string, attrs ...core.KeyValue) {
}
// SetName does nothing.
func (NoopSpan) SetName(name string) {
}