Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opencensus-beam/opencensus_plug
Opencensus integration with Elixir's Plug library
https://github.com/opencensus-beam/opencensus_plug
elixir elixir-plug metrics opencensus tracing
Last synced: 3 days ago
JSON representation
Opencensus integration with Elixir's Plug library
- Host: GitHub
- URL: https://github.com/opencensus-beam/opencensus_plug
- Owner: opencensus-beam
- License: apache-2.0
- Created: 2018-12-04T19:21:05.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-01T10:58:22.000Z (over 3 years ago)
- Last Synced: 2024-10-07T09:49:40.396Z (about 1 month ago)
- Topics: elixir, elixir-plug, metrics, opencensus, tracing
- Language: Elixir
- Homepage:
- Size: 72.3 KB
- Stars: 15
- Watchers: 5
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-beam-monitoring - Plug
README
# Opencensus.Plug
[![CircleCI](https://circleci.com/gh/opencensus-beam/opencensus_plug.svg?style=svg)](https://circleci.com/gh/opencensus-beam/opencensus_plug)
[![CodeCov](https://codecov.io/gh/opencensus-beam/opencensus_plug/branch/master/graph/badge.svg)](https://codecov.io/gh/opencensus-beam/opencensus_plug)
[![Inline docs](http://inch-ci.org/github/opencensus-beam/opencensus_plug.svg)](http://inch-ci.org/github/opencensus-beam/opencensus_plug)
[![Hex version badge](https://img.shields.io/hexpm/v/opencensus_plug.svg)](https://hex.pm/packages/opencensus_plug)[Plug][plug] integration for [OpenCensus][oc]. It provides tracer and metrics
integration.## Installation
The package can be installed by adding `opencensus_plug` to your list
of dependencies in `mix.exs`:```elixir
def deps do
[
{:opencensus_plug, "~> 0.3"}
]
end
```The docs can be found at [https://hexdocs.pm/opencensus\_plug](https://hexdocs.pm/opencensus_plug).
## Usage
### Tracing
Create tracing module:
```elixir
defmodule MyApp.TracePlug do
use Opencensus.Plug.Trace
end
```And then add it on the beginning of your pipeline (the sooner the better):
```elixir
plug MyApp.TracePlug
```This will extract parent trace from the headers accordingly
to [Tracing Context](https://github.com/w3c/trace-context) proposal and it will
create new span. By default span name will match request path, you can configure
that by defining `span_name/2` method that will receive `Plug.Conn.t` as a first
argument and plug options as a second.### Metrics
Create metrics module:
```elixir
defmodule MyApp.MetricsPlug do
use Opencensus.Plug.Metrics
end
```And then add it on the beginning of your pipeline (the sooner the better):
```elixir
plug MyApp.MetricsPlug
```You also need to define metrics that will be measured, fortunately there is
helper method for you, just call `MyApp.MetricsPlug.setup_metrics()` **before**
running pipeline.Available metrics:
- `"plug/requests/duration"` - request duration in microseconds
- `"plug/requests/count"` - requests count**WARNING!** This defines only metrics, not views. You need to define views on
your own to be able to see them in the exporters.## License
See [LICENSE](LICENSE) file.
[plug]: https://github.com/elixir-plug/plug
[oc]: https://opencensus.io