Documentation
¶
Index ¶
- Constants
- type Daemon
- func (d *Daemon) AutoSelectStrategy() flush.Strategy
- func (d *Daemon) ComputeGlobalTags(configTags []string)
- func (d *Daemon) FinishInvocation()
- func (d *Daemon) InvocationInterval() time.Duration
- func (d *Daemon) LogFlushStategy() string
- func (d *Daemon) RestoreCurrentStateFromFile() error
- func (d *Daemon) SaveCurrentExecutionContext() error
- func (d *Daemon) SetClientReady(isReady bool)
- 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) StartInvocation()
- func (d *Daemon) Stop()
- func (d *Daemon) StoreInvocationTime(t time.Time) bool
- func (d *Daemon) TriggerFlush(isLastFlushBeforeShutdown bool)
- func (d *Daemon) UpdateStrategy()
- func (d *Daemon) UseAdaptiveFlush(enabled bool)
- func (d *Daemon) WaitForDaemon()
- func (d *Daemon) WaitUntilClientReady(timeout time.Duration) bool
- 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 // InvcWg is used to keep track of whether the daemon is doing any pending work // before finishing an invocation InvcWg *sync.WaitGroup ExtraTags *serverlessLog.Tags ExecutionContext *serverlessLog.ExecutionContext // 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. If the Flush route is called before the statsd server has been set, a 503 is returned by the HTTP route.
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 of 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) FinishInvocation ¶
func (d *Daemon) FinishInvocation()
FinishInvocation finishes the current invocation
func (*Daemon) InvocationInterval ¶
InvocationInterval computes the invocation interval of the current function. This function returns 0 if not enough invocations were done.
func (*Daemon) LogFlushStategy ¶
LogFlushStategy returns the flush stategy
func (*Daemon) RestoreCurrentStateFromFile ¶
RestoreCurrentStateFromFile loads the current context from a file
func (*Daemon) SaveCurrentExecutionContext ¶
SaveCurrentExecutionContext stores the current context to a file
func (*Daemon) SetClientReady ¶
SetClientReady indicates that the client library has initialised and called the /hello route on the agent
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) StartInvocation ¶
func (d *Daemon) StartInvocation()
StartInvocation tells the daemon the invocation began
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) 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 invocation finished any pending work
type Flush ¶
type Flush struct {
// contains filtered or unexported fields
}
Flush is the route to call to do an immediate flush on the serverless agent. Returns 503 if the DogStatsD is not ready yet, 200 otherwise.