opentracing

package module
v0.32.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

client-middleware/opentracing

GoDoc

OpenTracing instrumentation for the go-openapi/runtime client transport.

Compatibility module. This module exists solely to support users who still depend on the legacy OpenTracing API and have not yet migrated to OpenTelemetry. New code should use the OpenTelemetry tracing built into client.Runtime directly — it requires no extra wrapper.

The OpenTracing project has been archived since 2022 in favour of OpenTelemetry. We expect to keep this module compiling and passing tests, but it will not gain new features.

It is published as a separate Go module so that the opentracing-go dependency stays out of the main runtime's import graph — projects on OpenTelemetry pay no cost for it.

Install

go get github.com/go-openapi/runtime/client-middleware/opentracing

Usage

WithOpenTracing wraps a client.Runtime and starts a child span for each outgoing operation, provided the operation's context.Context already carries a parent span. If no parent span is found in the context, the call is forwarded unchanged.

import (
    "github.com/go-openapi/runtime/client"
    otmw "github.com/go-openapi/runtime/client-middleware/opentracing"
)

rt := client.New("api.example.com", "/v1", []string{"https"})
transport := otmw.WithOpenTracing(rt)

// pass `transport` (a runtime.ClientTransport) to your generated client

Per-request tags can be added through the variadic opentracing.StartSpanOption arguments:

transport := otmw.WithOpenTracing(rt, opentracing.Tag{Key: "service", Value: "billing"})

Migrating to OpenTelemetry

The main client.Runtime already emits OpenTelemetry spans; no wrapper is needed. Users coming from this module typically:

  1. Replace the opentracing-go Tracer setup with an OpenTelemetry TracerProvider.
  2. Drop the WithOpenTracing wrapper — instrument the client.Runtime directly.
  3. Remove the import of this module.

See the main runtime README for the OpenTelemetry configuration entry points.

License

Apache-2.0.

Documentation

Overview

Package opentracing supports opentracing instrumentation for the runtime client.

It is provided for backward-compatibility for users who can't transition to OTEL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithOpenTracing

func WithOpenTracing(r *client.Runtime, opts ...opentracing.StartSpanOption) runtime.ClientTransport

WithOpenTracing adds opentracing support to the provided runtime. A new client span is created for each request.

If the context of the client operation does not contain an active span, no span is created. The provided opts are applied to each spans - for example to add global tags.

This method is provided to continue supporting users of github.com/go-openapi/runtime who still rely on opentracing and have not been able to transition to opentelemetry yet.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL