customapm

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package customapm provides tracing and error-reporting helpers for Elastic APM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TXFromCtx

func TXFromCtx(ctx context.Context, txName string, txType string) *apm.Transaction

TXFromCtx returns the transaction in ctx or starts one with txName and txType when none is present. The caller must end a transaction started by this function.

func TraceError

func TraceError(
	ctx context.Context,
	err error,
	l sypl.ISypl,
	metric *expvar.Int,
) error

TraceError increments metric when non-nil, marks the current span failed, unwraps a single-error chain before capture and optional logging, and returns the original err.

Types

type Ender

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

Ender owns a traced span and, when Trace created it, its transaction.

func Trace

func Trace(
	ctx context.Context,
	what, nameOf string,
	operation status.Status,
	l sypl.ISypl,
	metric *expvar.Int,
) (context.Context, Ender)

Trace starts a span in the transaction from ctx, creating a transaction when necessary. It returns the tracing context and an Ender that the caller must end. metric is incremented when non-nil.

func (Ender) End

func (e Ender) End()

End ends the span before ending the transaction owned by this ender.

type Logger

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

Logger adapts the application logger to the Elastic APM logger interface.

func NewLogger

func NewLogger() (*Logger, error)

NewLogger returns a new APM logger.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted APM debug message.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted APM error.

type Outcome

type Outcome string

Outcome represents an APM span outcome.

const (
	// Failure is the outcome when the span failed.
	Failure Outcome = "failure"

	// Success is the outcome when the span succeeded.
	Success Outcome = "success"
)

func (Outcome) String

func (o Outcome) String() string

String returns the outcome value.

Jump to

Keyboard shortcuts

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