tracing

package
v0.21.212 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 2

Documentation

Overview

Package tracing handles opentracing support for skipper

Implementations of Opentracing API can be found in the https://github.com/skipper-plugins. It follows how to implement a new tracer plugin for this interface.

The tracers, except for "noop", are built as Go Plugins. Note the warning from Go's plugin.go:

// The plugin support is currently incomplete, only supports Linux,
// and has known bugs. Please report any issues.

All plugins must have a function named "InitTracer" with the following signature

func([]string) (opentracing.Tracer, error)

The parameters passed are all arguments for the plugin, i.e. everything after the first word from skipper's -opentracing parameter. E.g. when the -opentracing parameter is "mytracer foo=bar token=xxx somename=bla:3" the "mytracer" plugin will receive

[]string{"foo=bar", "token=xxx", "somename=bla:3"}

as arguments.

The tracer plugin implementation is responsible to parse the received arguments.

An example plugin looks like

package main

import (
     basic "github.com/opentracing/basictracer-go"
     opentracing "github.com/opentracing/opentracing-go"
)

func InitTracer(opts []string) (opentracing.Tracer, error) {
     return basic.NewTracerWithOptions(basic.Options{
         Recorder:       basic.NewInMemoryRecorder(),
         ShouldSample:   func(traceID uint64) bool { return traceID%64 == 0 },
         MaxLogsPerSpan: 25,
     }), nil
}

This should be built with

go build -buildmode=plugin -o basic.so ./basic/basic.go

and copied to the given as -plugindir (by default, "./plugins").

Then it can be loaded with -opentracing basic as parameter to skipper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSpan added in v0.10.153

func CreateSpan(name string, ctx context.Context, openTracer ot.Tracer) ot.Span

CreateSpan creates a started span from an optional given parent from context

func GetTraceID added in v0.16.15

func GetTraceID(span ot.Span) string

GetTraceID retrieves TraceID from HTTP request, for example to search for this trace in the UI of your tracing solution and to get more context about it

func InitTracer added in v0.10.89

func InitTracer(opts []string) (tracer ot.Tracer, err error)

InitTracer initializes an opentracing tracer. The first option item is the tracer implementation name.

func LoadPlugin

func LoadPlugin(pluginDir string, opts []string) (ot.Tracer, error)

LoadPlugin loads the given opentracing plugin and returns an opentracing.Tracer DEPRECATED, use LoadTracingPlugin

func LoadTracingPlugin added in v0.9.185

func LoadTracingPlugin(pluginDirs []string, opts []string) (tracer ot.Tracer, err error)

func LogKV added in v0.10.153

func LogKV(k, v string, ctx context.Context)

LogKV will add a log to the span from the given context

Types

This section is empty.

Directories

Path Synopsis
tracers
Package tracingtest provides an OpenTracing implementation for testing purposes.
Package tracingtest provides an OpenTracing implementation for testing purposes.

Jump to

Keyboard shortcuts

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