Movatterモバイル変換


[0]ホーム

URL:


Free trial
  1. Home
  2. Language Guides
  3. Ruby
  4. APM
  5. Profiling custom Ruby scripts

Profiling custom Ruby scripts

For standalone scripts, context start-end needs to be marked specifically and optionally extended events can be called.

#!/usr/bin/env rubyrequire'raygun/apm'classHellodefrdocsleep0.5endendtracer=Raygun::Apm::Tracer.newtracer.udp_sink!tracer.start_traceHello.new.rdoctracer.end_tracetracer.process_ended

Extended events can be sent where appropiate to capture web requests and SQL queries manually.

HTTP Incoming event

event=Raygun::Apm::Event::HttpIn.newevent[:pid]=Process.pidevent[:tid]=0event[:timestamp]=tracer.nowevent[:url]='https://google.com/'event[:verb]='GET'event[:status]=200event[:duration]=1000tracer.emit(event)

DB Query

event=Raygun::Apm::Event::Sql.newevent[:pid]=Process.pidevent[:tid]=0event[:timestamp]=tracer.nowevent[:provider]='postgres'event[:host]='localhost'event[:database]='rails'event[:query]='SELECT * from FOO;'event[:duration]=1000tracer.emit(event)

[8]ページ先頭

©2009-2025 Movatter.jp