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

global::tracer dynamic naming #666

Closed
Wolftousen opened this issue Nov 10, 2021 · 1 comment · Fixed by #670
Closed

global::tracer dynamic naming #666

Wolftousen opened this issue Nov 10, 2021 · 1 comment · Fixed by #670
Labels
enhancement New feature or request

Comments

@Wolftousen
Copy link

Wolftousen commented Nov 10, 2021

I have a scenario where I would like to use a name for my Tracers that is not known at compile time.

Currently the only way to do that, due to the usage of &'static str for name and version, is to cause a memory leak with something like

let s = String::from("some id");
let trace = global::tracer(format!("id-{}", Box::leak(s.into_boxed_str())));

I did try to go down the rabbit hole of switching out &'static str for Cow<'static, str> or String, but found that the InstrumentationLibrary requires the Copy trait, which neither Cow nor String implement. Removing the Copy trait causes the downstream effect of the inability to move an instance of InstrumentationLibrary on this line (and similar):
instrumentation_lib: *tracer.instrumentation_library(),

Could this be switched to a clone instead of dereference/move so that the rest of the InstrumentationLibrary struct can be more friendly?

@TommyCpp
Copy link
Contributor

Sounds reasonable 👍 Will try to have a PR for this over the weekend

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

Successfully merging a pull request may close this issue.

2 participants