Skip to Content
DocsEmitSDKGo

Go

The Chirpier SDK for Go is a simple, lightweight, and efficient SDK to emit event data to Chirpier direct from your Go applications.

Installation

Install Chirpier SDK using go get:

go get github.com/chirpier/chirpier-go

Getting Started

To start using the SDK, you need to initialize it with your API key.

Here’s a quick example of how to use the Chirpier SDK:

package main import ( "context" "fmt" "time" "github.com/chirpier/chirpier-go" ) func main() { // Initialize the Chirpier client err := chirpier.Initialize(chirpier.Options{ Key: "your-api-key", Region: "us-west", }) if err != nil { fmt.Printf("Error initializing Chirpier: %v\n", err) return } // Create and send an event err = chirpier.Monitor( context.Background(), chirpier.Event{ GroupID: "bfd9299d-817a-452f-bc53-6e154f2281fc", StreamName: "My measurement", Value: 1, }, ) if err != nil { fmt.Printf("Error monitoring event: %v\n", err) return } // Create a context with timeout to ensure proper shutdown ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() // Wait for any pending events to be sent <-ctx.Done() }

API Reference

Initialize

Initialize the Chirpier client with your API key and region. Find your API key in the Chirpier Integration page.

err := chirpier.Initialize(chirpier.Options{ Key: "your-api-key", Region: "us-west", })
  • your-api-key (str): Your Chirpier integration key
  • region (str): Your local region - options are us-west, eu-west, asia-southeast

Event

All events emitted to Chirpier must be of type Event.

event := chirpier.Event{ GroupID: "bfd9299d-817a-452f-bc53-6e154f2281fc", StreamName: "My measurement", Value: 1, }
  • group_id (str): UUID of the monitoring group
  • stream_name (str): Name of the measurement stream
  • value (float): Numeric value to record

Emit

Send an event to Chirpier using the Monitor function.

err = chirpier.Monitor(ctx, event)
Last updated on