31
31
// ErrMetadataUnavailable is returned when a lambda data is added to
32
32
// the batch without metadata being set.
33
33
ErrMetadataUnavailable = errors .New ("metadata is not yet available" )
34
- // ErrBatchFull signfies that the batch has reached full capacity
34
+ // ErrBatchFull signifies that the batch has reached full capacity
35
35
// and cannot accept more entries.
36
36
ErrBatchFull = errors .New ("batch is full" )
37
37
// ErrInvalidEncoding is returned for any APMData that is encoded
@@ -184,7 +184,7 @@ func (b *Batch) AddAgentData(apmData APMData) error {
184
184
return ErrBatchFull
185
185
}
186
186
if b .currentlyExecutingRequestID == "" {
187
- return fmt . Errorf ("lifecycle error, currently executing requestID is not set" )
187
+ return errors . New ("lifecycle error, currently executing requestID is not set" )
188
188
}
189
189
inc , ok := b .invocations [b .currentlyExecutingRequestID ]
190
190
if ! ok {
@@ -218,10 +218,10 @@ func (b *Batch) AddAgentData(apmData APMData) error {
218
218
// OnLambdaLogRuntimeDone prepares the data for the invocation to be shipped
219
219
// to APM Server. It accepts requestID and status of the invocation both of
220
220
// which can be retrieved after parsing `platform.runtimeDone` event.
221
- func (b * Batch ) OnLambdaLogRuntimeDone (reqID , status string , time time.Time ) error {
221
+ func (b * Batch ) OnLambdaLogRuntimeDone (reqID , status string , endTime time.Time ) error {
222
222
b .mu .Lock ()
223
223
defer b .mu .Unlock ()
224
- return b .finalizeInvocation (reqID , status , time )
224
+ return b .finalizeInvocation (reqID , status , endTime )
225
225
}
226
226
227
227
func (b * Batch ) OnPlatformStart (reqID string ) {
@@ -236,6 +236,8 @@ func (b *Batch) PlatformStartReqID() string {
236
236
// platform.report event the batch will cleanup any datastructure for the request
237
237
// ID. It will return some of the function metadata to allow the caller to enrich
238
238
// the report metrics.
239
+ //
240
+ //nolint:gocritic
239
241
func (b * Batch ) OnPlatformReport (reqID string ) (string , int64 , time.Time , error ) {
240
242
b .mu .Lock ()
241
243
defer b .mu .Unlock ()
@@ -249,7 +251,7 @@ func (b *Batch) OnPlatformReport(reqID string) (string, int64, time.Time, error)
249
251
250
252
// OnShutdown flushes the data for shipping to APM Server by finalizing all
251
253
// the invocation in the batch. If we haven't received a platform.runtimeDone
252
- // event for an invocation so far we won't be able to recieve it in time thus
254
+ // event for an invocation so far we won't be able to receive it in time thus
253
255
// the status needs to be guessed based on the available information.
254
256
func (b * Batch ) OnShutdown (status string ) error {
255
257
b .mu .Lock ()
@@ -259,8 +261,8 @@ func (b *Batch) OnShutdown(status string) error {
259
261
// TODO: @lahsivjar Is it possible to tweak the extension lifecycle in
260
262
// a way that we receive the platform.report metric for a invocation
261
263
// consistently and enrich the metrics with reported values?
262
- time := time .Unix (0 , inc .DeadlineMs * int64 (time .Millisecond ))
263
- if err := b .finalizeInvocation (inc .RequestID , status , time ); err != nil {
264
+ endTime := time .Unix (0 , inc .DeadlineMs * int64 (time .Millisecond ))
265
+ if err := b .finalizeInvocation (inc .RequestID , status , endTime ); err != nil {
264
266
return err
265
267
}
266
268
delete (b .invocations , inc .RequestID )
@@ -315,12 +317,12 @@ func (b *Batch) ToAPMData() APMData {
315
317
}
316
318
}
317
319
318
- func (b * Batch ) finalizeInvocation (reqID , status string , time time.Time ) error {
320
+ func (b * Batch ) finalizeInvocation (reqID , status string , endTime time.Time ) error {
319
321
inc , ok := b .invocations [reqID ]
320
322
if ! ok {
321
323
return fmt .Errorf ("invocation for requestID %s does not exist" , reqID )
322
324
}
323
- proxyTxn , err := inc .MaybeCreateProxyTxn (status , time )
325
+ proxyTxn , err := inc .MaybeCreateProxyTxn (status , endTime )
324
326
if err != nil {
325
327
return err
326
328
}
0 commit comments