zipkin

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPTagAttributeRoute = "http.route"
	HTTPTagMethod         = "http.method"
	HTTPTagPath           = "http.path"
	HTTPTagStatusCode     = "http.status_code"
	HTTPTagScriptFilename = "http.script.filename"
	HTTPTagClientAddress  = "Client Address"

	MysqlTagSQL = "sql"
	MysqlTagURL = "url"

	RedisTagMethod = "redis.method"

	ElasticsearchTagIndex     = "es.index"
	ElasticsearchTagOperation = "es.operation"
	ElasticsearchTagBody      = "es.body"

	KafkaTagTopic  = "kafka.topic"
	KafkaTagKey    = "kafka.key"
	KafkaTagOroker = "kafka.broker"

	RabbitTagExchange   = "rabbit.exchange"
	RabbitTagRoutingKey = "rabbit.routing_key"
	RabbitTagQueue      = "rabbit.queue"
	RabbitTagBroker     = "rabbit.broker"

	MongodbTagCommand    = "mongodb.command"
	MongodbTagCollection = "mongodb.collection"
	MongodbTagClusterID  = "mongodb.cluster_id"
)

For details, please see https://github.com/megaease/easeagent-sdk-go/blob/main/doc/middleware-span.md

View Source
const (
	MiddlewareTag string         = "component.type"
	MySQL         MiddlewareType = "mysql"
	Redis         MiddlewareType = "redis"
	ElasticSearch MiddlewareType = "elasticsearch"
	Kafka         MiddlewareType = "kafka"
	RabbitMQ      MiddlewareType = "rabbitmq"
	MongoDB       MiddlewareType = "mongodb"
)

decorate a special type Span by tag

View Source
const (
	// Kind is the kind of Zipkin plugin.
	Kind = "Zipkin"
	// Name is the name of Zipkin plugin.
	Name = "Zipkin"
)

Variables

This section is empty.

Functions

func DefaultSpec

func DefaultSpec() plugins.Spec

DefaultSpec returns the default spec of Zipkin.

func New

func New(pluginSpec plugins.Spec) (plugins.Plugin, error)

New creates a new Zipkin plugin.

func NewEndpoint

func NewEndpoint(serviceName string, hostPort string) (*model.Endpoint, error)

NewEndpoint new a model.Endpoint

func NewEndpointByName

func NewEndpointByName(serviceName string) *model.Endpoint

NewEndpointByName new a model.Endpoint by service name

Types

type AuthTransport

type AuthTransport struct {
	// contains filtered or unexported fields
}

AuthTransport is a http.RoundTripper that adds basic auth to requests.

func (*AuthTransport) RoundTrip

