Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michael-michalski/opencensus_patterns
Syntactic sugar for tracing
https://github.com/michael-michalski/opencensus_patterns
elixir opencensus
Last synced: 23 days ago
JSON representation
Syntactic sugar for tracing
- Host: GitHub
- URL: https://github.com/michael-michalski/opencensus_patterns
- Owner: michael-michalski
- License: mit
- Created: 2019-11-16T01:18:00.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-03T20:28:04.000Z (almost 5 years ago)
- Last Synced: 2024-10-30T00:34:11.934Z (2 months ago)
- Topics: elixir, opencensus
- Language: Elixir
- Homepage:
- Size: 1.25 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenCensus Patterns
![Hex.pm](https://img.shields.io/hexpm/v/opencensus_patterns.svg)
Utility functions for avoiding an entanglement ofbusiness logic and tracing.
## How to use
Example of tracing a phoenix endpoint.
```elixir
# Top level function uses the trace keyword, and .
trace home(conn, params), ctx do
IO.puts "I am a top level function call."# Dumps the structure as an annotation
annotate(params, ctx)# Call the nested function
utility(conn, params, ctx)
end# Consecutive tracing is done with the ntrace keyword,
# and the last parameter is the parent context.
ntrace utility(conn, params, parent_ctx), ctx do
IO.puts "I am nested"
end
```## Installation
The package is [available in Hex](https://hex.pm/docs/publish), and can be installed
by adding `opencensus_patterns` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:opencensus_patterns, "~> 0.2.0"}
]
end
```