← Back to reference

Go Sdk Reference

Install

go get github.com/denpex/denpex-sdk-go

Modules

  • client — HTTP + OTLP client.
  • otlp — OTLP submission.
  • cmd/denpex-cli — CLI for the same commands as the Python SDK.

Usage

import (
    "github.com/denpex/denpex-sdk-go/client"
    "github.com/denpex/denpex-sdk-go/otlp"
)

func main() {
    c := client.New("https://api.denpex.ai", "<token>", "<tenant_id>")
    incidents, err := c.ListIncidents(ctx, client.IncidentQuery{
        State: client.IncidentStateOpen,
        Limit: 25,
    })
    if err != nil {
        log.Fatal(err)
    }
    for _, inc := range incidents.Nodes {
        fmt.Printf("%s: %s on %s\n", inc.Severity, inc.Host, inc.ID)
    }

    // Submit OTLP telemetry
    sink := otlp.NewHTTPSink("https://denpex-cp.example.com:4318")
    sink.Submit(ctx, otlp.Envelope{ /* ResourceLogs, etc. */ })
}

CLI

denpex-cli incident list
denpex-cli incident show <id>
denpex-cli incident approve <id>
denpex-cli checkpoint validate --path <path>
denpex-cli rank map

Configuration

Env varPurpose
DENPEX_TOKENAuth token
DENPEX_TENANTTenant ID
DENPEX_OTLP_ENDPOINTOTLP HTTPS endpoint
DENPEX_INSECURE_SKIP_VERIFYSkip TLS verify (debug only)

Compatibility

  • Go 1.22+.

Tests

denpex-sdk-go/tests/:

  • 3 unit tests per module.
  • 1 integration test against a mock OTLP receiver.