mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-02 08:52:21 +02:00
use function instead of global var (#36)
* use function instead of global var * fix lack return
This commit is contained in:
parent
252c6b5502
commit
a606839692
@ -35,10 +35,6 @@ type Map interface {
|
||||
|
||||
type Option func(*registeredKey)
|
||||
|
||||
var (
|
||||
EmptyMap = NewMap(core.KeyValue{}, nil, core.Mutator{}, nil)
|
||||
)
|
||||
|
||||
func New(name string, opts ...Option) core.Key { // TODO rename NewKey?
|
||||
return register(name, opts)
|
||||
}
|
||||
@ -49,6 +45,11 @@ func NewMeasure(name string, opts ...Option) core.Measure {
|
||||
}
|
||||
}
|
||||
|
||||
func NewEmptyMap() Map {
|
||||
var t tagMap
|
||||
return t.Apply(core.KeyValue{}, nil, core.Mutator{}, nil)
|
||||
}
|
||||
|
||||
func NewMap(a1 core.KeyValue, attributes []core.KeyValue, m1 core.Mutator, mutators []core.Mutator) Map {
|
||||
var t tagMap
|
||||
return t.Apply(a1, attributes, m1, mutators)
|
||||
|
@ -126,8 +126,8 @@ func (ro *readerObserver) Observe(event observer.Event) {
|
||||
read := Event{
|
||||
Time: event.Time,
|
||||
Sequence: event.Sequence,
|
||||
Attributes: tag.EmptyMap,
|
||||
Tags: tag.EmptyMap,
|
||||
Attributes: tag.NewEmptyMap(),
|
||||
Tags: tag.NewEmptyMap(),
|
||||
}
|
||||
|
||||
if event.Context != nil {
|
||||
@ -201,7 +201,7 @@ func (ro *readerObserver) Observe(event observer.Event) {
|
||||
sid = event.Scope
|
||||
}
|
||||
if sid.EventID == 0 {
|
||||
m = tag.EmptyMap
|
||||
m = tag.NewEmptyMap()
|
||||
} else {
|
||||
parentI, has := ro.scopes.Load(sid.EventID)
|
||||
if !has {
|
||||
@ -316,7 +316,7 @@ func (ro *readerObserver) addMeasurement(e *Event, m core.Measurement) {
|
||||
|
||||
func (ro *readerObserver) readScope(id core.ScopeID) (tag.Map, *readerSpan) {
|
||||
if id.EventID == 0 {
|
||||
return tag.EmptyMap, nil
|
||||
return tag.NewEmptyMap(), nil
|
||||
}
|
||||
ev, has := ro.scopes.Load(id.EventID)
|
||||
if !has {
|
||||
@ -327,7 +327,7 @@ func (ro *readerObserver) readScope(id core.ScopeID) (tag.Map, *readerSpan) {
|
||||
} else if sp, ok := ev.(*readerSpan); ok {
|
||||
return sp.attributes, sp
|
||||
}
|
||||
return tag.EmptyMap, nil
|
||||
return tag.NewEmptyMap(), nil
|
||||
}
|
||||
|
||||
func (ro *readerObserver) cleanupSpan(id core.EventID) {
|
||||
|
Loading…
Reference in New Issue
Block a user