Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tracer_helpers.go « lightstep-tracer-go « lightstep « github.com « vendor - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a6aacb8a02f24b7da8ff61590fa854fa591b5fbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package lightstep

import (
	"context"

	opentracing "github.com/opentracing/opentracing-go"
)

// Flush forces a synchronous Flush.
func Flush(ctx context.Context, tracer opentracing.Tracer) {
	switch lsTracer := tracer.(type) {
	case Tracer:
		lsTracer.Flush(ctx)
	case *tracerv0_14:
		Flush(ctx, lsTracer.Tracer)
	default:
		emitEvent(newEventUnsupportedTracer(tracer))
	}
}

// Close synchronously flushes the tracer, then terminates it.
func Close(ctx context.Context, tracer opentracing.Tracer) {
	switch lsTracer := tracer.(type) {
	case Tracer:
		lsTracer.Close(ctx)
	case *tracerv0_14:
		Close(ctx, lsTracer.Tracer)
	default:
		emitEvent(newEventUnsupportedTracer(tracer))
	}
}

// GetLightStepAccessToken returns the currently configured AccessToken.
func GetLightStepAccessToken(tracer opentracing.Tracer) (string, error) {
	switch lsTracer := tracer.(type) {
	case Tracer:
		return lsTracer.Options().AccessToken, nil
	case *tracerv0_14:
		return GetLightStepAccessToken(lsTracer.Tracer)
	default:
		return "", newEventUnsupportedTracer(tracer)
	}
}

// FlushLightStepTracer flushes the tracer
// DEPRECATED: use Flush instead.
func FlushLightStepTracer(tracer opentracing.Tracer) error {
	switch lsTracer := tracer.(type) {
	case Tracer:
		lsTracer.Flush(context.Background())
		return nil
	case *tracerv0_14:
		return FlushLightStepTracer(lsTracer.Tracer)
	default:
		return newEventUnsupportedTracer(tracer)
	}
}

// CloseTracer closes the tracer
// DEPRECATED: use Close instead.
func CloseTracer(tracer opentracing.Tracer) error {
	switch lsTracer := tracer.(type) {
	case Tracer:
		lsTracer.Close(context.Background())
		return nil
	case *tracerv0_14:
		return CloseTracer(lsTracer.Tracer)
	default:
		return newEventUnsupportedTracer(tracer)
	}
}

// GetLightStepReporterID returns the currently configured Reporter ID.
func GetLightStepReporterID(tracer opentracing.Tracer) (uint64, error) {
	switch lsTracer := tracer.(type) {
	case *tracerImpl:
		return lsTracer.reporterID, nil
	case *tracerv0_14:
		return GetLightStepReporterID(lsTracer.Tracer)
	default:
		return 0, newEventUnsupportedTracer(tracer)
	}
}