Documentation ¶
Index ¶
- func ReportInitError(id ID, errorEnum ErrorEnum) error
- func SubscribeLogs(id ID, httpAddr string, logsType []string) error
- func WaitForNextInvocation(stopCh chan struct{}, daemon *Daemon, metricsChan chan []metrics.MetricSample, ...) error
- type Daemon
- func (d *Daemon) AutoSelectStrategy() flush.Strategy
- func (d *Daemon) EnableLogsCollection() (string, chan aws.LogMessage, error)
- func (d *Daemon) InvocationInterval() time.Duration
- func (d *Daemon) SetAggregator(aggregator *aggregator.BufferedAggregator)
- func (d *Daemon) SetFlushStrategy(strategy flush.Strategy)
- func (d *Daemon) SetStatsdServer(statsdServer *dogstatsd.Server)
- func (d *Daemon) SetTraceAgent(traceAgent *traceAgent.Agent)
- func (d *Daemon) StoreInvocationTime(t time.Time) bool
- func (d *Daemon) TriggerFlush(ctx context.Context, shutdown bool)
- func (d *Daemon) UseAdaptiveFlush(enabled bool)
- type ErrorEnum
- type Flush
- type Hello
- type ID
- type LogsCollection
- type Payload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportInitError ¶
ReportInitError reports an init error to the environment.
func SubscribeLogs ¶
SubscribeLogs subscribes to the logs collection on the platform. We send a request to AWS to subscribe for logs, indicating on which port we are opening an HTTP server, to receive logs from AWS. When we are receiving logs on this HTTP server, we're pushing them in a channel tailed by the Logs Agent pipeline, these logs then go through the regular Logs Agent pipeline to finally be sent on the intake when we receive a FLUSH call from the Lambda function / client. logsType contains the type of logs for which we are subscribing, possible value: platform, extension and function.
func WaitForNextInvocation ¶
func WaitForNextInvocation(stopCh chan struct{}, daemon *Daemon, metricsChan chan []metrics.MetricSample, id ID) error
WaitForNextInvocation makes a blocking HTTP call to receive the next event from AWS. Note that for now, we only subscribe to INVOKE and SHUTDOWN events. Write into stopCh to stop the main thread of the running program.
Types ¶
type Daemon ¶
type Daemon struct { // Wait on this WaitGroup in controllers to be sure that the Daemon is ready. // (i.e. that the DogStatsD server is properly instantiated) ReadyWg *sync.WaitGroup // 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 ¶
func StartDaemon(stopCh chan struct{}) *Daemon
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) EnableLogsCollection ¶
func (d *Daemon) EnableLogsCollection() (string, chan aws.LogMessage, error)
EnableLogsCollection is adding the HTTP route on which the HTTP server will receive logs from AWS. Returns the HTTP URL on which AWS should send the logs.
func (*Daemon) InvocationInterval ¶
InvocationInterval computes the invocation interval of the current function. This function returns 0 if not enough invocations were done.
func (*Daemon) SetAggregator ¶
func (d *Daemon) SetAggregator(aggregator *aggregator.BufferedAggregator)
SetAggregator sets the aggregator used within the DogStatsD server. Use this aggregator `GetChannels()` or `GetBufferedChannels()` to send metrics directly to the aggregator, with caution.
func (*Daemon) SetFlushStrategy ¶
SetFlushStrategy sets the flush strategy to use.
func (*Daemon) SetStatsdServer ¶
SetStatsdServer sets the DogStatsD server instance running when it is ready.
func (*Daemon) SetTraceAgent ¶
func (d *Daemon) SetTraceAgent(traceAgent *traceAgent.Agent)
SetTraceAgent sets the Agent instance for submitting traces
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. They are flushed concurrently. In some circumstances, it may switch to another flush strategy after the flush. shutdown indicates whether this is the last flush before the shutdown or not.
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.
type ErrorEnum ¶
type ErrorEnum string
ErrorEnum are errors reported to the AWS Extension environment.
const ( // FatalNoAPIKey is the error reported to the AWS Extension environment when // no API key has been set. Unused until we can report error // without stopping the extension. FatalNoAPIKey ErrorEnum = "Fatal.NoAPIKey" // FatalDogstatsdInit is the error reported to the AWS Extension environment when // DogStatsD fails to initialize properly. Unused until we can report error // without stopping the extension. FatalDogstatsdInit ErrorEnum = "Fatal.DogstatsdInit" // FatalBadEndpoint is the error reported to the AWS Extension environment when // bad endpoints have been configured. Unused until we can report error // without stopping the extension. FatalBadEndpoint ErrorEnum = "Fatal.BadEndpoint" // FatalConnectFailed is the error reported to the AWS Extension environment when // a connection failed. FatalConnectFailed ErrorEnum = "Fatal.ConnectFailed" )
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.
type Hello ¶
type Hello struct {
// contains filtered or unexported fields
}
Hello implements the basic Hello route, creating a way for the Datadog Lambda Library to know that the serverless agent is running. It is blocking until the DogStatsD daemon is ready.
type ID ¶
type ID string
ID is the extension ID within the AWS Extension environment.
type LogsCollection ¶
type LogsCollection struct {
// contains filtered or unexported fields
}
LogsCollection is the route on which the AWS environment is sending the logs for the extension to collect them. It is attached to the main HTTP server already receiving hits from the libraries client.
func (*LogsCollection) ServeHTTP ¶
func (l *LogsCollection) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP - see type LogsCollection comment.