invocationlifecycle

package
v0.0.0-...-cba18c7 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TraceIDHeader is the header containing the traceID
	// used in /trace-context and /lambda/start-invocation
	TraceIDHeader = "x-datadog-trace-id"

	// ParentIDHeader is the header containing the parentID
	// used in /trace-context and /lambda/start-invocation
	ParentIDHeader = "x-datadog-parent-id"

	// SpanIDHeader is the header containing the spanID
	// used in /lambda/start-invocation
	SpanIDHeader = "x-datadog-span-id"

	// InvocationErrorHeader : if set to "true", the extension will know that the current invocation has failed
	// used in /lambda/end-invocation
	InvocationErrorHeader = "x-datadog-invocation-error"

	// InvocationErrorMsgHeader is the error message captured by the tracer
	InvocationErrorMsgHeader = "x-datadog-invocation-error-msg"

	// InvocationErrorTypeHeader is the error type captured by the tracer
	InvocationErrorTypeHeader = "x-datadog-invocation-error-type"

	// InvocationErrorStackHeader is the stack trace captured by the tracer
	InvocationErrorStackHeader = "x-datadog-invocation-error-stack"

	// SamplingPriorityHeader is the header containing the sampling priority for execution and/or inferred spans
	SamplingPriorityHeader = "x-datadog-sampling-priority"
)

Variables

This section is empty.

Functions

func InjectContext

func InjectContext(executionContext *ExecutionStartInfo, headers http.Header)

InjectContext injects the context

func InjectSpanID

func InjectSpanID(executionContext *ExecutionStartInfo, headers http.Header)

InjectSpanID injects the spanId

func ParseLambdaPayload

func ParseLambdaPayload(rawPayload []byte) []byte

ParseLambdaPayload removes extra data sent by the proxy that surrounds a JSON payload. For example, for `a5a{"event":"aws_lambda"...}0` it would remove a5a at the front and 0 at the end, and just leave a correct JSON payload.

Types

type ExecutionStartInfo

type ExecutionStartInfo struct {
	TraceID uint64
	SpanID  uint64

	SamplingPriority sampler.SamplingPriority
	// contains filtered or unexported fields
}

ExecutionStartInfo is saved information from when an execution span was started

type InvocationEndDetails

type InvocationEndDetails struct {
	EndTime            time.Time
	IsError            bool
	IsTimeout          bool
	RequestID          string
	ResponseRawPayload []byte
	ColdStart          bool
	ProactiveInit      bool
	Runtime            string
	ErrorMsg           string
	ErrorType          string
	ErrorStack         string
}

InvocationEndDetails stores information about the end of an invocation. This structure is passed to the onInvokeEnd method of the invocationProcessor interface

type InvocationProcessor

type InvocationProcessor interface {
	// OnInvokeStart is the hook triggered when an invocation has started
	OnInvokeStart(startDetails *InvocationStartDetails)
	// OnInvokeEnd is the hook triggered when an invocation has ended
	OnInvokeEnd(endDetails *InvocationEndDetails)
	// GetExecutionInfo returns the current execution start information
	GetExecutionInfo() *ExecutionStartInfo
}

InvocationProcessor is the interface to implement to receive invocation lifecycle hooks

type InvocationStartDetails

type InvocationStartDetails struct {
	StartTime             time.Time
	InvokeEventRawPayload []byte
	InvokeEventHeaders    http.Header
	InvokedFunctionARN    string
	InferredSpan          inferredspan.InferredSpan
}

InvocationStartDetails stores information about the start of an invocation. This structure is passed to the onInvokeStart method of the invocationProcessor interface

type InvocationSubProcessor

type InvocationSubProcessor interface {
	// OnInvokeStart is the hook triggered when an invocation has started and the request handler context was created,
	OnInvokeStart(startDetails *InvocationStartDetails, ctx *RequestHandler)
	// OnInvokeEnd is the hook triggered when an invocation has ended
	OnInvokeEnd(endDetails *InvocationEndDetails, ctx *RequestHandler)
}

InvocationSubProcessor is the interface to implement to receive invocation lifecycle hooks along with the invocation context of the request handler.

type LifecycleProcessor

type LifecycleProcessor struct {
	ExtraTags            *serverlessLog.Tags
	ProcessTrace         func(p *api.Payload)
	Demux                aggregator.Demultiplexer
	DetectLambdaLibrary  func() bool
	InferredSpansEnabled bool
	SubProcessor         InvocationSubProcessor
	Extractor            propagation.Extractor
	// contains filtered or unexported fields
}

LifecycleProcessor is a InvocationProcessor implementation

func (*LifecycleProcessor) GetExecutionInfo

func (lp *LifecycleProcessor) GetExecutionInfo() *ExecutionStartInfo

GetExecutionInfo returns the trace and payload information of the currently executing lambda function

func (*LifecycleProcessor) GetInferredSpan

func (lp *LifecycleProcessor) GetInferredSpan() *inferredspan.InferredSpan

GetInferredSpan returns the generated inferred span of the currently executing lambda function

func (*LifecycleProcessor) GetServiceName

func (lp *LifecycleProcessor) GetServiceName() string

GetServiceName returns the value stored in the environment variable DD_SERVICE. Also assigned into `lp.serviceName` if not previously set

func (*LifecycleProcessor) GetTags

func (lp *LifecycleProcessor) GetTags() map[string]string

GetTags returns the tagset of the currently executing lambda function

func (*LifecycleProcessor) OnInvokeEnd

func (lp *LifecycleProcessor) OnInvokeEnd(endDetails *InvocationEndDetails)

OnInvokeEnd is the hook triggered when an invocation has ended

func (*LifecycleProcessor) OnInvokeStart

func (lp *LifecycleProcessor) OnInvokeStart(startDetails *InvocationStartDetails)

OnInvokeStart is the hook triggered when an invocation has started

type RequestHandler

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

RequestHandler is the struct that stores information about the trace, inferred span, and tags about the current invocation inferred spans may contain a secondary inferred span in certain cases like SNS from SQS

func (*RequestHandler) Event

func (r *RequestHandler) Event() interface{}

Event returns the invocation event parsed by the LifecycleProcessor. It is nil if the event type is not supported yet. The actual event type can be figured out thanks to a Go type switch on the event types of the package github.com/aws/aws-lambda-go/events

func (*RequestHandler) GetMetaTag

func (r *RequestHandler) GetMetaTag(tag string) (value string, exists bool)

GetMetaTag returns the meta span tag value if it exists.

func (*RequestHandler) SetMetaTag

func (r *RequestHandler) SetMetaTag(tag string, value string)

SetMetaTag sets a meta span tag. A meta tag is a tag whose value type is string.

func (*RequestHandler) SetMetricsTag

func (r *RequestHandler) SetMetricsTag(tag string, value float64)

SetMetricsTag sets a metrics span tag. A metrics tag is a tag whose value type is float64.

func (*RequestHandler) SetSamplingPriority

func (r *RequestHandler) SetSamplingPriority(priority sampler.SamplingPriority)

SetSamplingPriority sets the trace priority

Jump to

Keyboard shortcuts

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