PromEx.DashboardRenderer (PromEx v1.0.0) View Source

This module is used to read dashboard definitions, render EEx dashboards, and ensure that requested files actually exist

Link to this section Summary

Functions

Read the contents of a dashboard file entry. If an EEx version of the file exists, read that, else fallback to the provided file name. For example, if the requested dashboard file is ecto.json, if ecto.json.eex exists, then that will be returned. This is more so for convenience so that you don't need to write out .eex everywhere given that all PromEx 1st party dashboards are EEx templates.

This function will decode the JSON dashboard using Jason. If any errors occur during the decoding process, the struct will be marked as having invalid JSON.

This function will merge in the provided assigns to the struct's assigns. These assigns will then be used during the render_dashboard/1 call to render any EEx template statements.

Renders the dashboard. If it is an EEx file then the PromEx module assigns are passed. Else if it is a raw json file then it is passed through untouched.

Link to this section Types

Specs

t() :: %PromEx.DashboardRenderer{
  assigns: keyword() | nil,
  decoded_dashboard: map() | nil,
  error: tuple() | nil,
  file_contents: String.t(),
  file_type: :eex | :json | nil,
  full_path: String.t(),
  otp_app: atom(),
  relative_path: String.t(),
  rendered_file: String.t() | nil,
  valid_file?: boolean(),
  valid_json?: boolean() | nil
}

Link to this section Functions

Link to this function

build(otp_app, dashboard_relative_path)

View Source

Specs

build(otp_app :: atom(), dashboard_relative_path :: String.t()) :: t()

Read the contents of a dashboard file entry. If an EEx version of the file exists, read that, else fallback to the provided file name. For example, if the requested dashboard file is ecto.json, if ecto.json.eex exists, then that will be returned. This is more so for convenience so that you don't need to write out .eex everywhere given that all PromEx 1st party dashboards are EEx templates.

Link to this function

decode_dashboard(dashboard_render)

View Source

Specs

decode_dashboard(t()) :: t()

This function will decode the JSON dashboard using Jason. If any errors occur during the decoding process, the struct will be marked as having invalid JSON.

Link to this function

merge_assigns(dashboard_render, additional_assigns)

View Source

Specs

merge_assigns(t(), keyword()) :: t()

This function will merge in the provided assigns to the struct's assigns. These assigns will then be used during the render_dashboard/1 call to render any EEx template statements.

Link to this function

render_dashboard(dashboard_render)

View Source

Specs

render_dashboard(t()) :: t()

Renders the dashboard. If it is an EEx file then the PromEx module assigns are passed. Else if it is a raw json file then it is passed through untouched.