3scale / apisonator

Red Hat 3scale API Management Apisonator backend
https://3scale.net
Apache License 2.0
35 stars 27 forks source link

THREESCALE-9682: Add support for OpenTelemetry #405

Closed jlledom closed 2 weeks ago

jlledom commented 4 weeks ago

This adds OpenTelemetry instrumentation for Sinatra in Apisonator.

How to verify:

  1. Follow the instructions on the docs to launch a Jaeger container.
  2. Set OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318" and the new var CONFIG_OPENTELEMETRY_ENABLED=true.
  3. Work normally, e.g. send some transaction requests to the listener.
  4. Visit Jaeger UI at http://localhost:16686 and verify the requests are reported.
  5. Verify that not setting CONFIG_OPENTELEMETRY_ENABLED or setting it to false disables the metrics and you can't see the requests in Jaeger.

Jira Issue: https://issues.redhat.com/browse/THREESCALE-9682

akostadinov commented 4 weeks ago

Is it possible by any chance to test that the endpoint is operational with the said env variable? Maybe not, just asking.

jlledom commented 4 weeks ago

Is it possible by any chance to test that the endpoint is operational with the said env variable? Maybe not, just asking.

I don't think there's a way other than pinging the endpoint host and port directly.

akostadinov commented 4 weeks ago

Fair enough. But how do we know whether this fixes the actual JIRA issue THREESCALE-9669?

jlledom commented 4 weeks ago

Fair enough. But how do we know whether this fixes the actual JIRA issue THREESCALE-9669?

The issue is not only about apisonator. As I understood it, the only apisonator work required is:

3scale Backend should be instrumented using opentelemetry SDK. Sinatra has instrumentation in place implemented in https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/sinatra

So there's no need to check any endpoint AFAIK. @eguzki ?

eguzki commented 3 weeks ago

That's the one jira issue describing the work being done here: https://issues.redhat.com/browse/THREESCALE-9682

eguzki commented 3 weeks ago

LGTM

I left one suggestion, but it's a nit.

eguzki commented 3 weeks ago

It would be nice to drop an snapshot from jaeger UI with the trace being recorded from backend listener

jlledom commented 3 weeks ago

It would be nice to drop an snapshot from jaeger UI with the trace being recorded from backend listener

Some screenshots:

image image image image