Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/inframetadata] Improve warning when host-identifying attributes are missing #314

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Apr 2, 2024

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:

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

@mx-psi mx-psi marked this pull request as ready for review April 2, 2024 12:58
@mx-psi mx-psi requested a review from a team as a code owner April 2, 2024 12:58
@mx-psi mx-psi requested a review from liustanley April 2, 2024 12:58
@mx-psi mx-psi merged commit ba4072f into main Apr 2, 2024
7 checks passed
@mx-psi mx-psi deleted the mx-psi/improve-warning branch April 2, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants