instrumentation

typescript
import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { Resource } from '@opentelemetry/resources';
import {

OpenTelemetry tracing for Node HTTP

observability tracing opentelemetry
by codesnips 3 tabs
ruby
class JsonLogFormatter < ActiveSupport::Logger::SimpleFormatter
  def call(severity, timestamp, _progname, message)
    if message.is_a?(Hash)
      entry = {
        ts: timestamp.utc.iso8601(3),
        level: severity

Lograge-Style JSON Logging Without Extra Gems

rails logging observability
by codesnips 3 tabs
ruby
class CheckoutService
  def initialize(cart:, user:)
    @cart = cart
    @user = user
  end

Instrument a Service with Notifications

rails observability instrumentation
by codesnips 3 tabs
ruby
class DeliveryObserver
  def self.delivered_email(message)
    new(message).record
  end

  def initialize(message)

Action Mailer Delivery Observability Hook

rails observability action-mailer
by codesnips 3 tabs
go
package main

import (
	"log"
	"net/http"
	"time"

Instrumenting Go HTTP Handlers with Prometheus Counters and Histograms

prometheus metrics observability
by codesnips 3 tabs
ruby
module QueryBudget
  class Counter
    IGNORED = %w[SCHEMA CACHE TRANSACTION].freeze

    attr_reader :count

Per-Request Query Budget (Detect Runaway Pages)

rails performance observability
by codesnips 4 tabs
ruby
class ArticlesController < ApplicationController
  def index
    # Bounded queries: without preload, article.author in the view raises.
    @articles = Article
      .published
      .preload(:author, :tags)

Strict Loading to Catch N+1 in Development

rails activerecord performance
by codesnips 4 tabs