Forked go-glitch for go-sink
Go to file
Leopere 32f6560382 Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
build_logs Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
dist Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
.gitignore Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
README.md Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
build-run-test.sh Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
build.sh Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
go.mod Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
go.sum Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
install.sh Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
log.log Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
main.go Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00
test.sh Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 15:59:05 -04:00

README.md

You can stream and read files to a sentry DSN glitchtip or sentry itself I was fed up with how brittle sentry-cli was so I made this.

I might get around to making a whole CI/CD process for this which will upload the executables properly at some point and make this public.

Go Glitch

Go Glitch is a command-line utility that reads log messages from a file or stdin and sends them to Glitchtip, Sentry, or any compatible error tracking system.

Installation

To install the binary locally, you can use the provided installation script. Run the following command in your terminal:

curl -sSL https://git.nixc.us/Nixius/go-glitch/raw/branch/master/install.sh | bash

This will download and install the Go Glitch binary to your local machine.

Usage

You can use Go Glitch by specifying a log file as an argument or by piping input to it.

Using a Log File

go-glitch /path/to/logfile

Using Piped Input

cat /path/to/logfile | go-glitch

Server Mode

You can also run Go Glitch in server mode, which starts a webhook server that accepts log messages via HTTP requests:

go-glitch server

The server listens on port 5050 by default. You can send log messages to the webhook endpoint:

curl -X POST -H "Content-Type: application/json" \
  -d '{"log_level": "error", "message": "Error message", "service": "my-service"}' \
  http://localhost:5050/webhook

Configuration

Go Glitch supports multiple environment variables for the DSN. You can use any of the following:

  • GLITCHTIP_DSN: For GlitchTip instances
  • SENTRY_DSN: For Sentry instances
  • BUGSINK_DSN: For Bugsink instances

If multiple environment variables are set, they are checked in the order listed above, and the first one found is used.

Setting the DSN

Shell Environment

Add one of the following lines to your .zshrc or .bashrc file:

export GLITCHTIP_DSN="your-dsn"
# OR
export SENTRY_DSN="your-dsn"
# OR
export BUGSINK_DSN="your-dsn"

After adding the line, reload your shell configuration:

source ~/.zshrc # for zsh users
source ~/.bashrc # for bash users

Dockerfile

If you are using a Docker container, add the environment variable in your Dockerfile:

ENV GLITCHTIP_DSN=your-dsn
# OR
ENV SENTRY_DSN=your-dsn
# OR
ENV BUGSINK_DSN=your-dsn

docker-compose.yml

If you are using Docker Compose, add the environment variable in your docker-compose.yml file:

version: '3.8'

services:
  go-glitch:
    image: your-docker-image
    environment:
      - GLITCHTIP_DSN=your-dsn
      # OR
      # - SENTRY_DSN=your-dsn
      # OR
      # - BUGSINK_DSN=your-dsn

Development

Testing Protocol

Go Glitch includes a comprehensive test suite in build-run-test.sh that ensures all functionality works correctly:

  1. Build and Verification: The script builds the application for all supported platforms and verifies that the binaries are created.

  2. Environment Variable Tests: Each supported DSN environment variable is tested with both plain text and JSON input:

    • GLITCHTIP_DSN
    • SENTRY_DSN
    • BUGSINK_DSN
  3. Priority Tests: The script tests that when multiple environment variables are set, the correct order of precedence is followed.

  4. Webhook Tests: The server mode is tested with both single and batch webhook requests.

To run the tests, simply execute:

./build-run-test.sh

The script provides clear, color-coded output with pass/fail indicators for each test.

Contributing

Before submitting changes, please ensure that:

  1. You have run ./build-run-test.sh to verify that all tests pass
  2. Your changes maintain compatibility with all supported DSN environment variables
  3. Any new features include appropriate tests in the test suite