mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-03-31 21:55:32 +02:00
add SetAttribute(string,interface{}) (#674)
This commit is contained in:
parent
3809f7bba3
commit
ee30252752
@ -121,6 +121,9 @@ type Span interface {
|
||||
|
||||
// Set span attributes
|
||||
SetAttributes(...core.KeyValue)
|
||||
|
||||
// Set singular span attribute, with type inference.
|
||||
SetAttribute(string, interface{})
|
||||
}
|
||||
|
||||
// StartOption applies changes to StartConfig that sets options at span start time.
|
||||
|
@ -97,6 +97,10 @@ func (mockSpan) SetError(v bool) {
|
||||
func (mockSpan) SetAttributes(attributes ...core.KeyValue) {
|
||||
}
|
||||
|
||||
// SetAttribute does nothing.
|
||||
func (mockSpan) SetAttribute(k string, v interface{}) {
|
||||
}
|
||||
|
||||
// End does nothing.
|
||||
func (mockSpan) End(options ...trace.EndOption) {
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ func (NoopSpan) SetError(v bool) {
|
||||
func (NoopSpan) SetAttributes(attributes ...core.KeyValue) {
|
||||
}
|
||||
|
||||
// SetAttribute does nothing.
|
||||
func (NoopSpan) SetAttribute(k string, v interface{}) {
|
||||
}
|
||||
|
||||
// End does nothing.
|
||||
func (NoopSpan) End(options ...EndOption) {
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
"go.opentelemetry.io/otel/api/core"
|
||||
"go.opentelemetry.io/otel/api/key"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
)
|
||||
|
||||
@ -177,6 +178,10 @@ func (s *Span) SetAttributes(attrs ...core.KeyValue) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Span) SetAttribute(k string, v interface{}) {
|
||||
s.SetAttributes(key.Infer(k, v))
|
||||
}
|
||||
|
||||
// Name returns the name most recently set on the Span, either at or after creation time.
|
||||
// It cannot be change after End has been called on the Span.
|
||||
func (s *Span) Name() string {
|
||||
|
@ -239,6 +239,10 @@ func (s *MockSpan) SetAttributes(attributes ...otelcore.KeyValue) {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *MockSpan) SetAttribute(k string, v interface{}) {
|
||||
s.SetAttributes(otelkey.Infer(k, v))
|
||||
}
|
||||
|
||||
func (s *MockSpan) applyUpdate(update otelcorrelation.MapUpdate) {
|
||||
s.Attributes = s.Attributes.Apply(update)
|
||||
}
|
||||
|
@ -59,6 +59,10 @@ func (ms *MockSpan) SetError(v bool) {
|
||||
func (ms *MockSpan) SetAttributes(attributes ...core.KeyValue) {
|
||||
}
|
||||
|
||||
// SetAttribute does nothing.
|
||||
func (ms *MockSpan) SetAttribute(k string, v interface{}) {
|
||||
}
|
||||
|
||||
// End does nothing.
|
||||
func (ms *MockSpan) End(options ...apitrace.EndOption) {
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
"go.opentelemetry.io/otel/api/core"
|
||||
"go.opentelemetry.io/otel/api/key"
|
||||
apitrace "go.opentelemetry.io/otel/api/trace"
|
||||
export "go.opentelemetry.io/otel/sdk/export/trace"
|
||||
"go.opentelemetry.io/otel/sdk/internal"
|
||||
@ -100,6 +101,10 @@ func (s *span) SetAttributes(attributes ...core.KeyValue) {
|
||||
s.copyToCappedAttributes(attributes...)
|
||||
}
|
||||
|
||||
func (s *span) SetAttribute(k string, v interface{}) {
|
||||
s.SetAttributes(key.Infer(k, v))
|
||||
}
|
||||
|
||||
func (s *span) End(options ...apitrace.EndOption) {
|
||||
if s == nil {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user