tracer

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SpanTypeSQL is span as SQL span
	SpanTypeSQL int = 101

	// SpanTypeRedis is span as Redis call span
	SpanTypeRedis int = 102

	// SpanTypeHTTPCall is span as HTTP call span
	SpanTypeHTTPCall int = 103

	// SpanTypeNSQPublish is a span as Message Broker NSQ Publish
	SpanTypeNSQPublish int = 104

	// SpanTypeElasticsearch is span as Elasticsarch call span
	SpanTypeElasticsearch int = 105
)

Variables

This section is empty.

Functions

func Init

func Init(cfg Config) error

Init to initialize tracing package

Types

type Config

type Config struct {
	Appname          string
	IsEnableJaeger   bool
	IsEnableNewRelic bool
	NewRelic         NewRelicConfig
}

Config config

type DBConInfo

type DBConInfo struct {
	Name string
	Host string
	Port string
}

type ISegment

type ISegment interface {
	End()
}

type NewRelicConfig

type NewRelicConfig struct {
	SecretKey string
	LogLevel  string
}

NewRelicConfig is a newrelic's config

type Options

type Options struct {
	SpanType   int
	ExtraArgs  interface{}
	ExtraParam map[string]interface{}
}

Options is options for span

func WithSQLSpan

func WithSQLSpan(query string, param map[string]interface{}) Options

WithSQLSpan returns Options for SQL

func WithSQLSpanPQInfo

func WithSQLSpanPQInfo(dbi DBConInfo, query string, param map[string]interface{}) Options

WithSQLSpanPQInfo return an Option for tracer.StartExternalSpanFromContext but with Database connection information

func WithSQLSpanWithName

func WithSQLSpanWithName(dbName, dbHost, dbPort, query string, param map[string]interface{}) Options

WithSQLSpanWithName returns Options for SQL but with the database name & host

type Span

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

Span bg at funcs

func StartExternalSpanFromContext

func StartExternalSpanFromContext(ctx context.Context, name string, opt Options) (Span, context.Context)

StartExternalSpanFromContext to start an external span. newrelic: span can be customized, either sql, redis, or http call span

func StartSpanFromContext

func StartSpanFromContext(ctx context.Context, name string) (Span, context.Context)

StartSpanFromContext create and start newrelic span from context

func (*Span) Finish

func (s *Span) Finish()

type Transaction

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

Transaction bg transaction - at http handlers

func StartTransaction

func StartTransaction(name string) (t Transaction, ctx context.Context)

StartTransaction will create new nr transaction

func StartTransactionFromContext

func StartTransactionFromContext(ctx context.Context, name string) (Transaction, context.Context)

StartTransactionFromContext to create a new nr transaction using existing context

func StartTransactionFromGinContext

func StartTransactionFromGinContext(ctx *gin.Context, name string) (Transaction, *gin.Context)

func (*Transaction) Finish

func (s *Transaction) Finish(err ...*error)

Finish finishing a span / transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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