Skip to content

Using Uptrace with OpenTelemetry Collector


Installing OpenTelemetry Collector

Configuring OTLP exporter

Now you need to configure your service to export data to the Otel Collector. By default Otel Collector is running on ports 4317 (gRPC) and 55681 (HTTP). So you need to configure OTLP exporter using the correct IP address and port:

import (
    sdktrace ""

func installOTLP(ctx context.Context) error {
    driver := otlpgrpc.NewDriver(
        // otlpgrpc.WithAddress("localhost:4317"),
    exporter, err := otlp.NewExporter(ctx,
            ForMetrics: driver,
            ForTraces:  driver,
    if err != nil {
        return err

    tracerProvider := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exporter))

    return nil

When everything is configured properly you should see the following logs in Otel Collector:

otel-collector_1  | 2021-01-15T08:33:22.571Z    INFO    loggingexporter/logging_exporter.go:313 TracesExporter  {"#spans": 1}
otel-collector_1  | 2021-01-15T08:33:24.791Z    INFO    loggingexporter/logging_exporter.go:313 TracesExporter  {"#spans": 232}