zipkin

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2020 The micro-boot Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultBoundarySamplerRate

func SetDefaultBoundarySamplerRate(rate float64)

func SetDefaultBoundarySamplerSalt

func SetDefaultBoundarySamplerSalt(salt int64)

func SetDefaultCountingSamplerRate

func SetDefaultCountingSamplerRate(rate float64)

func SetDefaultModuloSamplerMod

func SetDefaultModuloSamplerMod(mod uint64)

func SetDefaultReporterBatchInterval

func SetDefaultReporterBatchInterval(d time.Duration)

func SetDefaultReporterBatchSize

func SetDefaultReporterBatchSize(num int)

func SetDefaultReporterFlagsPrefix

func SetDefaultReporterFlagsPrefix(prefix string)

func SetDefaultReporterMaxBacklog

func SetDefaultReporterMaxBacklog(num int)

func SetDefaultReporterTimeout

func SetDefaultReporterTimeout(d time.Duration)

func SetDefaultTracerAlwaysSample

func SetDefaultTracerAlwaysSample(b bool)

func SetDefaultTracerExtractFailurePolicy

func SetDefaultTracerExtractFailurePolicy(policy zipkin.ExtractFailurePolicy)

func SetDefaultTracerFlagsPrefix

func SetDefaultTracerFlagsPrefix(prefix string)

func SetDefaultTracerGenerator

func SetDefaultTracerGenerator(generator bootflag.ZipkinIDGenerator)

func SetDefaultTracerNeverSample

func SetDefaultTracerNeverSample(b bool)

func SetDefaultTracerNoop

func SetDefaultTracerNoop(b bool)

func SetDefaultTracerNoopSpan

func SetDefaultTracerNoopSpan(b bool)

func SetDefaultTracerSharedSpans

func SetDefaultTracerSharedSpans(b bool)

func SetDefaultTracerTags

func SetDefaultTracerTags(tags map[string]string)

func SetDefaultZipkinFlagsPrefix

func SetDefaultZipkinFlagsPrefix(prefix string)

Types

type BoundarySampler

type BoundarySampler struct {
	Rate float64 `json:"rate" yaml:"rate"`
	Salt int64   `json:"salt" yaml:"salt"`
}

BoundarySampler is the settings of boundary sampler for creating a standard zipkin boundary sampler

type Config

type Config struct {
	// Bridge uses Zipkin OpenTracing bridge instead of native implementation
	Bridge bool `json:"bridge" yaml:"bridge"`

	// Tracer is the settings for Golang official Zipkin client tracer implementation.
	Tracer Tracer `json:"tracer" yaml:"tracer"`

	Reporter Reporter `json:"reporter" yaml:"reporter"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

func (*Config) BindFlags

func (c *Config) BindFlags(fs *bootflag.FlagSet)

func (*Config) Parse

func (c *Config) Parse() (err error)

func (Config) StandardReporter

func (c Config) StandardReporter() reporter.Reporter

func (Config) WithAlwaysSampler

func (c Config) WithAlwaysSampler() zipkin.TracerOption

WithAlwaysSampler is the same as zipkin.WithSampler(zipkin.AlwaysSampler) in official Golang client.

func (Config) WithBoundarySampler

func (c Config) WithBoundarySampler() (zipkin.TracerOption, error)

WithBoundarySampler is the same as zipkin.WithSampler(zipkin.NewBoundarySampler(rate, salt)) in official Golang client.

func (Config) WithCountingSampler

func (c Config) WithCountingSampler() (zipkin.TracerOption, error)

WithCountingSampler is the same as zipkin.WithSampler(zipkin.NewModuloSampler(mod)) in official Golang client.

func (Config) WithExtractFailurePolicy

func (c Config) WithExtractFailurePolicy() zipkin.TracerOption

WithExtractFailurePolicy allows one to set the ExtractFailurePolicy.

func (Config) WithIDGenerator

func (c Config) WithIDGenerator() zipkin.TracerOption

WithIDGenerator allows one to set a custom ID Generator

func (Config) WithLocalEndpoint

func (c Config) WithLocalEndpoint() (zipkin.TracerOption, error)

WithLocalEndpoint sets the local endpoint of the tracer or returns a error if fail to create an Endpoint instance

func (Config) WithModuloSampler

func (c Config) WithModuloSampler() (zipkin.TracerOption, error)

WithModuloSampler is the same as zipkin.WithSampler(zipkin.NewModuloSampler(mod)) in official Golang client.

func (Config) WithNeverSampler

func (c Config) WithNeverSampler() zipkin.TracerOption

WithNeverSampler is the same as zipkin.WithSampler(zipkin.NeverSample) in official Golang client.

func (Config) WithNoopSpan

func (c Config) WithNoopSpan() zipkin.TracerOption

WithNoopSpan if set to true will switch to a NoopSpan implementation if the trace is not sampled.

func (Config) WithSharedSpans

func (c Config) WithSharedSpans() zipkin.TracerOption

WithSharedSpans allows to place client-side and server-side annotations for a RPC call in the same span (Zipkin V1 behavior) or different spans (more in line with other tracing solutions). By default this Tracer uses shared host spans (so client-side and server-side in the same span).

type CountingSampler

type CountingSampler struct {
	Rate float64 `json:"rate" yaml:"rate"`
}

CountingSampler is the settings of counting sampler for creating a standard zipkin counting sampler

type LocalEndpoint

type LocalEndpoint struct {
	// Name is the service name which used to create a local endpoint
	Name string `json:"name" yaml:"name"`

	// HostPort is the host port which used to create a local endpoint
	HostPort string `json:"address" yaml:"address"`
}

LocalEndpoint is the settings for creating a standard Zipkin local endpoint

func (LocalEndpoint) Standardize

func (le LocalEndpoint) Standardize() (*model.Endpoint, error)

type ModuloSampler

type ModuloSampler struct {
	Mod uint64 `json:"mod" yaml:"mod"`
}

ModuloSampler is the settings of modulo sampler for creating a standard zipkin module sampler

type Reporter

type Reporter struct {
	// URL enables Zipkin tracing via HTTP reporter URL e.g. http://localhost:9411/api/v2/spans
	URL string `json:"url" yaml:"url"`

	// Timeout sets maximum timeout for the http request through its context.
	Timeout time.Duration `json:"timeout" yaml:"timeout"`

	// BatchSize sets the maximum batch size, after which a collect will be
	// triggered. The default batch size is 100 traces.
	BatchSize int `json:"batch-size" yaml:"batch-size"`

	// MaxBacklog sets the maximum backlog size. When batch size reaches this
	// threshold, spans from the beginning of the batch will be disposed.
	MaxBacklog int `json:"max-backlog" yaml:"max-backlog"`

	// BatchInterval sets the maximum duration we will buffer traces before
	// emitting them to the collector. The default batch interval is 1 second.
	BatchInterval time.Duration `json:"batch-interval" yaml:"batch-interval"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

Reporter is the settings for official Zipkin Golang client reporter instance.

func (*Reporter) BindFlags

func (r *Reporter) BindFlags(fs *bootflag.FlagSet)

func (*Reporter) Parse

func (r *Reporter) Parse() (err error)

func (Reporter) Standardize

func (r Reporter) Standardize() reporter.Reporter

func (Reporter) WithBatchInterval

func (r Reporter) WithBatchInterval() httpreporter.ReporterOption

BatchInterval sets the maximum duration we will buffer traces before emitting them to the collector. The default batch interval is 1 second.

func (Reporter) WithBatchSize

func (r Reporter) WithBatchSize() httpreporter.ReporterOption

BatchSize sets the maximum batch size, after which a collect will be triggered. The default batch size is 100 traces.

func (Reporter) WithMaxBacklog

func (r Reporter) WithMaxBacklog() httpreporter.ReporterOption

MaxBacklog sets the maximum backlog size. When batch size reaches this threshold, spans from the beginning of the batch will be disposed.

func (Reporter) WithTimeout

func (r Reporter) WithTimeout() httpreporter.ReporterOption

Timeout sets maximum timeout for the http request through its context.

type Sampler

type Sampler struct {
	// AlwaysSample will always return true. If used by a service it will always start
	// traces if no upstream trace has been propagated. If an incoming upstream trace
	// is not sampled the service will adhere to this and only propagate the context.
	AlwaysSample bool `json:"always" yaml:"always"`

	// NeverSample will always return false. If used by a service it will not allow
	// the service to start traces but will still allow the service to participate
	// in traces started upstream.
	NeverSample bool `json:"never" yaml:"never"`

	// BoundarySampler is the settings of boundary sampler for
	// creating a standard zipkin boundary sampler
	BoundarySampler BoundarySampler `json:"boundary" yaml:"boundary"`

	// ModuloSampler is the settings of modulo sampler for creating a standard zipkin
	// module sampler
	ModuloSampler ModuloSampler `json:"modulo" yaml:"modulo"`

	// CountingSampler is the settings of counting sampler for creating a standard zipkin
	// counting sampler
	CountingSampler CountingSampler `json:"counting" yaml:"counting"`
}

Sampler specifies a sample policy if a Zipkin span should be sampled, based on its traceID.

type Span

type Span struct {
	Noop        bool `json:"noop-span" yaml:"noop-span"`
	SharedSpans bool `json:"shared-spans" yaml:"shared-spans"`
}

type Tracer

type Tracer struct {
	// ExtractFailurePolicy deals with Extraction errors:
	//
	// 0 for ExtractFailurePolicyRestart
	//
	// 1 for ExtractFailurePolicyError
	//
	// 2 for ExtractFailurePolicyTagAndRestart
	ExtractFailurePolicy zipkin.ExtractFailurePolicy `json:"extract-failure-policy" yaml:"extract-failure-policy"`

	// LocalEndpoint is the settings for creating a standard Zipkin local endpoint
	LocalEndpoint LocalEndpoint `json:"endpoint" yaml:"endpoint"`

	// Generator interface can be used to provide the Zipkin Tracer with custom
	// implementations to generate Span and Trace IDs.
	Generator idgenerator.IDGenerator `json:"generator" yaml:"generator"`

	// Tags allows one to set default tags to be added to each created span
	Tags map[string]string `json:"tags" yaml:"tags"`

	// Noop allows one to start the zipkin tracer as noop implementation.
	Noop bool `json:"noop" yaml:"noop"`

	// Sampler is the sample policy for a zipkin tracer
	Sampler Sampler `json:"sampler" yaml:"sampler"`

	Span Span `json:"span" yaml:"span"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

Tracer is the settings for Golang official Zipkin client tracer implementation.

func (*Tracer) BindFlags

func (t *Tracer) BindFlags(fs *bootflag.FlagSet)

func (*Tracer) Parse

func (t *Tracer) Parse() (err error)

func (Tracer) WithAlwaysSampler

func (t Tracer) WithAlwaysSampler() zipkin.TracerOption

WithAlwaysSampler is the same as zipkin.WithSampler(zipkin.AlwaysSampler) in official Golang client.

func (Tracer) WithBoundarySampler

func (t Tracer) WithBoundarySampler() (zipkin.TracerOption, error)

WithBoundarySampler is the same as zipkin.WithSampler(zipkin.NewBoundarySampler(rate, salt)) in official Golang client.

func (Tracer) WithCountingSampler

func (t Tracer) WithCountingSampler() (zipkin.TracerOption, error)

WithCountingSampler is the same as zipkin.WithSampler(zipkin.NewModuloSampler(mod)) in official Golang client.

func (Tracer) WithExtractFailurePolicy

func (t Tracer) WithExtractFailurePolicy() zipkin.TracerOption

WithExtractFailurePolicy allows one to set the ExtractFailurePolicy.

func (Tracer) WithIDGenerator

func (t Tracer) WithIDGenerator() zipkin.TracerOption

WithIDGenerator allows one to set a custom ID Generator

func (Tracer) WithLocalEndpoint

func (t Tracer) WithLocalEndpoint() (zipkin.TracerOption, error)

WithLocalEndpoint sets the local endpoint of the tracer or returns a error if fail to create an Endpoint instance

func (Tracer) WithModuloSampler

func (t Tracer) WithModuloSampler() (zipkin.TracerOption, error)

WithModuloSampler is the same as zipkin.WithSampler(zipkin.NewModuloSampler(mod)) in official Golang client.

func (Tracer) WithNeverSampler

func (t Tracer) WithNeverSampler() zipkin.TracerOption

WithNeverSampler is the same as zipkin.WithSampler(zipkin.NeverSample) in official Golang client.

func (Tracer) WithNoopSpan

func (t Tracer) WithNoopSpan() zipkin.TracerOption

WithNoopSpan if set to true will switch to a NoopSpan implementation if the trace is not sampled.

func (Tracer) WithSharedSpans

func (t Tracer) WithSharedSpans() zipkin.TracerOption

WithSharedSpans allows to place client-side and server-side annotations for a RPC call in the same span (Zipkin V1 behavior) or different spans (more in line with other tracing solutions). By default this Tracer uses shared host spans (so client-side and server-side in the same span).

Jump to

Keyboard shortcuts

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