👻🧶
Go to file
2023-12-19 15:32:45 +03:00
.github/workflows TD-686: Adds scoper handler OTel-instrumentalisation (#6) 2023-10-23 17:08:59 +03:00
src TD-788: Adds support for woody event severity mapping (#7) 2023-12-19 15:32:45 +03:00
test TD-686: Adds scoper handler OTel-instrumentalisation (#6) 2023-10-23 17:08:59 +03:00
.editorconfig TD-222: Add CI through GH Actions (#1) 2022-07-13 19:42:00 +03:00
.env TD-222: Add CI through GH Actions (#1) 2022-07-13 19:42:00 +03:00
.gitignore TD-222: Add CI through GH Actions (#1) 2022-07-13 19:42:00 +03:00
Dockerfile.dev TD-222: Add CI through GH Actions (#1) 2022-07-13 19:42:00 +03:00
elvis.config TD-222: Add CI through GH Actions (#1) 2022-07-13 19:42:00 +03:00
LICENSE Let's make it opensource (#11) 2019-09-20 17:51:54 +03:00
Makefile TD-222: Add CI through GH Actions (#1) 2022-07-13 19:42:00 +03:00
README.md TD-222: Add CI through GH Actions (#1) 2022-07-13 19:42:00 +03:00
rebar.config TD-686: Adds scoper handler OTel-instrumentalisation (#6) 2023-10-23 17:08:59 +03:00
rebar.lock TD-686: Adds scoper handler OTel-instrumentalisation (#6) 2023-10-23 17:08:59 +03:00

scoper

Log metadata scoping Erlang library.

About

From Urban Dictionary:

Scoper - another word for spastic. Came into use when the Spastic's Society changed it's name to Scope.

You Scoper!
You're such a Scoper!
Scoooper!

Usage

  • Scope log metadata along the process call stack, wrapping functions in scoper:scope/2,3. Scope name should be an atom, metadata is a map with atom keys. The types:

    -type key()   :: atom().
    -type value() :: any().
    -type meta()  :: #{key() => value()}.
    -type scope() :: key().
    
  • Add/remove scope metadata via scoper:add_meta/1 and scoper:remove_meta/1

  • Use lager or just process dictionary (by default) as metadata storage.

  • Implement your own storage as scoper_storage behaviour. Metadata storage is configured via application environment variable storage, which should name the module implementing scoper_storage behaviour. E.g.:

    {scoper, [
        {storage, scoper_storage_lager}
    ]}.
    
  • Enjoy tailored scoper_woody_event_handler:

    %% woody client or server config
    event_handler => scoper_woody_event_handler,
    

    Scope names for woody client and server are: rpc.client and rpc.server.

Note, if using lager metadata storage or/and woody event handler make sure to properly setup corresponding applications in your app.src file, since they are optional for scoper and not configured as it's application dependencies.