Fork me on GitHub
#clj-otel
<
2024-05-30
>
Ion Simion09:05:47

Hi everyone! I’m new with otel and might have some facts confused. Is there a way to render metrics instead of exporting them to a collector? I assumed clj-otel.exporter.prometheus would allow that but is blank when I access the host/port.

Dimitar Uzunov08:05:40

You can also send metrics directly to an otel backend that can visualize them

Ion Simion08:05:29

Thank you, I don’t wish to send the metrics, I want to have them built in the same app, so it just exposes the metrics for pulling.

Dimitar Uzunov09:05:04

https://opentelemetry.io/img/otel-diagram.svg - perhaps you are looking for an in-memory time-series database of some sort?

Ion Simion09:05:41

yes yes exactly, but didn’t find an example of implementing with clj-otel

Dimitar Uzunov09:05:08

yeah I’m not sure otel is intended to be used in this scenario, it is about the observability of applications

Dimitar Uzunov09:05:04

@U028REEBHGF perhaps you can describe your need in #CQT1NFF4L?

Ion Simion09:05:37

thank you, I guess my only option would be with the java interop around the open-telemetry, a lot to figure out though ..

Dimitar Uzunov09:05:56

if you mean you just want to view the application traces and metrics locally you can run jeager locally pretty easily: https://cljdoc.org/d/com.github.steffan-westcott/clj-otel-api/0.2.6/doc/tutorial#_start_telemetry_backend

Ion Simion09:05:14

Yes, done the tutorial, however still fits as a separate collector and isn’t accepted

steffan11:05:26

You can export metrics directly to a Prometheus instance without going via any Collector(s). The divisor-app is a small example that exports directly to Prometheus. https://github.com/steffan-westcott/clj-otel/tree/master/examples/divisor-app

👀 1
steffan11:05:16

`divisor-app` uses the OpenTelemetry agent at runtime. By default, the agent attempts to export metrics using OTLP, so the option otel.metrics.exporter=prometheus is required to use Prometheus instead. You'll see this option (and others) in the deps.edn of the example.

Ion Simion11:05:54

So it does a push exporting right? my task is to be a pull server, so I can add it as source in Prometheus or any other similar

steffan11:05:58

divisor-app includes a Prometheus configuration, where the Prometheus instance scrapes (pulls) metrics from an HTTP endpoint provided by the instrumentation agent.

Ion Simion11:05:30

oh, yes, no instrumentation agent, all instrumenting will be internal..

steffan11:05:46

The instrumentation agent runs as a Java agent, so it is in the same OS process as the main application.

Ion Simion11:05:20

no java agent, all metrics would be manually instrumented around the code

steffan11:05:31

Manual instrumentation is the primary use case of clj-otel, so you are in the right place 😄 You have the option of using the Java agent or not when using clj-otel. Using the agent is useful, as you get lots of high-quality instrumentation with no effort. Please take a look at this https://cljdoc.org/d/com.github.steffan-westcott/clj-otel-api/0.2.6/doc/concepts#_instrumenting_libraries_and_applications.

👀 1
Ion Simion11:05:34

In iopates package there was a reitit middleware that used io.prometheus.server to render the metrics .. I have to do something similar but with open-telemetrics .. my view is foggy, confusing aspects .. I understand clj-otel doesn’t have such a middlerware, and most probably I need some “in memory” thingy .. Or perhaps I could use jetty to render the registry metrics? 🤯

steffan11:05:11

Perhaps to clear your view, might I suggest looking through the https://cljdoc.org/d/com.github.steffan-westcott/clj-otel-api/0.2.6/doc/concepts documentation? I think you may be confusing instrumentation (getting the telemetry data) with visualisation (analysis and display of telemetry data). Telemetry backends are responsible for visualisation.

steffan12:05:18

Prometheus ships with a very basic display of metrics that it collects (scrapes). Telemetry backends (like Grafana and many others) integrate with your Prometheus instance to give a more comprehensive display and analysis.

Ion Simion12:05:58

Yes, that’s what I need, a basic display of metrics, not a collector or exporter to collector.

steffan12:05:58

In the OpenTelemetry model, that display would be provided by a telemetry backend. clj-otel scope does not include making a telemetry backend, as it's focus is on the source of the telemetry data, not the visualisation.

Ion Simion12:05:37

Yess, but it exports right ? and instead of export it, can’t I store it in memory, and on request, display it? ..

steffan12:05:29

The Prometheus exporter does not store metrics, as far as I know. It exports metrics in batches of a few seconds' worth of metrics at a time.

truestory 1
steffan12:05:33

A Prometheus instance stores the metrics it scrapes, so I think you may be duplicating effort.

Ion Simion12:05:29

quoting - “Must not be specific to Prometheus, but to OpenTelemetry, in case tomorrow we switch to something else”

steffan12:05:05

It sounds like you need to investigate the use cases for analysis and display of your metrics. You will need to develop queries against those metrics, which will likely involve PromQL or similar. OpenTelemetry and clj-otel is a standardisation effort around the capture and forwarding of telemetry data to compatible telemetry backends. I think it would be a lot of effort (but not impossible) to create your own telemetry backend, so you may need to look at the capabilities of existing backends and see if they fit your needs.

steffan09:06:22

Correction: divisor-app in fact does not use the OpenTelemetry instrumentation agent. Instead, it uses the autoconfigure SDK extension. I'm sorry for any confusion caused. This https://cljdoc.org/d/com.github.steffan-westcott/clj-otel-api/0.2.6/doc/guides#_configure_and_run_an_application_with_telemetry explains the various options for configuring and running an application with telemetry.

1