Sha256: 4f95f5dd1716bd39989bfd24f68b8dab8b63bf9190607d78e4754ad88c78666d

Contents?: true

Size: 808 Bytes

Versions: 5

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal: true

module Fly
  class FlyReplay
    def initialize(app)
      @app = app
    end

    def call(env)
      # replay /prometheus/* to the prom proxy in bubblegum
      if env["PATH_INFO"].starts_with?("/prometheus")
        return [307, { "Fly-Replay" => "app=flyio-bubblegum-api" }, []]
      end

      # replay /debug to the debug app. unsure if this is actually used
      if env["PATH_INFO"].starts_with?("/debug")
        return [307, { "Fly-Replay" => "app=debug" }, []]
      end

      @status, @headers, @response = @app.call(env)

      context = OpenTelemetry::Trace.current_span.context
      @headers["fly-trace-id"] = context.trace_id.unpack1("H*")
      @headers["fly-span-id"] = context.span_id.unpack1("H*")

      [@status, @headers, @response]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dockerfile-rails-1.6.23 lib/fly_replay.rb
dockerfile-rails-1.6.20 lib/fly_replay.rb
dockerfile-rails-1.6.19 lib/fly_replay.rb
dockerfile-rails-1.6.16 lib/fly_replay.rb
dockerfile-rails-1.6.15 lib/fly_replay.rb