SDKs
Go
Installation

Installation

Install the Statly Observe SDK for Go applications.

Package Installation

go get github.com/KodyDennon/statly-go

Requirements

  • Go 1.18 or higher

Basic Setup

Initialize the SDK in your main() function:

package main
 
import (
    statly "github.com/KodyDennon/statly-go"
)
 
func main() {
    err := statly.Init(statly.Options{
        DSN:         "https://[email protected]/your-org",
        Environment: "production",
    })
    if err != nil {
        log.Fatal(err)
    }
    defer statly.Close()
 
    // Your application code
}

Get your DSN from Dashboard → Settings → SDK Setup.

Verify Installation

Test that events are being sent:

package main
 
import (
    statly "github.com/KodyDennon/statly-go"
)
 
func main() {
    statly.Init(statly.Options{
        DSN: "https://[email protected]/your-org",
    })
    defer statly.Close()
 
    statly.CaptureMessage("SDK installed successfully", statly.LevelInfo)
}

Check your Statly dashboard to see the test event.

With Panic Recovery

Capture panics in your main goroutine:

package main
 
import (
    statly "github.com/KodyDennon/statly-go"
)
 
func main() {
    statly.Init(statly.Options{
        DSN: "https://[email protected]/your-org",
    })
    defer statly.Close()
    defer statly.Recover() // Captures panic, flushes, then re-panics
 
    // Your application code that might panic
    riskyOperation()
}

Import Alias

The SDK uses a common import alias:

import statly "github.com/KodyDennon/statly-go"

All examples in this documentation use this alias.

Next Steps