Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
/ tracing-go Public archive

Package for setting up aspen mesh and istio compatible tracing

License

Notifications You must be signed in to change notification settings

aspenmesh/tracing-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuring tracing in your application

This package can be used to configure tracing in your application which is compatible with Istio and Aspen Mesh. It sets the global opentracing tracer which can be used by applications to propagate tracing headers or create new spans.

import (
  "log"

  "github.com/spf13/cobra"
  "github.com/spf13/viper"

  "github.com/aspenmesh/tracing-go"
)

func setupTracing() {
	// Configure Tracing
	tOpts := &tracing.Options{
		ZipkinURL:     viper.GetString("trace_zipkin_url"),
		JaegerURL:     viper.GetString("trace_jaeger_url"),
		LogTraceSpans: viper.GetBool("trace_log_spans"),
	}
	if err := tOpts.Validate(); err != nil {
		log.Fatal("Invalid options for tracing: ", err)
	}
	var tracer io.Closer
	if tOpts.TracingEnabled() {
		tracer, err = tracing.Configure("myapp", tOpts)
		if err != nil {
			tracer.Close()
			log.Fatal("Failed to configure tracing: ", err)
		} else {
			defer tracer.Close()
		}
	}
}

Note that most of this package is derived from the Istio tracing package.

About

Package for setting up aspen mesh and istio compatible tracing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages