Upgrade to Pro — share decks privately, control downloads, hide ads and more …

open telemetry w/ Ruby

k.yanagimoto
February 09, 2021

open telemetry w/ Ruby

k.yanagimoto

February 09, 2021
Tweet

More Decks by k.yanagimoto

Other Decks in Technology

Transcript

  1. OpenTelemetry with Ruby
    @kyanagimoto
    Jaeger also


    9th Feb, 2021 Nikotama.rb #15

    View full-size slide

  2. OpenTelemetry?
    • CNCF project


    • OpenCensus + OpenTracing


    • Observability


    • Traces, Metrics, Logs

    View full-size slide

  3. “Let’s create sample project!”

    View full-size slide

  4. docker run —rm -d --name jaeger \


    -p 5775:5775/udp \


    -p 6831:6831/udp \


    -p 6832:6832/udp \


    -p 5778:5778 \


    -p 16686:16686 \


    -p 14268:14268 \


    -p 14250:14250 \


    -p 9411:9411 \


    jaegertracing/all-in-one:1.21
    Port meanings: https://www.jaegertracing.io/docs/1.21/getting-started/#all-in-one

    View full-size slide

  5. Demo App
    https://guides.rubyonrails.org/getting_started.html

    View full-size slide

  6. Gem
    f
    ile


    gem 'opentelemetry-sdk'


    gem 'opentelemetry-exporter-jaeger'


    gem 'opentelemetry-instrumentation-mysql2'


    gem 'opentelemetry-instrumentation-rails'

    View full-size slide

  7. con
    f
    ig/application.rb


    require_relative "boot"


    require "rails/all"


    require 'opentelemetry/sdk'


    require ‘opentelemetry/exporter/jaeger'


    # Require the gems listed in Gem
    f
    ile, including any gems


    # you've limited to :test, :development, or :production.


    Bundler.require(*Rails.groups)


    OpenTelemetry::SDK.con
    f
    igure do |c|


    c.use_all


    c.add_span_processor(


    OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(


    exporter: OpenTelemetry::Exporter::Jaeger::AgentExporter.new(host: '0.0.0.0', port: 6831)


    )


    )


    c.service_name = 'sample-app'


    c.service_version = '0.0.1'


    end


    module RailsSample


    class Application < Rails::Application


    # Initialize con
    f
    iguration defaults for originally generated Rails version.


    con
    f
    ig.load_defaults 6.1


    # Con
    f
    iguration for the application, engines, and railties goes here.


    #


    # These settings can be overridden in speci
    f
    ic environments using the
    f
    iles


    # in con
    f
    ig/environments, which are processed later.


    #

    f

    View full-size slide

  8. Let’s access


    http://localhost:16686/trace

    View full-size slide