Documentation ¶
Index ¶
- Constants
- type Daemon
- func (d *Daemon) AutoSelectStrategy() flush.Strategy
- func (d *Daemon) ComputeGlobalTags(configTags []string)
- func (d *Daemon) GetFlushStrategy() string
- func (d *Daemon) HandleRuntimeDone()
- func (d *Daemon) InvocationInterval() time.Duration
- func (d *Daemon) RestoreCurrentStateFromFile() error
- func (d *Daemon) SaveCurrentExecutionContext() error
- func (d *Daemon) SetExecutionContext(arn string, requestID string)
- func (d *Daemon) SetFlushStrategy(strategy flush.Strategy)
- func (d *Daemon) SetStatsdServer(metricAgent *metrics.ServerlessMetricAgent)
- func (d *Daemon) SetTraceAgent(traceAgent *trace.ServerlessTraceAgent)
- func (d *Daemon) SetupLogCollectionHandler(route string, logsChan chan *logConfig.ChannelMessage, logsEnabled bool, ...)
- func (d *Daemon) ShouldFlush(moment flush.Moment, t time.Time) bool
- func (d *Daemon) Stop()
- func (d *Daemon) StoreInvocationTime(t time.Time) bool
- func (d *Daemon) TellDaemonRuntimeDone()
- func (d *Daemon) TellDaemonRuntimeStarted()
- func (d *Daemon) TriggerFlush(isLastFlushBeforeShutdown bool)
- func (d *Daemon) UpdateStrategy()
- func (d *Daemon) UseAdaptiveFlush(enabled bool)
- func (d *Daemon) WaitForDaemon()
- type Flush
- type Hello
Constants ¶
const FlushTimeout time.Duration = 5 * time.Second
FlushTimeout is the amount of time to wait for a flush to complete.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Daemon ¶
type Daemon struct { MetricAgent *metrics.ServerlessMetricAgent TraceAgent *trace.ServerlessTraceAgent // RuntimeWg is used to keep track of whether the runtime is currently handling an invocation. // It should be reset when we start a new invocation, as we may start a new invocation before hearing that the last one finished. RuntimeWg *sync.WaitGroup // FlushWg is used to keep track of whether there is currently a flush in progress FlushWg *sync.WaitGroup ExtraTags *serverlessLog.Tags ExecutionContext *serverlessLog.ExecutionContext // TellDaemonRuntimeDoneOnce asserts that TellDaemonRuntimeDone will be called at most once per invocation (at the end of the function OR after a timeout) // this should be reset before each invocation TellDaemonRuntimeDoneOnce sync.Once // contains filtered or unexported fields }
Daemon is the communcation server for between the runtime and the serverless Agent. The name "daemon" is just in order to avoid serverless.StartServer ...
func StartDaemon ¶
StartDaemon starts an HTTP server to receive messages from the runtime. The DogStatsD server is provided when ready (slightly later), to have the hello route available as soon as possible. However, the HELLO route is blocking to have a way for the runtime function to know when the Serverless Agent is ready.
func (*Daemon) AutoSelectStrategy ¶
AutoSelectStrategy uses the invocation interval of the function to select the best flush strategy. This function doesn't mind if the flush strategy has been overridden through configuration / environment var, the caller is responsible for that.
func (*Daemon) ComputeGlobalTags ¶
ComputeGlobalTags extracts tags from the ARN, merges them with any user-defined tags and adds them to traces, logs and metrics
func (*Daemon) GetFlushStrategy ¶
GetFlushStrategy returns the flush stategy
func (*Daemon) HandleRuntimeDone ¶
func (d *Daemon) HandleRuntimeDone()
HandleRuntimeDone should be called when the runtime is done handling the current invocation. It will tell the daemon that the runtime is done, and may also flush telemetry.
func (*Daemon) InvocationInterval ¶
InvocationInterval computes the invocation interval of the current function. This function returns 0 if not enough invocations were done.
func (*Daemon) RestoreCurrentStateFromFile ¶
RestoreCurrentStateFromFile loads the current context from a file
func (*Daemon) SaveCurrentExecutionContext ¶
SaveCurrentExecutionContext stores the current context to a file
func (*Daemon) SetExecutionContext ¶
SetExecutionContext sets the current context to the daemon
func (*Daemon) SetFlushStrategy ¶
SetFlushStrategy sets the flush strategy to use.
func (*Daemon) SetStatsdServer ¶
func (d *Daemon) SetStatsdServer(metricAgent *metrics.ServerlessMetricAgent)
SetStatsdServer sets the DogStatsD server instance running when it is ready.
func (*Daemon) SetTraceAgent ¶
func (d *Daemon) SetTraceAgent(traceAgent *trace.ServerlessTraceAgent)
SetTraceAgent sets the Agent instance for submitting traces
func (*Daemon) SetupLogCollectionHandler ¶
func (d *Daemon) SetupLogCollectionHandler(route string, logsChan chan *logConfig.ChannelMessage, logsEnabled bool, enhancedMetricsEnabled bool)
SetupLogCollectionHandler configures the log collection route handler
func (*Daemon) ShouldFlush ¶
ShouldFlush indicated whether or a flush is needed
func (*Daemon) Stop ¶
func (d *Daemon) Stop()
Stop causes the Daemon to gracefully shut down. After a delay, the HTTP server is shut down, data is flushed a final time, and then the agents are shut down.
func (*Daemon) StoreInvocationTime ¶
StoreInvocationTime stores the given invocation time in the list of previous invocations. It is used to compute the invocation interval of the current function. It is automatically removing entries when too much have been already stored (more than maxInvocationsStored). When trying to store a new point, if it is older than the last one stored, it is ignored. Returns if the point has been stored.
func (*Daemon) TellDaemonRuntimeDone ¶
func (d *Daemon) TellDaemonRuntimeDone()
TellDaemonRuntimeDone tells the daemon that the runtime finished handling an invocation
func (*Daemon) TellDaemonRuntimeStarted ¶
func (d *Daemon) TellDaemonRuntimeStarted()
TellDaemonRuntimeStarted tells the daemon that the runtime started handling an invocation
func (*Daemon) TriggerFlush ¶
TriggerFlush triggers a flush of the aggregated metrics, traces and logs. If the flush times out, the daemon will stop waiting for the flush to complete, but the flush may be continued on the next invocation. In some circumstances, it may switch to another flush strategy after the flush.
func (*Daemon) UpdateStrategy ¶
func (d *Daemon) UpdateStrategy()
UpdateStrategy will update the current flushing strategy
func (*Daemon) UseAdaptiveFlush ¶
UseAdaptiveFlush sets whether we use the adaptive flush or not. Set it to false when the flush strategy has been forced through configuration.
func (*Daemon) WaitForDaemon ¶
func (d *Daemon) WaitForDaemon()
WaitForDaemon waits until the daemon has finished handling the current invocation
type Flush ¶
type Flush struct {
// contains filtered or unexported fields
}
Flush is a route called by the Lambda Library when the runtime is done handling an invocation. It is no longer used, but the route is maintained for backwards compatibility.