Documentation ¶
Index ¶
- Variables
- func GetSpanFromGinContex(funcName string, c *gin.Context) (opentracing.Span, context.Context)
- func GetTraceIdFromSpanContext(spanCtx opentracing.SpanContext) string
- func InitDevelopment(tracingAgentHostPort []byte)
- func InitMacDocker(tracingAgentHostPort []byte)
- func InitProduction(sampleProbability float64, tracingAgentHostPort []byte)
- func InitTracing(serviceName string, tracingAgentHostPort string, opt ...Option) (tracer opentracing.Tracer, reporter jaeger.Reporter, closer io.Closer, ...)
- func InjectTraceID(ctx opentracing.SpanContext, header http.Header) error
- func StartDBSpanWithParent(parent opentracing.SpanContext, ...) opentracing.Span
- func StartSpan(operationName, method, path string) opentracing.Span
- func StartSpanWithHeader(header *http.Header, operationName, method, path string) opentracing.Span
- func StartSpanWithParent(parent opentracing.SpanContext, operationName, method, path string) opentracing.Span
- type Option
Constants ¶
This section is empty.
Variables ¶
var Config jaegercfg.Configuration
Config - the open tracing config singleton
Functions ¶
func GetSpanFromGinContex ¶
func GetTraceIdFromSpanContext ¶
func GetTraceIdFromSpanContext(spanCtx opentracing.SpanContext) string
func InitDevelopment ¶
func InitDevelopment(tracingAgentHostPort []byte)
InitDevelopment - DEPRECATED (uses deprecated jaeger client func) init a production tracer environment example: Create the default tracer and schedule its closing when main returns.
func main() { tracing.InitDevelopment() # defaults to "localhost:6831" for tracing agent tracer, closer, _ := tracing.Config.New("passport-gigya-user-access") // the service name is the param to New() defer closer.Close() opentracing.SetGlobalTracer(tracer)
func InitMacDocker ¶
func InitMacDocker(tracingAgentHostPort []byte)
InitMacDocker - DEPRECATED (uses deprecated jaeger client func) init a production tracer environment example: Create the default tracer and schedule its closing when main returns.
func main() { tracing.InitMacDocker() # defaults to "host.docker.internal:6831 for tracing agent tracer, closer, _ := tracing.Config.New("passport-gigya-user-access") // the service name is the param to New() defer closer.Close() opentracing.SetGlobalTracer(tracer)
func InitProduction ¶
InitProduction - DEPRECATED (uses deprecated jaeger client func) init a production tracer environment example: Create the default tracer and schedule its closing when main returns.
func main() { tracing.InitProduction("jaegeragent.svc.cluster.local:6831") tracer, closer, _ := tracing.Config.New("passport-gigya-user-access") // the service name is the param to New() defer closer.Close() opentracing.SetGlobalTracer(tracer)
func InitTracing ¶
func InitTracing(serviceName string, tracingAgentHostPort string, opt ...Option) ( tracer opentracing.Tracer, reporter jaeger.Reporter, closer io.Closer, err error)
InitTracing - init opentracing with options (WithSampleProbability, WithEnableInfoLog) defaults: constant sampling, no info logging
func InjectTraceID ¶
func InjectTraceID(ctx opentracing.SpanContext, header http.Header) error
InjectTraceID injects the span ID into the provided HTTP header object, so that the current span will be propogated downstream to the server responding to an HTTP request. Specifying the span ID in this way will allow the tracing system to connect spans between servers.
Usage: // resty example r := resty.R() injectTraceID(span, r.Header) resp, err := r.Get(fmt.Sprintf("http://localhost:8000/users/%s", bosePersonID)) // galapagos_clients example c := galapagos_clients.GetHTTPClient() req, err := http.NewRequest("GET", fmt.Sprintf("http://localhost:8000/users/%s", bosePersonID)) injectTraceID(span, req.Header) c.Do(req)
func StartDBSpanWithParent ¶
func StartDBSpanWithParent(parent opentracing.SpanContext, operationName, dbInstance, dbType, dbStatement string) opentracing.Span
StartDBSpanWithParent - start a DB operation span
func StartSpan ¶
func StartSpan(operationName, method, path string) opentracing.Span
StartSpan will start a new span with no parent span.
func StartSpanWithHeader ¶
func StartSpanWithHeader(header *http.Header, operationName, method, path string) opentracing.Span
StartSpanWithHeader will look in the headers to look for a parent span before starting the new span. example:
func handleGet(c *gin.Context) { span := StartSpanWithHeader(&c.Request.Header, "api-request", method, path) defer span.Finish() c.Set("tracing-context", span) // add the span to the context so it can be used for the duration of the request. bosePersonID := c.Param("bosePersonID") span.SetTag("bosePersonID", bosePersonID)
func StartSpanWithParent ¶
func StartSpanWithParent(parent opentracing.SpanContext, operationName, method, path string) opentracing.Span
StartSpanWithParent will start a new span with a parent span. example:
span:= StartSpanWithParent(c.Get("tracing-context"),
Types ¶
type Option ¶
type Option func(*options)
Option - define options for NewJWTCache()
func WithEnableInfoLog ¶
WithEnableInfoLog - optional: enable Info logging for tracing
func WithSampleProbability ¶
WithSampleProbability - optional sample probability