|
||
---|---|---|
build_logs | ||
dist | ||
.gitignore | ||
README.md | ||
build-run-test.sh | ||
build.sh | ||
go.mod | ||
go.sum | ||
install.sh | ||
log.log | ||
main.go | ||
test.sh |
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 instancesSENTRY_DSN
: For Sentry instancesBUGSINK_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:
-
Build and Verification: The script builds the application for all supported platforms and verifies that the binaries are created.
-
Environment Variable Tests: Each supported DSN environment variable is tested with both plain text and JSON input:
GLITCHTIP_DSN
SENTRY_DSN
BUGSINK_DSN
-
Priority Tests: The script tests that when multiple environment variables are set, the correct order of precedence is followed.
-
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:
- You have run
./build-run-test.sh
to verify that all tests pass - Your changes maintain compatibility with all supported DSN environment variables
- Any new features include appropriate tests in the test suite