Go

Send OpenTelemetry traces, metrics, and logs from any Go server to Sophonz using the official go.opentelemetry.io modules — no Sophonz package required.

There is no @sophonz/go-sdk, and you don't need one. Sophonz's collector speaks standard OTLP, so any Go service can send it traces, metrics, and logs by wiring up the official go.opentelemetry.io/otel modules and pointing them at Sophonz with environment variables.

What you get

  • The official Go SDK — go.opentelemetry.io/otel plus its OTLP-over-HTTP exporters for traces and logs, both of which read the standard OTEL_EXPORTER_OTLP_* environment variables with no extra configuration code.
  • Middleware instrumentation for common routers and HTTP clients — otelhttp for net/http, plus otelgin, otelecho, and similar packages for popular frameworks — that create spans for you.
  • A small, explicit setup function you write once — Go has no bytecode-weaving agent like Java, so wiring the SDK is a few lines of code rather than a flag, but it never needs to change again.

How it works

Go doesn't have a zero-code auto-instrumentation agent the way Java does — there's no bytecode to patch at runtime. Instead, you call a short setup function once at startup that:

  1. Builds a Resource describing your service (read from OTEL_SERVICE_NAME / OTEL_RESOURCE_ATTRIBUTES via resource.WithFromEnv()).
  2. Creates an OTLP HTTP trace exporter (otlptracehttp.New) and a log exporter (otlploghttp.New) — both pick up the endpoint, protocol, and headers straight from OTEL_EXPORTER_OTLP_* environment variables.
  3. Registers the resulting TracerProvider / LoggerProvider as the global providers.

From there, wrap your router or http.Handler with otelhttp.NewHandler (or the framework-specific middleware) and every request gets a span automatically.

CAUTION — Telemetry without a valid service.key is dropped silently

Sophonz's collector runs in enforce mode: it accepts the OTLP payload over the wire but silently drops anything that doesn't carry a resolvable service.key resource attribute. There's no error in your app and no rejected request — the console will simply stay empty. Double-check OTEL_RESOURCE_ATTRIBUTES (and OTEL_EXPORTER_OTLP_HEADERS) before assuming something else is broken.

TIP — Where to next

Head to Installation for the exact go get commands, the setup snippet, environment variable table, and framework notes.