Skip to content

Add attribute.Any() to simplify dynamic attribute construction #6787

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

Open
ch0s1n opened this issue May 16, 2025 · 1 comment
Open

Add attribute.Any() to simplify dynamic attribute construction #6787

ch0s1n opened this issue May 16, 2025 · 1 comment
Labels
enhancement New feature or request pkg:attribute Related to the attribute package

Comments

@ch0s1n
Copy link

ch0s1n commented May 16, 2025

Problem Statement

I'm often frustrated when I need to convert dynamic or mixed-type data (e.g. from map[string]interface{} or JSON payloads) into OpenTelemetry attributes. The current API only provides type-specific constructors such as attribute.String(), attribute.Int(), and so on, which requires repetitive and verbose type-switching logic in user code.

This makes it inconvenient to handle arbitrary structured data in a generic way, especially when building spans programmatically from logs, requests, or metadata.

@ch0s1n ch0s1n added the enhancement New feature or request label May 16, 2025
@pellared
Copy link
Member

I am against this proposal because of there would be breaking behavioral change if the specification would add new type to https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/common#attribute (e.g. open-telemetry/opentelemetry-specification#4485)

which requires repetitive and verbose type-switching logic in user code

One can always create a reusable function himself.

@pellared pellared added the pkg:attribute Related to the attribute package label May 19, 2025
@pellared pellared closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2025
@pellared pellared reopened this May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg:attribute Related to the attribute package
Projects
None yet
Development

No branches or pull requests

2 participants