sampling-fingers-crossed

command
v0.54.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 7 Imported by: 0

README

HTTP server example: sampling + fingers-crossed logging

This example demonstrates how to enable gosoline's context-based sampling and fingers-crossed logging in an HTTP service.

Run

go run .

Server listens on http://127.0.0.1:8088.

Endpoints

  • GET /success: returns HTTP 200
  • GET /fail: returns HTTP 500 (useful to see fingers-crossed flushing)

Try it

1) Normal request
curl -i http://127.0.0.1:8088/success
2) Force sampling via request header
curl -i -H 'X-Goso-Sampled: true' http://127.0.0.1:8088/success
curl -i -H 'X-Goso-Sampled: false' http://127.0.0.1:8088/success
3) Trigger a failure (flushes buffered logs)
curl -i -H 'X-Goso-Sampled: false' http://127.0.0.1:8088/fail

On a non-sampled request, gosoline buffers most log lines and flushes them on errors and failed requests.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL