Exporters

Você está visualizando a versão em versão em inglês desta página porque ela ainda não foi traduzida. Possui interesse em ajudar? Veja como contribuir.

Envie dados de telemetria para o OpenTelemetry Collector para garantir que estes dados sejam exportados corretamente. A utilização de um Collector em ambientes de produção é a melhor prática. Para visualizar os dados de telemetria que foram gerados, exporte-os para um backend como Jaeger, Zipkin, Prometheus, ou um backend específico de um fornecedor.

Exportadores disponíveis

O registro oferece uma lista de exportadores para Ruby.

Entre os exportadores, os exportadores do OpenTelemetry Protocol (OTLP) são projetados tendo em mente o modelo de dados do OpenTelemetry, emitindo dados OTel sem qualquer perda de informação. Além disso, muitas ferramentas que operam com dados de telemetria suportam o formato OTLP (como Prometheus, Jaeger e a maioria dos fornecedores), proporcionando um alto grau de flexibilidade quando necessário. Para saber mais sobre o OTLP, consulte a Especificação do OTLP.

Esta página reúne informações sobre os principais exportadores do OpenTelemetry Ruby e como configurá-los.

OTLP endpoint

To send trace data to a OTLP endpoint (like the collector or Jaeger) you’ll want to use an exporter package, such as opentelemetry-exporter-otlp:

bundle add opentelemetry-exporter-otlp
gem install opentelemetry-exporter-otlp

Next, configure the exporter to point at an OTLP endpoint. For example you can update config/initializers/opentelemetry.rb from the Getting Started by adding require 'opentelemetry-exporter-otlp' to the code:

# config/initializers/opentelemetry.rb
require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/all'
require 'opentelemetry-exporter-otlp'
OpenTelemetry::SDK.configure do |c|
  c.service_name = 'dice-ruby'
  c.use_all() # enables all instrumentation!
end

If you now run your application it will use OTLP to export traces:

rails server -p 8080

By default traces are sent to an OTLP endpoint listening on localhost:4318. You can change the endpoint by setting the OTEL_EXPORTER_OTLP_ENDPOINT accordingly:

env OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318" rails server -p 8080

To try out the OTLP exporter quickly and see your traces visualized at the receiving end, you can run Jaeger in a docker container:

docker run -d --name jaeger \
  -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
  -e COLLECTOR_OTLP_ENABLED=true \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 4317:4317 \
  -p 4318:4318 \
  -p 14250:14250 \
  -p 14268:14268 \
  -p 14269:14269 \
  -p 9411:9411 \
  jaegertracing/all-in-one:latest

Zipkin

To set up Zipkin as quickly as possible, run it in a docker container:

docker run --rm -d -p 9411:9411 --name zipkin openzipkin/zipkin

Install the exporter package as a dependency for your application:

bundle add opentelemetry-exporter-zipkin
gem install opentelemetry-exporter-zipkin

Update your OpenTelemetry configuration to use the exporter and to send data to your Zipkin backend:

# config/initializers/opentelemetry.rb
require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/all'

require 'opentelemetry-exporter-zipkin'
OpenTelemetry::SDK.configure do |c|
  c.service_name = 'dice-ruby'
  c.use_all() # enables all instrumentation!
end

If you now run your application, set the environment variable OTEL_TRACES_EXPORTER to Zipkin:

env OTEL_TRACES_EXPORTER=zipkin rails server

By default traces are sent to a Zipkin endpoint listening on port localhost:9411. You can change the endpoint by setting the OTEL_EXPORTER_ZIPKIN_ENDPOINT accordingly:

env OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:9411" rails server