Features

Telemetry & Observability

Ship traces, metrics and trace-correlated logs to Grafana, Jaeger or any OTLP backend zero-code with Ginboot's telemetry integration.

Telemetry & Observability

Ginboot provides zero-code-boilerplate OpenTelemetry integration. Simply define your telemetry configuration in ginboot.yml or set standard OTEL_* environment variables in .env — Ginboot automatically initializes OpenTelemetry tracing, metrics, request IDs, and trace-correlated logging pipelines.


1. Zero-Boilerplate Configuration (ginboot.yml)

You do not need to write manual telemetry setup or shutdown code in main.go. Define telemetry options declaratively in ginboot.yml:

ginboot:
  telemetry:
    enabled: true
    service-name: order-service
    service-version: v1.0.0
    environment: production
    exporter: otlp
    endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:https://otlp-gateway-prod.grafana.net/otlp}
    headers: ${OTEL_EXPORTER_OTLP_HEADERS}
    protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf}
    resource-attributes: ${OTEL_RESOURCE_ATTRIBUTES}

2. Standard OpenTelemetry Environment Variables (.env)

Ginboot automatically inspects and loads standard OpenTelemetry environment variables:

# OTLP Endpoint (Grafana Cloud, Jaeger, Datadog, or Ginboot Cloud)
OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp-gateway-prod.grafana.net/otlp"

# OTLP Headers (Basic Auth / Bearer tokens)
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic%20MTEyNj..."

# OTLP Protocol
OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"

# Standard Resource Attributes
OTEL_RESOURCE_ATTRIBUTES="service.name=order-service,service.version=v1.0.0,deployment.environment=production"

3. Minimal Application main.go

With zero-code telemetry initialization, your application entry point stays clean and readable:

package main

import (
	"log"
	"github.com/klass-lk/ginboot"
	"github.com/klass-lk/ginboot/internal/controller"
)

func main() {
	// Automatically loads .env, ginboot.yml, and configures OTLP telemetry
	server := ginboot.New()

	server.RegisterController("/orders", controller.NewOrderController())

	log.Fatal(server.Start(8080))
}

4. Key Capabilities

  • Distributed Tracing: Automatically injects W3C Trace Context headers into incoming and outgoing service requests (traceparent).
  • Context-Correlated Logging: Controller logs using ctx.Logger().Info("Created order") are automatically enriched with active trace_id and span_id.
  • System & Runtime Metrics: Automatically collects HTTP request duration histograms, error rates, and Go runtime memory stats.

On this page