Documentation ¶
Index ¶
- Constants
- Variables
- func AddClientTags(clientSpan opentracing.Span, tags map[string]interface{}) opentracing.Span
- func CloseTracers()
- func InitConfig(conf Config)
- func InjectClientTrace(clientSpan opentracing.Span, req *http.Request)
- func InjectClientTraceWithUrlMethod(clientSpan opentracing.Span, req *http.Request, url string, method string)
- func RecordError(clientSpan opentracing.Span, err error, clientName string)
- type Config
- type Context
- type DbConfig
- type JaegerTracer
- type Logger
- type RedisConfig
Constants ¶
const ( //DefaultServiceVersion for dev environment where deployment markers aren't available DefaultServiceVersion = "debug" //ServiceVersionKey tag used in the spans for deployment markers ServiceVersionKey = "service.version" //Environment cloud environment (stage, prod, func, canary etc) Environment = "environment" //Error Error = "error" ErrorType = "error.type" ErrorStack = "error.stack" ErrorDetails = "error.details" //HTTP Request Specific HttpClientHost = "request.client_host" HttpRequestMethod = "http.method" HttpRequestHeaderPrefix = "request.header" HttpRequestQueryParamPrefix = "request.query.param" HttpStatusCode = "http.status_code" GinErrors = "gin.errors" //Database Specific DBTable = "db.table" DbMethod = "db.method" DbError = "db.err" DbCount = "db.count" //Http Response Specific HttpResponseStatus = "response.status_code" HttpPath = "http.path" )
Variables ¶
var ( DBPeerService string // Database HostName DBHostName string // Database port DBPort uint16 RedisPeerService string // Redis Hostname RedisHostName string // Redis Port RedisPort uint16 // Don't remove the following. This will be used for deployment markers. RTFM ServiceVersion string //Git Commit Hash / Service Version ContextPropogationKey string ContextKey string DefaultContextPropogationValue string BaggagePrefix string BaggageKeys string )
var RequestHeaderExclusions = map[string]bool{}
Exclude the following request headers from going into the spans from the http headers
var RequestQueryParamExclusions = map[string]bool{}
Exclude the following query params from going into the spans from the http headers
var RouteURLsToExclude []string
Functions ¶
func AddClientTags ¶
func AddClientTags(clientSpan opentracing.Span, tags map[string]interface{}) opentracing.Span
Helper method for adding a map of client tags to the given span object
func InitConfig ¶
func InitConfig(conf Config)
func InjectClientTrace ¶
Helper method for injecting traces for remote http calls
func InjectClientTraceWithUrlMethod ¶
func InjectClientTraceWithUrlMethod(clientSpan opentracing.Span, req *http.Request, url string, method string)
Another helper method for injecting traces explictly with request object, url and http method
func RecordError ¶
Helper method to record application errors into traces
Types ¶
type Config ¶
type Config struct { ServiceName string ServiceVersion string Env string JaegerHostName string JaegerPort string Enabled bool EnableDebug bool RequestHeaderExclusions map[string]bool RequestQueryParamExclusions map[string]bool RouteURLsToExclude []string Logger Logger PrometheusRegister prometheus.Registerer Database DbConfig Redis RedisConfig Context Context }
type JaegerTracer ¶
type JaegerTracer struct { // Tracer is a simple, thin interface for Span creation and SpanContext Tracer opentracing.Tracer // Interface for wrapping close methods when closing the tracer Closer io.Closer }
Tracer instance
func InitAppTracer ¶
func InitAppTracer(serviceName string) *JaegerTracer
* Initializes global app tracer Initializer and sets tracing configs of peer services also. * * To be called from main/init of the application, before calling InitTracing from anywhere else. * opentracing.StartSpan would start span on this tracer, by default
func InitTracing ¶
func InitTracing(serviceName string) *JaegerTracer
* General Tracer Initializer. * To be called from init of any datastore like mysql/redis etc * * Environment determines the actual appearance on the jaeger UI * (e.g. {application}-prod, {application}-stage, {application}-canary etc
func (*JaegerTracer) GetCloser ¶
func (tr *JaegerTracer) GetCloser() io.Closer
Return Closer interface. Useful for flushing the spans when needed or closing it during application shutdown
func (*JaegerTracer) GetTracer ¶
func (tr *JaegerTracer) GetTracer() opentracing.Tracer
Get the opentracing object from the tracer