# 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