1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-27 22:49:15 +02:00

Remove the distributedctx.Mutator (#252)

* Remove the distributedctx.Mutator

* Remove unused field

* Update examples
This commit is contained in:
Joshua MacDonald
2019-10-30 13:21:13 -07:00
committed by GitHub
parent 25e97e56a4
commit de6715fca3
14 changed files with 28 additions and 244 deletions

View File

@@ -18,13 +18,8 @@ import (
"go.opentelemetry.io/api/core"
)
type MeasureMetadata struct {
TTL int // -1 == infinite, 0 == do not propagate
}
type entry struct {
value core.Value
meta MeasureMetadata
}
type rawMap map[core.Key]entry
@@ -34,10 +29,8 @@ type Map struct {
}
type MapUpdate struct {
SingleKV core.KeyValue
MultiKV []core.KeyValue
SingleMutator Mutator
MultiMutator []Mutator
SingleKV core.KeyValue
MultiKV []core.KeyValue
}
func newMap(raw rawMap) Map {
@@ -55,7 +48,7 @@ func NewMap(update MapUpdate) Map {
}
func (m Map) Apply(update MapUpdate) Map {
r := make(rawMap, len(m.m)+len(update.MultiKV)+len(update.MultiMutator))
r := make(rawMap, len(m.m)+len(update.MultiKV))
for k, v := range m.m {
r[k] = v
}
@@ -69,12 +62,6 @@ func (m Map) Apply(update MapUpdate) Map {
value: kv.Value,
}
}
if update.SingleMutator.Key.Defined() {
r.apply(update.SingleMutator)
}
for _, mutator := range update.MultiMutator {
r.apply(mutator)
}
if len(r) == 0 {
r = nil
}
@@ -108,25 +95,3 @@ func (m Map) Foreach(f func(kv core.KeyValue) bool) {
}
}
}
func (r rawMap) apply(mutator Mutator) {
key := mutator.KeyValue.Key
content := entry{
value: mutator.KeyValue.Value,
meta: mutator.MeasureMetadata,
}
switch mutator.MutatorOp {
case INSERT:
if _, ok := r[key]; !ok {
r[key] = content
}
case UPDATE:
if _, ok := r[key]; ok {
r[key] = content
}
case UPSERT:
r[key] = content
case DELETE:
delete(r, key)
}
}