func (a *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip adds basic auth to the request.

type HTTPClientWrapper

type HTTPClientWrapper struct {
	// contains filtered or unexported fields
}

HTTPClientWrapper is the wrapper of http.Client.

func (*HTTPClientWrapper) Do

func (c *HTTPClientWrapper) Do(req *http.Request) (*http.Response, error)

Do implements plugins.HTTPDoer.

type HTTPHandlerWrapper

type HTTPHandlerWrapper struct {
	// contains filtered or unexported fields
}

HTTPHandlerWrapper is the wrapper of http.Handler.

func (*HTTPHandlerWrapper) ServeHTTP

func (h *HTTPHandlerWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MiddlewareType

type MiddlewareType string

MiddlewareType A special type about middleware

func (MiddlewareType) TagValue

func (t MiddlewareType) TagValue() string

TagValue return the middleware tag value for decorate Span

type Span

type Span struct {
	SpanModel `json:",inline"`
	Type      string `json:"type,omitempty"`
	Service   string `json:"service,omitempty"`
}

Span represents a Zipkin span.

func (Span) MarshalJSON

func (s Span) MarshalJSON() ([]byte, error)

MarshalJSON exports our Model into the correct format for the Zipkin V2 API.

func (*Span) UnmarshalJSON

func (s *Span) UnmarshalJSON(b []byte) error

UnmarshalJSON imports our Model from a Zipkin V2 API compatible span representation.

type SpanModel

type SpanModel model.SpanModel

SpanModel is for override MarshalJSON

type Spec

type Spec struct {
	plugins.BaseSpec `json:",inline"`

	OutputServerURL string `json:"reporter.output.server"`

	EnableTLS bool   `json:"reporter.output.server.tls.enable"`
	TLSKey    string `json:"reporter.output.server.tls.key"`
	TLSCert   string `json:"reporter.output.server.tls.cert"`
	TLSCaCert string `json:"reporter.output.server.tls.caCert"`

	EnableBasicAuth bool   `json:"reporter.output.server.auth.enable"`
	Username        string `json:"reporter.output.server.auth.username"`
	Password        string `json:"reporter.output.server.auth.password"`

	ServiceName   string            `json:"serviceName"`
	TracingType   string            `json:"tracing.type"`
	LocalHostport string            `json:"-"`
	Tags          map[string]string `json:"-"`

	EnableTracing bool    `json:"tracing.enable" jsonschema:"required,minimum=0,maximum=1"`
	SampleRate    float64 `json:"tracing.sample.rate" jsonschema:"required,minimum=0,maximum=1"`
	SharedSpans   bool    `json:"tracing.shared.spans"`
	ID128Bit      bool    `json:"tracing.id128bit"`
}

Spec is the Zipkin spec.

func NewConsoleReportSpec

func NewConsoleReportSpec(localHostPort string) Spec

NewConsoleReportSpec new a Console Reporter Spec

func (Spec) Validate

func (spec Spec) Validate() error

Validate validates the Zipkin spec.

type Tracing

type Tracing interface {
	//get zipkin Tracer
	Tracer() *zipkin.Tracer
	//start a Span from parent
	StartSpan(parent zipkin.Span, name string, options ...zipkin.SpanOption) zipkin.Span
	//start a Span from context.Context
	StartSpanFromCtx(parent context.Context, name string, options ...zipkin.SpanOption) (zipkin.Span, context.Context)
	//start a middleware span from parent
	StartMWSpan(parent zipkin.Span, name string, mwType MiddlewareType, options ...zipkin.SpanOption) zipkin.Span
	//start a middleware span from context.Context
	StartMWSpanFromCtx(parent context.Context, name string, mwType MiddlewareType, options ...zipkin.SpanOption) (zipkin.Span, context.Context)
}

Tracing the tracing interface

type Zipkin

type Zipkin struct {
	// contains filtered or unexported fields
}

Zipkin is the Zipkin dedicated plugin.

func (*Zipkin) Close

func (z *Zipkin) Close() error

Close closes the plugin.

func (*Zipkin) Name

func (z *Zipkin) Name() string

Name gets the zipkin name

func (*Zipkin) StartMWSpan

func (z *Zipkin) StartMWSpan(parent zipkin.Span, name string, mwType MiddlewareType, options ...zipkin.SpanOption) zipkin.Span

StartMWSpan start a middleware span from parent

func (*Zipkin) StartMWSpanFromCtx

func (z *Zipkin) StartMWSpanFromCtx(parent context.Context, name string, mwType MiddlewareType, options ...zipkin.SpanOption) (zipkin.Span, context.Context)

StartMWSpanFromCtx start a middleware span from context.Context

func (*Zipkin) StartSpan

func (z *Zipkin) StartSpan(parent zipkin.Span, name string, options ...zipkin.SpanOption) zipkin.Span

StartSpan start a Span from parent

func (*Zipkin) StartSpanFromCtx

func (z *Zipkin) StartSpanFromCtx(parent context.Context, name string, options ...zipkin.SpanOption) (zipkin.Span, context.Context)

StartSpanFromCtx start a Span from context.Context

func (*Zipkin) Tracer

func (z *Zipkin) Tracer() *zipkin.Tracer

Tracer gets the zipkin.Tracer

func (*Zipkin) WrapUserClient

func (z *Zipkin) WrapUserClient(c plugins.HTTPDoer) plugins.HTTPDoer

WrapUserClient wraps the http client.

func (*Zipkin) WrapUserClientRequest

func (z *Zipkin) WrapUserClientRequest(current context.Context, req *http.Request) *http.Request

WrapUserClientRequest wraps the user's http request.

func (*Zipkin) WrapUserHandlerFunc

func (z *Zipkin) WrapUserHandlerFunc(handlerFunc http.HandlerFunc) http.HandlerFunc

WrapUserHandlerFunc wraps the user's http handler.

Jump to

Keyboard shortcuts

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