hauleth

hauleth OP

As tracing and metrics gathering seems to still be problem for some of the newcomers I have started few projects to improve that by utilising OpenCensus. During my last 2 days of work I have added few 3 new libraries to the OpenCensus BEAM organisation:

  • DataDog - support for DogStatsD metrics and for DataDog’s APM traces.
  • plug integration (not yet released on Hex) - tracing and measurements. For now there is support for pipeline as a whole, maybe in future I will add “per plug” support.
  • telemetry integration (not yet released on Hex) - measurements.

Future libraries:

  • Phoenix integration - maybe, maybe not. I am not sure how much it will be needed when Phoenix integrate telemetry. Maybe tracing, but that would be covered by opencensus_plug library
  • Ecto integration - while measurements are covered by opencensus_telemetry, support for traces would still be desirable, however no idea how to support it right now
  • Wrapper library for erlang:trace/3 - this would be really interesting project, that would allow us to trace enormous amount of data. However there are few problems I see right now, and finding solution for them can be a little bit costly, so for now it is left deep in the backlog.

Let me know what other libraries and integrations you would like to see.

First 10 of 17 Posts Switch mode

ferd

ferd

Author of Property-Based Testing with PropEr, LYSE, & Erlang in Anger

Using trace data is likely a bad idea. There can only be one tracer at any point in time (no concurrency), so if you integrate it to the metrics, nobody can use it to debug at the same time.

hauleth

hauleth OP

Yeah, I have checked that and it is a shame. So I would need to find another way to handle that, unfortunately I cannot take a look into WombatOAM :frowning:


By the way, new exporter (not yet published) is available:

GregMefford

GregMefford

I’m happy to see that OpenCensus is gaining more traction in the BEAM ecosystem! I think it was about 6-9 months ago that I last checked and it didn’t seem like there was enough there yet to go all in, but now it seems that there are a number of people working on it. :rocket:

I am maintaining the Spandex project along with @zachdaniel, with the goal of being an OpenTracing-compatible API that supports multiple vendor back-ends, very similar to the goals of OpenCensus. Currently, we only support DataDog APM as a back-end, but I think it should be relatively simple to support others if someone wanted to (and I’d love to know where they got stuck if it didn’t work out). We’re also looking forward to using Telemetry to collect span data in the future as more libraries support it. In the meantime, you may be interested to look at how Spandex integrates with Plug/Phoenix and Ecto. We have an example project that demonstrates how to integrate Spandex into an existing app, if you’re curious (see the links in the README for a code diff).

Also, as you probably know, several vendors have their own first-party support for tracing that is proprietary to only their back-ends, but mostly open-source (e.g. AppSignal, New Relic, Scout).

I’d be interested to look more into how the OpenCensus BEAM core compares to Spandex, and see whether there’s anything that can be shared somehow so everybody wins.

zachdaniel

zachdaniel

Creator of Ash

I agree :). I spent a really long time on Spandex, but I don’t want to be working against a more standardized implementation of tracing in Elixir. I’d hope that either spandex could be a standard interface for tracing an Elixir application, or the good parts of it could be salvaged/copied into a new standard. My point being that we should only hold tight into spandex if it’s going to be good for the community. If the community needs a more standard implementation, I’d be happy to support it.

hauleth

hauleth OP

I see no problems with making Spandex thin wrapper over OpenCensus library as API and concepts are quite similar. To be honest I even thought about creating OpenCensus wrapper for Elixir, that would end like something like Spandex, but in the end I didn’t see much value in that (at least yet, because I have proposed moving some utilities to macros). I also believe that we should reduce fragmentation in the matter of tracing and metrics gathering, but not only in Elixir, but in BEAM as a platform. It would be best if we would have single toolset to export metrics form both Erlang and Elixir.

Main reasons why I have joined OpenCensus project rather than Spandex are:

  • OpenCensus is Erlang project, so by adding new integrations there I can improve all BEAM languages at once. While we can still use Elixir from other languages in BEAM-family it isn’t that pretty, especially as a lot of Elixir code relies on Elixir’s macros. Porting Erlang macro to Elixir is much more straightforward than other way around.
  • In theory OpenCensus have bigger backing by being Google project that was open-sourced. It also has some big names in “Partners & Contributors” section.
  • OpenCensus also provide interface for metrics gathering, and I wanted something for my project Imager that would provide me single interface to export metrics and traces for different systems defined at runtime (PR with support for that is still WIP).
  • It uses W3C Context Specification for distributed tracing instead of relying on DataDog proprietary headers.

My only main problem with OpenCensus library right now is that it completely lacks documentation, which I will try to tackle soon. A lot of data is outdated, and it would be really wort to improve that, as it could help building community around such standard.

About integrating with Plug/Phoenix and Ecto I would need to create example projects in opencensus/plug and opencensus/telemetry. Only place where I still need to find how to hook into Ecto is tracing, but I have seen that you are using :trace level of Ecto logger for that, it can be worth checking this out that for adding new integration.

tristan

tristan

Rebar3 Core Team

Another useful project would be some benchmarks to both check overhead and eventually compare different ways of setting traces and collecting metrics. For example, I have a work in progress for using a message to a pool of workers for collecting metrics instead of doing them inline. In many cases just doing them inline is likely preferred – when not updating lots of views per measure – but useful to have numbers.

GregMefford

GregMefford

I should also mention that there are other OpenTracing-related projects in the BEAM ecosystem that seem relatively robust as options: otter for Erlang project and ExRay, which is an Elixir wrapper around it.

I agree that the ideal situation would be a robust core that allows the difficult/complicated parts to be shared by all BEAM languages, and perhaps wrapper interfaces native to each language so that it feels more idiomatic (for example, with respect to the macros). I think Spandex could be adapted somewhat-easily to that because it doesn’t rely in any magic or macros at its core - only for convenience so that we can offer function decorators and automatically generate some code for you so that you don’t have to explicitly pass in all of the default options to each API call.

hauleth

hauleth OP

I was fully aware of other solutions available out there. The points that (at least for me) were the most important are:

  • OpenCensus Erlang library seems to be backed by Google, and even if it isn’t then it seems more “official” than community projects like otter and Spandex
  • It supports not only tracing but metrics as well. Having common API for both of these is quite handy.
  • Is supported by the author of the Prometheus implementation which I quite liked and used in some projects.
  • Adding new integrations was a breeze
  • Metrics supports tags (in contrast to exometer/elixometer or Folsom)

So everything I needed was in just one package, what I really appreciate. So, with all respect to you guys, I place my bet on OpenCensus.

tristan

tristan

Rebar3 Core Team

Yea, I would love if we could all share an Erlang core. But now that there are so many implementations I doubt that is ever going to happen. And I’m partly to blame :). I started opencensus-erlang after trying otter when it was released.

I find opencensus to be important as a core because it defines so much (like propagation encoding and even a stacktrace proto format so services will actually be able to understand Erlang stacktraces! – small potatoes to Elixir world since services are starting to pick up on supporting Elixir).

It is also very open development of the specs and accepted Erlang as part of this process from early on.

hauleth

hauleth OP

opencensus_plug has landed on Hex

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91898 914
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
mudasobwa
While I am working on the Language Agnostic Code Audit SaaS, which uses MetaAST (spoiler: I am expecting it to be in a good shape for ann...
New

We're in Beta

About us Mission Statement