golang-samber-slog

Design Go slog handler pipelines with samber/slog-multi, sampling, and formatting.

Updated May 28, 2026
One-click install
npx skills add https://github.com/vanstinator/semantic-search --skill golang-samber-slog-vanstinator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-slog
Source: https://github.com/vanstinator/semantic-search/tree/main/.agents/skills/golang-samber-slog
Command: npx skills add https://github.com/vanstinator/semantic-search --skill golang-samber-slog-vanstinator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps Go teams design reliable, consistent structured logging pipelines with samber/slog-* so logs are routed correctly, noisy records are sampled safely, and sensitive data is formatted or scrubbed before it reaches sinks.

Core Features & Use Cases

  • Pipeline correctness for slog-multi: Compose sampling, middleware, routing, and sinks with the right ordering so expensive work is not performed for dropped records.
  • Throughput control with slog-sampling: Apply uniform or threshold sampling to reduce volume while preserving early visibility and enabling matcher-based deduplication buckets.
  • Safe attribute handling with slog-formatter and HTTP middleware sinks: Use PII and error/IP formatting so downstream backends (Sentry, Loki, Datadog, etc.) receive cleaned, structured attributes, including request-scoped attributes from HTTP middleware.

Quick Start

Use the golang-samber-slog skill to generate a slog-multi pipeline that applies sampling first, adds PII scrubbing with slog-formatter, routes ERROR to Sentry and the rest to Loki, and configures slog-gin to set WARN for 4xx and ERROR for 5xx.

Frequently Asked Questions about golang-samber-slog

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a slog-multi pipeline for routing logs to multiple backends?

Structure a slog-multi pipeline by composing sampling, formatting, and routing middleware with correct ordering before backend sinks. Use predicate-based routing semantics with Router or FirstMatch to ensure records reach intended destinations without being dropped or duplicated.

Why should sampling come before formatting in a Go structured logging pipeline?

Sampling must come before formatting in a structured logging pipeline to prevent expensive formatting operations on records that will be dropped. This ordering ensures computational resources are not wasted processing log entries that the sampling middleware ultimately discards.

How do I scrub PII from Go slog records before sending to Loki or Datadog?

Scrub PII from Go slog records by integrating slog-formatter middleware in the pipeline before backend sinks. This ensures sensitive data like IP addresses and errors are cleaned into structured attributes prior to reaching downstream destinations such as Loki or Datadog.

Can I use slog-gin middleware for HTTP request logging with custom log levels?

Yes, you can use slog-gin middleware for HTTP request logging by configuring it to set WARN for 4xx responses and ERROR for 5xx responses. This integrates request-scoped attributes directly into the structured logging pipeline.

What is the difference between Router and FirstMatch routing in slog-multi?

Router and FirstMatch are predicate-based routing semantics in slog-multi that control record distribution. Proper selection between them avoids dropped or duplicated records when directing logs to multiple backend sinks concurrently.