@@ -205,6 +205,9 @@ func (r *telemetryAPIReceiver) createLogs(slice []event) (plog.Logs, error) {
205205 scopeLog .Scope ().SetName (scopeName )
206206 for _ , el := range slice {
207207 r .logger .Debug (fmt .Sprintf ("Event: %s" , el .Type ), zap .Any ("event" , el ))
208+ if ! r .logReport && el .Type == string (telemetryapi .PlatformReport ) {
209+ continue
210+ }
208211 logRecord := scopeLog .LogRecords ().AppendEmpty ()
209212 logRecord .Attributes ().PutStr ("type" , el .Type )
210213 if t , err := time .Parse (time .RFC3339 , el .Time ); err == nil {
@@ -215,6 +218,17 @@ func (r *telemetryAPIReceiver) createLogs(slice []event) (plog.Logs, error) {
215218 return plog.Logs {}, err
216219 }
217220 if record , ok := el .Record .(map [string ]interface {}); ok {
221+ requestId := r .getRecordRequestId (record )
222+ if requestId != "" {
223+ logRecord .Attributes ().PutStr (semconv .AttributeFaaSInvocationID , requestId )
224+
225+ // If this is the first event in the invocation with a request id (i.e. the "platform.start" event),
226+ // set the current invocation id to this request id.
227+ if el .Type == string (telemetryapi .PlatformStart ) {
228+ r .currentFaasInvocationID = requestId
229+ }
230+ }
231+
218232 // in JSON format https://docs.aws.amazon.com/lambda/latest/dg/telemetry-schema-reference.html#telemetry-api-function
219233 if timestamp , ok := record ["timestamp" ].(string ); ok {
220234 if t , err := time .Parse (time .RFC3339 , timestamp ); err == nil {
@@ -229,24 +243,13 @@ func (r *telemetryAPIReceiver) createLogs(slice []event) (plog.Logs, error) {
229243 logRecord .SetSeverityText (logRecord .SeverityNumber ().String ())
230244 }
231245
232- requestId := r .getRecordRequestId (record )
233- if requestId != "" {
234- logRecord .Attributes ().PutStr (semconv .AttributeFaaSInvocationID , requestId )
235-
236- // If this is the first event in the invocation with a request id (i.e. the "platform.start" event),
237- // set the current invocation id to this request id.
238- if el .Type == string (telemetryapi .PlatformStart ) {
239- r .currentFaasInvocationID = requestId
240- }
241- }
242-
243- if line , ok := record ["message" ].(string ); ok {
244- logRecord .Body ().SetStr (line )
245- } else if el .Type == string (telemetryapi .PlatformReport ) {
246+ if el .Type == string (telemetryapi .PlatformReport ) {
246247 platformReportMessage := createPlatformReportMessage (requestId , record )
247248 if platformReportMessage != "" {
248249 logRecord .Body ().SetStr (platformReportMessage )
249250 }
251+ } else if line , ok := record ["message" ].(string ); ok {
252+ logRecord .Body ().SetStr (line )
250253 }
251254 } else {
252255 if r .currentFaasInvocationID != "" {
@@ -406,7 +409,7 @@ func newTelemetryAPIReceiver(
406409 }
407410 }
408411
409- subscribedTypes := []telemetryapi.EventType {}
412+ var subscribedTypes []telemetryapi.EventType
410413 for _ , val := range cfg .Types {
411414 switch val {
412415 case "platform" :
@@ -418,14 +421,19 @@ func newTelemetryAPIReceiver(
418421 }
419422 }
420423
424+ logReport := true
425+ if cfg .LogReport != nil {
426+ logReport = * cfg .LogReport
427+ }
428+
421429 return & telemetryAPIReceiver {
422430 logger : set .Logger ,
423431 queue : queue .New (initialQueueSize ),
424432 extensionID : cfg .extensionID ,
425433 port : cfg .Port ,
426434 types : subscribedTypes ,
427435 resource : r ,
428- logReport : cfg . LogReport ,
436+ logReport : logReport ,
429437 }, nil
430438}
431439
0 commit comments