Documentation ¶
Overview ¶
Package tracegen contains functions that generate a trace including transaction, span, error, and logs using elastic APM Go agent and opentelemtry-go
Index ¶
- func NewRandomTraceID() apm.TraceID
- func SetOTLPTracePropagator(ctx context.Context, traceparent string, tracestate string) context.Context
- type Config
- type ConfigOption
- func WithAPIKey(k string) ConfigOption
- func WithAPMServerURL(a string) ConfigOption
- func WithElasticAPMServiceName(s string) ConfigOption
- func WithInsecureConn(b bool) ConfigOption
- func WithOTLPProtocol(p string) ConfigOption
- func WithOTLPServiceName(s string) ConfigOption
- func WithSampleRate(r float64) ConfigOption
- func WithTraceID(t apm.TraceID) ConfigOption
- type EventStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRandomTraceID ¶
func NewRandomTraceID() apm.TraceID
NewRandomTraceID returns randomly generated apm.TraceID which is also compatible with otel's trace.TraceID
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func NewConfig ¶
func NewConfig(opts ...ConfigOption) Config
type ConfigOption ¶
type ConfigOption func(*Config)
func WithAPIKey ¶
func WithAPIKey(k string) ConfigOption
WithAPIKey sets auth apiKey to communicate with APM Server
func WithAPMServerURL ¶
func WithAPMServerURL(a string) ConfigOption
WithAPMServerURL set APM Server URL (env value ELASTIC_APM_SERVER_URL)
func WithElasticAPMServiceName ¶
func WithElasticAPMServiceName(s string) ConfigOption
WithElasticAPMServiceName specifies the service name that the Elastic APM agent will use.
This config will be ignored when using SendOTLPTrace.
func WithInsecureConn ¶
func WithInsecureConn(b bool) ConfigOption
WithInsecureConn skip the server's TLS certificate verification
func WithOTLPProtocol ¶
func WithOTLPProtocol(p string) ConfigOption
WithOTLPProtocol specifies OTLP transport protocol to one of: grpc (default), http/protobuf.
This config will be ignored when using SendIntakeV2Trace
func WithOTLPServiceName ¶
func WithOTLPServiceName(s string) ConfigOption
WithOTLPServiceName specifies the service name that the OpenTelemetry SDK will use.
This config will be ignored when using SendIntakeV2Trace.
func WithSampleRate ¶
func WithSampleRate(r float64) ConfigOption
WithSampleRate specifies the sample rate for the APM GO Agent
func WithTraceID ¶
func WithTraceID(t apm.TraceID) ConfigOption
WithTraceID specifies the user defined traceID
type EventStats ¶
type EventStats struct { // ExceptionssSent holds the number of exception span events sent. ExceptionsSent int // LogsSent holds the number of logs sent, including standalone // log records and non-exception span events. LogsSent int // SpansSent holds the number of transactions and spans sent. SpansSent int }
EventStats holds client-side stats.
func SendDistributedTrace ¶
func SendDistributedTrace(ctx context.Context, cfg Config) (EventStats, error)
SendDistributedTrace sends events generated by both APM Go Agent and OTEL library and link them with the same traceID so that they are linked and can be shown in the same trace view
func SendIntakeV2Trace ¶
func SendIntakeV2Trace(ctx context.Context, cfg Config) (apm.TraceContext, EventStats, error)
SendIntakeV2Trace generate a trace including a transaction, a span and an error
func SendOTLPTrace ¶
func SendOTLPTrace(ctx context.Context, cfg Config) (EventStats, error)
SendOTLPTrace sends spans, error and logs to the configured APM Server If distributed tracing is needed, you might want to set up the propagator using SetOTLPTracePropagator function before calling this function
func (EventStats) Add ¶
func (lhs EventStats) Add(rhs EventStats) EventStats
Add adds the statistics together, returning the result.