Documentation ¶
Index ¶
- func AddSpanError(span trace.Span, err error)
- func AddSpanEvents(span trace.Span, name string, events map[string]string)
- func AddSpanTags(span trace.Span, tags map[string]string)
- func AnyToBool(value any) bool
- func AppName() string
- func AppVersion() string
- func EnvironmentMode() string
- func FailSpan(span trace.Span, msg string)
- func GenerateMetrics()
- func GetActionName() string
- func GetEnv(key string) string
- func GetEnvOrDefault(key string, defaultValue interface{}) interface{}
- func GetFunctionName(skip int) string
- func NewHttpSpan(ctx context.Context, name string, operation string, ...) (context.Context, trace.Span)
- func NewRelicTemporalitySelector() aggregation.TemporalitySelector
- func NewSpan(ctx context.Context, name string, operation string) (context.Context, trace.Span)
- func OtelJaegerURL() string
- func OtelSampled() bool
- func SpanFromContext(ctx context.Context) trace.Span
- func Start(ctx *gin.Context) (context.Context, trace.Span)
- func StartWorker(ctx context.Context) (context.Context, trace.Span)
- func StringToBool(value string) bool
- func TracerPatch() (ctx context.Context, reset func())
- func WriteStringTemplate(stringTemplate string, args ...interface{}) string
- type HttpSpanAttribute
- type OtelMetricService
- type OtelTracer
- type OtelTracerOptionFunc
- func IsSampledEnable(isEnabled bool) OtelTracerOptionFunc
- func SetApiKey(key string) OtelTracerOptionFunc
- func SetAppName(name string) OtelTracerOptionFunc
- func SetEnv(env string) OtelTracerOptionFunc
- func SetExporterEndpoint(endpoint string) OtelTracerOptionFunc
- func SetVersion(version string) OtelTracerOptionFunc
- type SpanCustomiser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSpanError ¶
AddSpanError adds a new event to the span. It will appear under the "Logs" section of the selected span. This is not going to flag the span as "failed". Use this if you think you should log any exceptions such as critical, error, warning, caution etc. Avoid logging sensitive data!
func AddSpanEvents ¶
AddSpanEvents adds a new events to the span. It will appear under the "Logs" section of the selected span. Use this if the event could mean anything valuable while debugging.
func AddSpanTags ¶
AddSpanTags adds a new tags to the span. It will appear under "Tags" section of the selected span. Use this if you think the tag and its value could be useful while debugging.
func AppVersion ¶ added in v1.1.0
func AppVersion() string
func EnvironmentMode ¶ added in v1.1.0
func EnvironmentMode() string
func FailSpan ¶
FailSpan flags the span as "failed" and adds "error" label on listed trace. Use this after calling the `AddSpanError` function so that there is some sort of relevant exception logged against it.
func GenerateMetrics ¶
func GenerateMetrics()
func GetActionName ¶ added in v1.1.0
func GetActionName() string
func GetEnvOrDefault ¶
func GetEnvOrDefault(key string, defaultValue interface{}) interface{}
func GetFunctionName ¶ added in v1.1.0
func NewHttpSpan ¶ added in v1.0.3
func NewHttpSpan(ctx context.Context, name string, operation string, httpSpanAttribute HttpSpanAttribute) (context.Context, trace.Span)
NewHttpSpan returns a new span from the global tracer. It's can trace an HTTP client request. Each resulting span must be completed with `defer span.End()` right after the call.
func NewRelicTemporalitySelector ¶
func NewRelicTemporalitySelector() aggregation.TemporalitySelector
func NewSpan ¶
NewSpan returns a new span from the global tracer. Depending on the `cus` argument, the span is either a plain one or a customised one. Each resulting span must be completed with `defer span.End()` right after the call.
func OtelJaegerURL ¶ added in v1.1.0
func OtelJaegerURL() string
func OtelSampled ¶ added in v1.1.0
func OtelSampled() bool
func SpanFromContext ¶
SpanFromContext returns the current span from a context. If you wish to avoid creating child spans for each operation and just rely on the parent span, use this function throughout the application. With such practise you will get flatter span tree as opposed to deeper version. You can always mix and match both functions.
func StartWorker ¶ added in v1.1.0
func StringToBool ¶
func TracerPatch ¶ added in v1.2.0
TracerPatch for unit test monkey patch
func WriteStringTemplate ¶ added in v1.1.0
Types ¶
type HttpSpanAttribute ¶ added in v1.0.3
type OtelMetricService ¶
type OtelMetricService struct {
// contains filtered or unexported fields
}
func ConstructMetricOtel ¶
func ConstructMetricOtel() OtelMetricService
func (*OtelMetricService) InitMetricProvider ¶
func (otelMetricService *OtelMetricService) InitMetricProvider(ctx context.Context)
type OtelTracer ¶
type OtelTracer interface { SetTraceProviderJaeger() error SetTraceProviderNewRelic(ctx context.Context) error }
func ConstructOtelTracer ¶
func ConstructOtelTracer(options ...OtelTracerOptionFunc) OtelTracer
type OtelTracerOptionFunc ¶ added in v1.1.0
type OtelTracerOptionFunc func(*otelTracer)
func IsSampledEnable ¶ added in v1.1.0
func IsSampledEnable(isEnabled bool) OtelTracerOptionFunc
func SetApiKey ¶ added in v1.2.0
func SetApiKey(key string) OtelTracerOptionFunc
func SetAppName ¶ added in v1.1.0
func SetAppName(name string) OtelTracerOptionFunc
func SetEnv ¶ added in v1.1.0
func SetEnv(env string) OtelTracerOptionFunc
func SetExporterEndpoint ¶ added in v1.2.0
func SetExporterEndpoint(endpoint string) OtelTracerOptionFunc
func SetVersion ¶ added in v1.1.0
func SetVersion(version string) OtelTracerOptionFunc
type SpanCustomiser ¶
type SpanCustomiser interface {
// contains filtered or unexported methods
}
SpanCustomiser is used to enforce custom span options. Any custom concrete span customiser type must implement this interface.