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

Thoughts on replacing mocks with telemetry events #48

Open
ruslandoga opened this issue Nov 27, 2024 · 0 comments
Open

Thoughts on replacing mocks with telemetry events #48

ruslandoga opened this issue Nov 27, 2024 · 0 comments

Comments

@ruslandoga
Copy link

ruslandoga commented Nov 27, 2024

👋

I had an idea a few days ago, what if FlameOn starts and stops tracing on Telemetry events? That would potentially allow removing mocks.

Since telemetry runs in the caller process, we have access to the current pid, and we can use the new :trace module with very minimal effort for flamegraphs (+ with heap alloc stats). Flamecharts (which is what FlameOn is doing now) would require extra effort. With :trace we can also cross process boundary and start tracing the processes that the current process "calls", right now FlameOn just shows sleep when something like GenServer.call is encountered.

The API could be just a telemetry event for which to start tracing, and an optional event for when to stop tracing.

ref = make_ref()
# or something like FlameTrace.trace_once([:phoenix, :endpoint, :start])
:telemetry.attach("trace-phx-on", [:phoenix, :endpoint, :start], &FlameOn.start_tracing/4, sample: 0.01, ref: ref)
:telemetry.detach("trace-phx-on")
FlameOn.svg(FlameOn.report(ref))

Context:

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

No branches or pull requests

1 participant