istio: istio.io/istio/pkg/tracing Index | Files

package tracing

import "istio.io/istio/pkg/tracing"

Package tracing provides the canonical tracing functionality used by Go-based Istio components.

The package provides direct integration with the Cobra command-line processor which makes it easy to build programs that use a consistent interface for tracing. Here's an example of a simple Cobra-based program using this tracing package:

		func main() {
			// get the default tracing options
			options := tracing.DefaultOptions()

			rootCmd := &cobra.Command{
				Run: func(cmd *cobra.Command, args []string) {

					// configure the tracing system
					if _, err := tracing.Configure(options); err != nil {
                     // print an error and quit
                 }

					// Generate a trace
					ot.StartSpan(...)
				},
			}

			// add tracing-specific flags to the cobra command
			options.AttachCobraFlags(rootCmd)
			rootCmd.SetArgs(os.Args[1:])
			rootCmd.Execute()
		}

The point of this package is to configure the global OpenTracing tracer for the process as read from ot.GlobalTracer and used by ot.StartSpan.

Index

Package Files

config.go options.go

func Configure Uses

func Configure(serviceName string, options *Options) (io.Closer, error)

Configure initializes Istio's tracing subsystem.

You typically call this once at process startup. Once this call returns, the tracing system is ready to accept data.

type Options Uses

type Options struct {
    // URL of zipkin collector (example: 'http://zipkin:9411/api/v1/spans').
    ZipkinURL string

    // URL of jaeger HTTP collector (example: 'http://jaeger:14268/api/traces?format=jaeger.thrift').
    JaegerURL string

    // Whether or not to emit trace spans as log records.
    LogTraceSpans bool

    // SamplingRate controls the rate at which a process will decide to generate trace spans.
    SamplingRate float64
}

Options defines the set of options supported by Istio's component tracing package.

func DefaultOptions Uses

func DefaultOptions() *Options

DefaultOptions returns a new set of options, initialized to the defaults

func (*Options) AttachCobraFlags Uses

func (o *Options) AttachCobraFlags(cmd *cobra.Command)

AttachCobraFlags attaches a set of Cobra flags to the given Cobra command.

Cobra is the command-line processor that Istio uses. This command attaches the necessary set of flags to expose a CLI to let the user control all tracing options.

func (*Options) TracingEnabled Uses

func (o *Options) TracingEnabled() bool

TracingEnabled returns whether the given options enable tracing to take place.

func (*Options) Validate Uses

func (o *Options) Validate() error

Validate returns whether the options have been configured correctly or an error

Package tracing imports 12 packages (graph) and is imported by 3 packages. Updated 2019-06-12. Refresh now. Tools for package owners.