{"id":18039412,"url":"https://github.com/nogates/discorelic","last_synced_at":"2025-03-27T10:32:13.809Z","repository":{"id":57490315,"uuid":"65756863","full_name":"nogates/discorelic","owner":"nogates","description":"Elixir implementation of the NewRelic intrumentation PaaS","archived":false,"fork":false,"pushed_at":"2016-08-23T20:22:51.000Z","size":13,"stargazers_count":7,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-14T12:45:40.581Z","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/nogates.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":"2016-08-15T18:55:18.000Z","updated_at":"2024-01-17T07:40:06.000Z","dependencies_parsed_at":"2022-09-02T12:01:43.629Z","dependency_job_id":null,"html_url":"https://github.com/nogates/discorelic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogates%2Fdiscorelic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogates%2Fdiscorelic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogates%2Fdiscorelic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogates%2Fdiscorelic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nogates","download_url":"https://codeload.github.com/nogates/discorelic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222235884,"owners_count":16953366,"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","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":"2024-10-30T14:09:21.915Z","updated_at":"2024-10-30T14:09:22.507Z","avatar_url":"https://github.com/nogates.png","language":"Elixir","readme":"[![Build Status](https://travis-ci.org/nogates/discorelic.svg?branch=add-travis)](https://travis-ci.org/nogates/discorelic)\n[![Coverage Status](https://coveralls.io/repos/github/nogates/discorelic/badge.svg)](https://coveralls.io/github/nogates/discorelic)\n\n# Discorelic\n\nDiscorelic is an Elixir implementation of the NewRelic intrumentation PaaS. It's based on erlang newrelic, which basically has reversed engineering the python client, so its integration with NewRelic is not 100% perfect.\n\n## Why?\n\nThere are a few implementations out there written in Elixir to publish metrics in NewRelic. However, all of them are using either the NewRelic SDK client, which wasn't very easy to work with, or requiring libraries that are not always required for all projects, like `Plug` or `Ecto`, as [`new-relixir`](https://github.com/TheRealReal/new-relixir) is doing.\n\nThe aim of this project it to create a library that contains the minimal dependencies and has a consistent way to interact with NewRelic transactions.\n\n\n## Installation\n\n\n  1. Add discorelic to your list of dependencies in `mix.exs`:\n    ```elixir\n\n    def deps do\n      [ { :discorelic, \"~\u003e 0.0.1\", github: \"nogates/discorelic\" } ]\n    end\n\n    ```\n\n  2. Ensure discorelic is started before your application:\n\n  ```elixir\n\n    def application do\n      [ applications: [ :discorelic ] ]\n    end\n  ```\n\n  3. Set up your application name and license key in your `config.exs`\n\n  ```elixir\n\n    config :discorelic,\n      application_name: \"MyAwesomeApplication\",\n      license_key: System.get_env(\"NEW_RELIC_LICENSE_KEY\")\n\n  ```\n\n## Usage\n\nDiscorelic uses Elixir's macros in order to provide an easy way to record transactions. Currently it supports:\n\n - Web transactions / total time:\n\n  ```elixir\n  # Basic module transaction\n  defmodule MyModule do\n    import Discorelic.Tracker\n\n    def request_with_tracking do\n      record_transaction! \"my_request\" do\n        my_request\n      end\n    end\n  end\n\n  ```\n\n- Web transactions / Module segments:\n\n  ```elixir\n  # Basic module transaction\n  defmodule MyModule do\n    import Discorelic.Tracker\n\n    def request_with_tracking do\n      record_transaction! \"my_request\" do\n        record_transaction! { User, \"user_login\" } do\n          User.login\n        end\n        record_transaction! { Request, \"Http request\" } do\n          Request.my_request\n        end\n      end\n    end\n  end\n  ```\n\n- Manually handle async transactions\n\n  ```elixir\n\n  defmodule AsyncTask do\n    alias Discorelic.Tracker\n\n    def call(pid) do\n      # Create a transaction\n      transaction = Tracker.init_transaction \"Async Transaction\"\n\n      # Initialise a task process with the transaction\n      task_pid    = Task.start_link(fn -\u003e loop(transaction) end)\n\n      # Call an external pid process, which will notify the running task at some point\n      GenServer.cast(pid, { :async_event, task_pid })\n    end\n\n    def loop(%Discorelic.Transaction{} = transaction) do\n      receive do\n        # the process has completed the first step, record a time set for the module\n        # and continue the loop\n        { :step_1, _pid } -\u003e Tracker.record(transaction, { AsyncTask, \"step 1\" }) |\u003e loop\n        # You can also provide a transaction segment to this record function\n        :wait -\u003e\n          transaction_segment = Tracker.init_transaction_segment { AsyncTask, \"wait\" }\n          :timer.sleep 5_000\n          Tracker.record(transaction, transaction_segment) |\u003e loop\n        # the process has finished. record the transaction\n        :finish         -\u003e { :ok, _transaction } = Tracker.publish(transaction)\n\n      end\n    end\n  end\n  ```\n\n\n## TODO\n\n - Publish this to hex\n\n\n## License\n\nPlease see [LICENSE](https://github.com/nogates/discorelic/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnogates%2Fdiscorelic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnogates%2Fdiscorelic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnogates%2Fdiscorelic/lists"}