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

[chore] Allow OTTL pdata Map setters to take raw map #38434

Merged

Conversation

TylerHelmuth
Copy link
Member

Description

To be consistent, we should try treating raw maps and pcommon.Map the same. Updates all the setters that were expecting a pcommon.Map to also allow a raw map to set the value

Testing

unit tests

@edmocosta
Copy link
Contributor

edmocosta commented Mar 6, 2025

We could maybe add a new function into the internal/ctxutil package for handling this common logic, E.g.:

func SetMap(target pcommon.Map, val any) error {
	if cm, ok := val.(pcommon.Map); ok {
		cm.CopyTo(target)
		return nil
	}
	if rm, ok := val.(map[string]any); ok {
		return target.FromRaw(rm)
	}
	return nil
}

@TylerHelmuth TylerHelmuth merged commit 14de63f into open-telemetry:main Mar 6, 2025
156 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants