Skip to content

[Feature]: Is there a way to remove useless metrics attributes? #1451

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
yunbo-xufeng opened this issue Dec 21, 2023 · 7 comments
Closed

[Feature]: Is there a way to remove useless metrics attributes? #1451

yunbo-xufeng opened this issue Dec 21, 2023 · 7 comments
Labels
enhancement New feature or request triage:todo Needs to be traiged.

Comments

@yunbo-xufeng
Copy link

yunbo-xufeng commented Dec 21, 2023

Related Problems?

I'm using rust opentelemetry_sdk 0.19.0,and dump some metrics to opentelemetry collector,and one more things, the metrics attributes are changing always in my scenario, so the memory usage is increasing, and lead to oom issue finally.
So is there any way to cleanup these unused metrics attributes?

Describe the solution you'd like:

In my project, I also use Prometheus to dump metrics, to resolve the above issue, Prometheus provides a remove_label_values() api, so this is not a issue for Prometheus, could Opentelemetry SDK also provides a similar API?

Considered Alternatives

No response

Additional Context

No response

@yunbo-xufeng yunbo-xufeng added enhancement New feature or request triage:todo Needs to be traiged. labels Dec 21, 2023
@cijothomas
Copy link
Member

OTel SDK offers a View concept which can be leveraged to drop unwanted metric attributes.
https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/metrics-advanced/src/main.rs#L24-L31

Another alternative is, if you control the code, you can simply chose to add only the required metric attributes. If you cannot control the code, then View is the right solution from the SDK. (OTel Collector has similar mechanisms as well, if you are running OTel Collector in your environment)

@lalitb
Copy link
Member

lalitb commented Dec 21, 2023

Curious, as we have the upper cardinality limit of 2000, the memory shouldn't be increasing continuously leading to OOM. What is the machine configuration? Eventually, we should be able to control the upper limit through Views (#1065). But as mentioned by @cijothomas, the right approach would be to filter the attributes through Views.

@cijothomas
Copy link
Member

The cardinality capping is in the newer version, definitely not in 0.19.0!

@lalitb
Copy link
Member

lalitb commented Dec 21, 2023

Ah, I overlooked the version

@yunbo-xufeng
Copy link
Author

OTel SDK offers a View concept which can be leveraged to drop unwanted metric attributes. https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/metrics-advanced/src/main.rs#L24-L31

Another alternative is, if you control the code, you can simply chose to add only the required metric attributes. If you cannot control the code, then View is the right solution from the SDK. (OTel Collector has similar mechanisms as well, if you are running OTel Collector in your environment)

Thanks for your reply!
I just checked the View feature, and found it can only filter attribute keys, not including the values?
Actually, in my scenario, the metrics keys are not changed, only the values in the attributes changed when I call:

fn observe(&self, cx: &Context, value: T, attributes: &[KeyValue])

Any solution to resolve this "attributes key is constant but value is changing" problem?

@yunbo-xufeng
Copy link
Author

Curious, as we have the upper cardinality limit of 2000, the memory shouldn't be increasing continuously leading to OOM. What is the machine configuration? Eventually, we should be able to control the upper limit through Views (#1065). But as mentioned by @cijothomas, the right approach would be to filter the attributes through Views.

Many thanks!
So the newer version OTel can resolve this memory problem implicitly by the cardinality limit?
My scenario is special: only the value changes, the key remains the same.

@cijothomas
Copy link
Member

The new SDK will impose cardinality limit, so SDK wont go OOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage:todo Needs to be traiged.
Projects
None yet
Development

No branches or pull requests

3 participants