This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Bundle the converter. | |
Inspiration: https://github.com/python-poetry/poetry/pull/2682 | |
""" | |
from argparse import ArgumentParser | |
from contextlib import contextmanager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fn gl -> | |
:dbg.stop_clear() | |
repr = fn | |
%Phoenix.LiveView.Socket{} -> "socket" | |
v -> inspect(v) | |
end | |
{:ok, _} = | |
:dbg.tracer( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule LVCallTime do | |
@moduledoc """ | |
Best used sparingly. | |
LVCallTime.start() | |
:timer.sleep(:timer.seconds(20)) | |
LVCallTime.dump() | |
LVCallTime.stop() | |
or just |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:dbg.stop_clear() | |
{:ok, _} = | |
:dbg.tracer( | |
:process, | |
{fn | |
{:trace, pid, :call, {mod, fun, args} = call}, stacks -> | |
mfa = Exception.format_mfa(mod, fun, Enum.count(args)) |> Pretty.inspect(label: ":call") | |
Smuggle.dump({mod, fun, args}, wrapper: :gfm) | |
stack = Map.get(stacks, pid, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:ok, _} = | |
:dbg.tracer( | |
:process, | |
{fn | |
{:trace, pid, :call, {mod, fun, args} = call}, stacks -> | |
mfa = Exception.format_mfa(mod, fun, Enum.count(args)) | |
stack = Map.get(stacks, pid, []) | |
if match?({Phoenix.PubSub, :broadcast, _}, call) do | |
Pretty.inspect(stack, label: "broadcast stack") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Smuggle do | |
@moduledoc """ | |
Make it easier to smuggle data from one system to another. | |
If your target is an `iex` prompt: | |
Smuggle.dump(value) | |
# copy | |
# paste into other iex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PidSnitchFormatter do | |
@moduledoc """ | |
Report test PIDs? | |
```bash | |
mix test --formatter PidSnitchFormatter | |
``` | |
See `ExUnit.CLIFormatter` for protocol details. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker build -t start_span . | |
# docker run --rm -ti start_span | |
FROM elixir:1.10.3-alpine | |
RUN cd /usr/local/src && mix new start_span | |
WORKDIR /usr/local/src/start_span | |
COPY mix.exs README.md ./ | |
COPY start_span.ex lib/ | |
RUN mix local.hex --force && mix local.rebar --force && mix deps.get | |
CMD ["mix", "dialyzer"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule TelemetryTracingExperimentTest do | |
use ExUnit.Case, async: true | |
@doc """ | |
Dump a variable to standard output, ANSI formatted, and pretty. | |
""" | |
def dump(v) do | |
opts = IEx.Config.inspect_opts() | |
[:reset, "\n", get_in(opts, [:syntax_colors, :reset]) || :reset, inspect(v, opts), :reset] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule AutoRecords do | |
defmacro __using__(_opts) do | |
quote do | |
require OpenTelemetry.Records.Auto | |
import OpenTelemetry.Records.Auto, only: [auto_record: 2] | |
end | |
end | |
defmacro auto_record(name, from_lib) do |