Sibyl.Plugin behaviour (Sibyl v0.1.11)
View SourceOpen interface for defining custom Sibyl plugins.
Note that at the time of writing, all plugins are considered in-development features and no stability or fixed API is guaranteed.
Sibyl Plugins are intended to be used by providing them as an option when attaching Sibyl handlers like so:
:ok = Sibyl.Handlers.attach_all_events(plugins: [Sibyl.Plugins.Absinthe])
:ok = Sibyl.Handlers.attach_module_events(MyApp.Module, plugins: [Sibyl.Plugins.Absinthe])
:ok = Sibyl.Handlers.attach_events([[:my_app, :start]], plugins: [Sibyl.Plugins.Absinthe])
Implementing a plugin is done by defining a module which use
s Sibyl.Plugin
and implements
the behaviour below.
Please feel free to refer to Sibyl.Plugins.Absinthe
or Sibyl.Plugins.Ecto
for examples of
how to implement a plugin.
Summary
Callbacks
Unique ID for the plugin. Intended to be used as a mechanism for attaching/detaching proxy :telemetry
handlers
Called by Sibyl when attaching a plugin to a handler. Should return a list of events which should be listened to by handlers
Event prefix for events emitted/proxied by a given plugin implementation. Defaults to the module's name split
Stops and cleans up any resources used by the plugin. Intended primarily for :telemetry
handler detachment
Callbacks
@callback identity() :: String.t()
Unique ID for the plugin. Intended to be used as a mechanism for attaching/detaching proxy :telemetry
handlers
@callback init(opts :: Keyword.t()) :: [Sibyl.Events.event()]
Called by Sibyl when attaching a plugin to a handler. Should return a list of events which should be listened to by handlers
@callback prefix() :: [atom()]
Event prefix for events emitted/proxied by a given plugin implementation. Defaults to the module's name split
@callback stop() :: :ok | {:error, term()}
Stops and cleans up any resources used by the plugin. Intended primarily for :telemetry
handler detachment