opentracing

package
v0.0.0-...-0f65a33 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JaegerConfig struct {
	AgentUrl     string  `json:"agent_url"`
	CollectorUrl string  `json:"collector_url"`
	Probability  float64 `json:"probability"`
}

jaeger 相关配置信息

Functions

func GetTraceInfoFromContext

func GetTraceInfoFromContext(ctx context.Context) (traceId, pSpanId, spanId string)

从 context 获取 trace 信息

func JaegerTrace

func JaegerTrace(next echo.HandlerFunc) echo.HandlerFunc

jaeger 中间件,用于对每个请求生成一个span,并使用opentracing生成的spanID作为日志的spanID

func NewTracer

func NewTracer(serviceName string, options ...config.Option) (closer io.Closer, err error)

返回一个 Jaeger Trace,可以传入option 自定义采样

Types

type CountRecord

type CountRecord struct {
	Option metrics.Options `json:"option"`
	Count  int64           `json:"count"`
}

自定义实现 metric 的类型

func (*CountRecord) Inc

func (c *CountRecord) Inc(n int64)

type GaugeRecord

type GaugeRecord struct {
	Option      metrics.Options `json:"option"`
	RecordValue int64           `json:"record_value"`
}

func (*GaugeRecord) Update

func (g *GaugeRecord) Update(n int64)

type HistogramRecord

type HistogramRecord struct {
	Option      metrics.HistogramOptions `json:"option"`
	RecordValue float64                  `json:"record_value"`
}

func (*HistogramRecord) Record

func (h *HistogramRecord) Record(n float64)

type Metric

type Metric struct {
	CounterRecord   []*CountRecord     `json:"counter_record,omitempty"`
	TimerRecord     []*TimeRecord      `json:"timer_record,omitempty"`
	GaugeRecord     []*GaugeRecord     `json:"gauge_record,omitempty"`
	HistogramRecord []*HistogramRecord `json:"histogram_record,omitempty"`
	NamespaceRecord []*NamespaceRecord `json:"namespace_record,omitempty"`
}

自定义集中式度量系统 metrics

func GetNewMetric

func GetNewMetric() *Metric

生成 metric 对象

func (*Metric) Counter

func (m *Metric) Counter(metric metrics.Options) metrics.Counter

func (*Metric) Gauge

func (m *Metric) Gauge(metric metrics.Options) metrics.Gauge

func (*Metric) Histogram

func (m *Metric) Histogram(metric metrics.HistogramOptions) metrics.Histogram

func (*Metric) Namespace

func (m *Metric) Namespace(scope metrics.NSOptions) metrics.Factory

func (*Metric) PrintLog

func (m *Metric) PrintLog()

这里可以设置定时打印 metric 信息

func (*Metric) Timer

func (m *Metric) Timer(metric metrics.TimerOptions) metrics.Timer

type NamespaceRecord

type NamespaceRecord struct {
	Namespace metrics.NSOptions `json:"namespace"`
	SubMetric *Metric           `json:"sub_metric"`
}

type TimeRecord

type TimeRecord struct {
	Option     metrics.TimerOptions `json:"option"`
	RecordTime time.Duration        `json:"record_time"`
}

func (*TimeRecord) Record

func (t *TimeRecord) Record(dur time.Duration)

Jump to

Keyboard shortcuts

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