Skip to content

[otel] Bugs when handling attributes #2803

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

Closed
sk- opened this issue Nov 17, 2023 · 2 comments
Closed

[otel] Bugs when handling attributes #2803

sk- opened this issue Nov 17, 2023 · 2 comments
Labels

Comments

@sk-
Copy link

sk- commented Nov 17, 2023

Expected Behavior

I was reviewing the source code of the OpenTelemetry hooks and found two possible bugs related to how the attributes are being handled.

The first one is that every time a new node is detected, then we attach the pool name to the list of attributes

conf.attrs = append(conf.attrs, attribute.String("pool.name", conf.poolName))

The second bug happens in the function reportPoolStats

labels := conf.attrs
idleAttrs := append(labels, attribute.String("state", "idle"))
usedAttrs := append(labels, attribute.String("state", "used"))

In this case depending on whether the initial labels slice has enough capacity we could get unexpected results, as the code it's not copying the values into a new slice.

See for example this code in the playground that shows the bug https://go.dev/play/p/XBHgyYioH4s

Or check this code in the same file, which correctly handles the attributes

attrs := make([]attribute.KeyValue, 0, len(mh.attrs)+2)
attrs = append(attrs, mh.attrs...)
attrs = append(attrs, attribute.String("type", "command"))
attrs = append(attrs, statusAttr(err))

Copy link

This issue is marked stale. It will be closed in 30 days if it is not updated.

@github-actions github-actions bot added the Stale label Mar 23, 2025
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2025
@sk-
Copy link
Author

sk- commented Apr 24, 2025

Could this be please reopened? Also, could you confirm whether the otel pacakge is still being supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant