diff --git a/ruby/sinatra-puma/app/app.rb b/ruby/sinatra-puma/app/app.rb index 0d4912a7..2d4dd9e0 100644 --- a/ruby/sinatra-puma/app/app.rb +++ b/ruby/sinatra-puma/app/app.rb @@ -5,21 +5,28 @@ Appsignal.start get "/" do - time = Time.now.strftime("%H:%M") - <<~HTML -

Sinatra + Puma example app

- -

Run the console command for this app to "phased restart" this app.

- - - HTML + time = + Appsignal.instrument "fetch.time" do + Time.now.strftime("%H:%M") + end + Appsignal.instrument "render.view" do + <<~HTML +

Sinatra + Puma example app

+ +

Run the console command for this app to "phased restart" this app.

+ + + HTML + end end get "/slow" do @@ -57,6 +64,7 @@ class AnotherCustomError < StandardError end get "/stream/slow" do + sleep 0.5 stream do |out| sleep 1 out << "1" @@ -83,3 +91,28 @@ class AnotherCustomError < StandardError "Cron check-in sent!" end + +class MyResponseBody + def initialize + @body = [] + end + + def <<(value) + @body << value + end + + def to_ary + @body + end +end + +get "/array" do + body = MyResponseBody.new + Appsignal.instrument "do.stuff" do + body << "abc" + Appsignal.instrument "do_more.stuff" do + body << "def" + end + end + [200, body] +end