uptrace/uptrace-rust

Provide some way to flush metrics

vmihailenco opened this issue · 2 comments

We should flush pending metrics when the program exits:

    controller.stop(&cx)?; // send remaining metrics.

But we don't provide access to the underlying controller created by this package.

In Go, this is solved by providing a single shutdown function that shuts down both tracing and metrics:

import "github.com/uptrace/uptrace-go/uptrace"

	uptrace.ConfigureOpentelemetry(
		// copy your project DSN here or use UPTRACE_DSN env var
		// uptrace.WithDSN("https://<token>@uptrace.dev/<project_id>"),

		uptrace.WithServiceName("myservice"),
		uptrace.WithServiceVersion("1.0.0"),
	)
	// Send buffered spans and free resources.
	defer uptrace.Shutdown(ctx)

We probably should do the same in Rust, but I am not good enough with the language to do that myself... @bestgopher perhaps you could help with that at some point?

Maybe we can use Drop trait to achieve this goal, but I have no specific plan yet. Do you have a good idea?

Do you have a good idea?

Not really, I've just learned how to compile Rust code and not much besides that :)