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

Self-recursive debug implementations #550

Closed
tustvold opened this issue May 13, 2021 · 2 comments
Closed

Self-recursive debug implementations #550

tustvold opened this issue May 13, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@tustvold
Copy link
Contributor

tustvold commented May 13, 2021

I'm not sure how widespread this is, but if you try to debug print a prometheus sync instrument it leads to a stack overflow. Or if you debug print with {:#?} it effectively deadlocks trying to print an infinite string, I suspect you would get a stack overflow eventually if you left it for long enough.

The code snippet below demonstrates this problem, it overflows the stack

let exporter = opentelemetry_prometheus::exporter()
            .with_resource(Resource::new(vec![KeyValue::new("R", "V")]))
            .init();

let provider = exporter.provider().unwrap();
let meter = provider.meter("foo", None);
let counter = meter.f64_counter("test").init();
counter.add(23., &[KeyValue::new("foo", "bar")]);

println!("{:?}", counter);
@TommyCpp TommyCpp added the bug Something isn't working label May 14, 2021
@TommyCpp
Copy link
Contributor

Looks like the reason is Instrument refers to Accumulator, which contains references to AsyncInstrument. And AsyncInstrument also contains a reference to Instrument, creating a loop.

TommyCpp added a commit to TommyCpp/opentelemetry-rust that referenced this issue May 18, 2021
fixes open-telemetry#550. We choose to break the loop at instrument level because debug info on `Accumulator` can be found via other structs and descriptors seem to be more important for instruments.
@TommyCpp
Copy link
Contributor

close via #552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants