Skip to content

Instantly share code, notes, and snippets.

View matsimitsu's full-sized avatar

Robert Beekman matsimitsu

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Performance metrics
Name: `transaction_duration` /Measurement /`namespace`, `action`
Exception metrics
Name: `transaction_exception_count` /Counter /`namespace`, `action`
Name: `transaction_exception_rate` /Gauge /`namespace`, `action`
Queue duration metrics
Name: `transaction_queue_duration` /Measurement /`namespace`
@matsimitsu
matsimitsu / custom_metrics.rake
Created May 14, 2019 12:16
custom_metrics.rake
namespace :database do
task :current_visits => :environment do
Appsignal.set_gauge("current_visits", CurrentVisit.count)
end
task :done do
# Wait for data to flush
Appsignal.stop
end
# Consumer that updates dashboards for an app
# through the AppSignal GraphQL API.
require 'rest-client'
require 'active_support'
require 'active_support/core_ext'
APPID = '' # app/site id, can be found in the url (/sites/<id>)
TOKEN = '' # Can be found on https://appsignal.com/users/edit
-
title: 'Heroku Postres'
graphs:
-
title: Connections
kind: gauge
format: number
draw_null_as_zero: false
fields:
- active_connections
db.foo.insertMany([
{ email: 'wes@example.com', course: 'a', purchaseDate: 10 },
{ email: 'wes@example.com', course: 'b', purchaseDate: 20 },
{ email: 'wes@example.com', course: 'c', purchaseDate: 5 },
{ email: 'nancy@example.com', course: 'c', purchaseDate: 6 },
{ email: 'nancy@example.com', course: 'b', purchaseDate: 10 },
{ email: 'nancy@example.com', course: 'a', purchaseDate: 5 },
{ email: 'nancy@example.com', course: 'd', purchaseDate: 1 },
{ email: 'john@example.com', course: 'd', purchaseDate: 1 },
{ email: 'bob@example.com', course: 'a', purchaseDate: 1 }
fn main() {
let str = "000030.294";
let float: f32 = str.parse().unwrap();
println!("{:?}", float);
}
// Running this on a Raspberry Pi returns:
//pi@raspberrypi ~ $ RUST_BACKTRACE=1 ./p1-monitor
//0.000000000000000000000000000000000000000000042
require "appsignal"
Appsignal.config = Appsignal::Config.new(
File.expand_path(File.dirname(__FILE__)),
"development"
)
Appsignal.start
class DailyProcessor
-
title: 'Sidekiq Queues'
graphs:
-
title: 'Sidekiq Queue count'
kind: count
filter: queue_(.+)_count
format: number
-
title: 'Sidekiq Queue durations'
# config/initializers/sidekiq.rb
require 'socket'
class MemoryUsageMiddleware
attr_reader :active, :max_oom, :shutdown
cattr_reader :cached_mb, :last_checked_at, :hostname
def self.start
@@start ||= Time.now
end