Mix tasks for installing and invoking otelcol-contrib. Copied from tailwind, with the intent of easily running an OpenTelemetry Collector next to the server, in development. It uses the contrib version to have as many options for export as possible.
Otelcol is intended as a development-only tool. Make sure to specify only: :dev
in your mix.exs:
def deps do
[
{:otelcol, "~> 0.1", only: :dev}
]
end
Once installed, change your config/config.exs
to pick your
otelcol version of choice:
config :otelcol, version: "0.45.0"
Now you can install otelcol-contrib
by running:
$ mix otelcol.install
And invoke otelcol with:
$ mix otelcol default
The executable is kept at _build/otelcol-contrib
.
The first argument to otelcol
is the execution profile.
You can define multiple execution profiles with the current
directory, the OS environment, and default arguments to the
otelcol
task:
config :otelcol,
version: "0.46.0",
default: [
args: ~w(
--config=config/otelcol-collector.yml
)
]
When mix otelcol default
is invoked, the task arguments will be appended
to the ones configured above. Note profiles must be configured in your
config/config.exs
, as otelcol
runs without starting your application
(and therefore it won't pick settings in config/runtime.exs
).
To add otelcol
to an application using Phoenix, you need one more step.
Installation requires that Phoenix watchers can accept module-function-args
tuples which is not built into Phoenix 1.5.9.
For development, we want to use "watch" mode, even though we're not really
watching any files. So find the watchers
configuration in your
config/dev.exs
and add:
otelcol: {Otelcol, :install_and_run, [:default, []]}
The first time this package is installed, a default otelcol configuration
will be placed in a new config/otel-collector.yml
file. See
the otelcol documentation
on configuration options.
Copyright (c) 2022 Kenichi Nakamura. copied/modded from https://github.com/phoenixframework/tailwind Copyright (c) 2021 Wojtek Mach, José Valim.
otelcol source code is licensed under the MIT License.