{"id":30883311,"url":"https://github.com/globocom/alchemetrics_web","last_synced_at":"2025-09-08T09:44:32.956Z","repository":{"id":57478770,"uuid":"103968328","full_name":"globocom/alchemetrics_web","owner":"globocom","description":"Collect and report key metrics for a typical web application based on Phoenix and Ecto.","archived":false,"fork":false,"pushed_at":"2023-07-21T13:02:24.000Z","size":196,"stargazers_count":10,"open_issues_count":1,"forks_count":3,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-08-02T03:24:07.276Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/globocom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-18T17:10:54.000Z","updated_at":"2024-01-26T21:27:40.000Z","dependencies_parsed_at":"2022-09-17T04:21:49.377Z","dependency_job_id":null,"html_url":"https://github.com/globocom/alchemetrics_web","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/globocom/alchemetrics_web","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Falchemetrics_web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Falchemetrics_web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Falchemetrics_web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Falchemetrics_web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/globocom","download_url":"https://codeload.github.com/globocom/alchemetrics_web/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Falchemetrics_web/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274166945,"owners_count":25233959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-08T09:44:26.679Z","updated_at":"2025-09-08T09:44:32.937Z","avatar_url":"https://github.com/globocom.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eAlchemetrics Web\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Alchemetrics Web\" src=\"https://github.com/globocom/alchemetrics_web/blob/master/assets/alchemetrics_web.png?raw=true\" width=\"128\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Metrics for phoenix and ecto.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.org/globocom/alchemetrics_web\"\u003e\n    \u003cimg alt=\"Travis\" src=\"https://travis-ci.org/globocom/alchemetrics_web.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://hex.pm/packages/alchemetrics_web\"\u003e\n    \u003cimg alt=\"Hex\" src=\"https://img.shields.io/hexpm/dt/alchemetrics_web.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `alchemetrics_web` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:alchemetrics_web, \"~\u003e 0.5.4\"}\n  ]\nend\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/alchemetrics_web](https://hexdocs.pm/alchemetrics_web).\n\n## Usage\n\n1) Add alchemetris_web to your application list in mix.exs file: \n```elixir \ndef application do\n  ...\n  applications: [:phoenix, ..., :alchemetrics_web]\n  ...\nend\n```\n\n2) Plug AlchemetricsWeb to your endpoint: \n```elixir \ndefmodule MyApp.Endpoint do\n  use Phoenix.Endpoint, otp_app: ...\n  use AlchemetricsWeb\nend\n```\n\n```bash\n%{datapoint: :last_interval, request_count: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 1}\n%{datapoint: :total,         request_count: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 1}\n\n%{datapoint: :avg, request_time: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 192090}\n%{datapoint: :max, request_time: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 192090}\n%{datapoint: :min, request_time: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 192090}\n%{datapoint: :p95, request_time: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 192090}\n%{datapoint: :p99, request_time: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 192090}\n%{datapoint: :total, request_time: %{action: :index, controller: \"page_controller\", type: \"controller\"}, value: 192090}\n%{datapoint: :last_interval, request_time: %{action: :index, controller: \"page_controller\",type: \"controller\"}, value: 192090}\n```\n\n3) To collect and report ecto query metrics, config ecto logger in config.exs:\n```elixir \nconfig :my_app, MyApp.Repo, ..., \n  loggers: [..., {AlchemetricsWeb.Collectors.Ecto, :collect, []}]\n```\n\nEcto collector will report the follow data:\n```bash\n%{datapoint: :total, options: [], query_count: %{type: \"database.ecto\"}, value: 1}\n%{datapoint: :total, name: \"queue_time\", options: [], type: \"database.ecto\", value: 46}\n```\n#### Custom reporter\nAlchemetrics automatically schedule collected request and query metrics, but its \npossible to customize the way how the metrics is reported. In order to do that\nyou must implement modules to receive the collected metrics and set this up in\nyour config file. The follow example shows how can you do that:\n\n```elixir\n  defmodule MyApp.CustomPhoenixReporter do\n    def report(value, metadata) do\n      # value is the reported metric value.\n      # metadata is a keyword list.\n    end\n\n    def increment(metadata) do\n      # metadata is a keywork list.\n    end\n  end\n```\nIn config.exs\n```elixir\n  config :alchemetrics_web, :custom_request_reporter, MyApp.CustomPhoenixReporter\n```\n\nTo create a custom reporter for ecto queries just replace :custom_request_reporter config key by :custom_ecto_reporter\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobocom%2Falchemetrics_web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglobocom%2Falchemetrics_web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobocom%2Falchemetrics_web/lists"}