Closed mx-psi closed 3 months ago
Uses AsRaw for printing resource attributes and links reference page on mapping OTLP resource attributes to hostnames.
AsRaw
pcommon.Map doesn't have a very sensible formatting. With the following sample program:
pcommon.Map
package main import ( "go.opentelemetry.io/collector/pdata/pcommon" "go.uber.org/zap" ) func main() { logger := zap.NewExample() // or NewProduction, or NewDevelopment defer logger.Sync() m := pcommon.NewMap() if err := m.FromRaw(map[string]any{"key": "value"}); err != nil { panic(err) } logger.Info("Testing logging of pcommon.Map", zap.Any("map", m), zap.Any("raw map", m.AsRaw())) }
We can see the following output:
❯ go run main.go {"level":"info","msg":"Testing logging of pcommon.Map","map":{},"raw map":{"key":"value"}}
Where map is shown as empty, when it isn't. Casting to a map with AsRaw fixes the issue
map
What does this PR do?
Uses
AsRaw
for printing resource attributes and links reference page on mapping OTLP resource attributes to hostnames.Motivation
pcommon.Map
doesn't have a very sensible formatting. With the following sample program:We can see the following output:
Where
map
is shown as empty, when it isn't. Casting to a map withAsRaw
fixes the issue