Forked go-glitch for go-sink
Go to file
Leopere 5c49cadb5e Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
build_logs Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
dist Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
.gitignore Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
README.md Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -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 16:10:16 -04:00
build.sh Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
go.mod Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
go.sum Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
install.sh Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
log.log Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
main.go Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
test.sh Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00
version.go Initial release v0.0.1: go-sink - A tool for sending logs to error tracking systems 2025-04-14 16:10:16 -04:00

README.md

You can stream and read files to a BugSink DSN, GlitchTip, or Sentry. 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 Sink

Go Sink is a command-line utility that reads log messages from a file or stdin and sends them to BugSink, GlitchTip, 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:

# For the latest stable version
curl -sSL https://git.nixc.us/Nixius/go-sink/raw/tag/v0.0.1/install.sh | bash

# Or to install a specific version (replace v0.0.1 with your desired version)
curl -sSL https://git.nixc.us/Nixius/go-sink/raw/tag/v0.0.1/install.sh | bash

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

Usage

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

Using a Log File

go-sink /path/to/logfile

Using Piped Input

cat /path/to/logfile | go-sink

Server Mode

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

go-sink 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 Sink supports multiple environment variables for the DSN. You can use any of the following:

  • BUGSINK_DSN: For BugSink instances
  • GLITCHTIP_DSN: For GlitchTip instances
  • SENTRY_DSN: For Sentry 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 BUGSINK_DSN="your-dsn"
# OR
export GLITCHTIP_DSN="your-dsn"
# OR
export SENTRY_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 BUGSINK_DSN=your-dsn
# OR
ENV GLITCHTIP_DSN=your-dsn
# OR
ENV SENTRY_DSN=your-dsn

docker-compose.yml

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

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

Development

Testing Protocol

Go Sink 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:

    • BUGSINK_DSN
    • GLITCHTIP_DSN
    • SENTRY_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