DCMetrics Elixir

Elixir implementation for DeliveryCenter's structured logging format.

This package is part of a family of libraries that implement DeliveryCenter's metrics pattern for different languages. Check also our Golang, Node and Ruby versions.

By default, all events will be logged to:

For the complete documentation, refer to the documentation page.

Installation

This package can be installed by adding dc_metrics to your list of dependencies in mix.exs:

def deps do
[
{:dc_metrics, "~> 0.1.2"}
]
end

Usage

First, set the required configs in your config file

config :dc_metrics,
caller: "APPLICATION_NAME",
env: Mix.env(),
gcp_project_id: "project_id",
pubsub_topic_name: "topic_name"

By default, Elixir's Logger will print colored logs, which doesn't work on GCP. To prevent it

config :logger,
:console, colors: [enabled: false]

Then, to log an event

DCMetrics.info("Product created with success",
action: "CREATE_PRODUCT",
direction: "INCOMING",
source_type: "PROVIDER",
source_name: "MY_PROVIDER",
root_resource_type: "PRODUCT",
ext_root_resource_id: "EXT1234",
int_root_resource_id: "6789",
int_store_id: 100
)

Options

Levels

The supported levels are:

Metadata

All log operations take a argument metadata, which should contain all fields to be sent as a metric. The list of fields and its descriptions can be found at the Confluence documentation page.

Config options