[Feature Request] Improved support for passing compile time dynamic tracing event names to StaticString
- Dominant language
- C++
- Stars
- 6.5k
- Forks
- 868
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 218
Description
Hi there!
I don't expect any action, but just wanted to bubble up a feature I'm trying to build in my [perfetto integration for the JUCE C++ framework](https://github.com/sudara/melatonin_perfetto).
A DX/usability improvement I've been trying to provide are some friendlier macros that don't require manual labelling, they just use the current function name.
So instead of `TRACE_EVENT ("myCategory", "myFunctionName")` I pepper codebase with something like `TRACE_DSP()` with a compile-time derived function name and a fixed category ("dsp" in this case).
I was hoping to use `PERFETTO_DEBUG_FUNCTION_IDENTIFIER()` to grab the function identifier, but it's of course.... human-unfriendly and needs trimming.
Doing this at compile time turns out to be a bit annoying, and since it's no longer a literal, it makes `StaticString` complain:
```
error: static_assert failed due to requirement 'IsValidEventNameType::value' "Event names must be static strings. To use dynamic event names, see https://perfetto.dev/docs/instrumentation/track-events#dynamic-event-names"
```
My last effort was to wrap `PERFETTO_DEBUG_FUNCTION_IDENTIFIER()` [in a lambda so it can behave as a template parameter](https://github.com/sudara/melatonin_perfetto/issues/13#issuecomment-1426864054). This.... just about seems to work?
I'm not sure what my "ask" is here, just noting in case anyone has a suggestion, are doing similar things or have a solution that's less hacky. I'm not quite smart enough to know if there's a way for `StaticString` itself to be happier for my use case. The issue seems to be even though my logic is happily compile-time when run in isolation, it ends up running in a runtime context (or at least triggering the static_assert) when passing to `StaticString`.
Contributor guide
Assessment
This issue has not been assessed yet.