| 72 | } |
| 73 | |
| 74 | fn call(&mut self, req: LambdaInvocation) -> Self::Future { |
| 75 | let span = if let Some(tenant_id) = &req.context.tenant_id { |
| 76 | tracing::info_span!( |
| 77 | "Lambda function invocation", |
| 78 | "otel.name" = req.context.env_config.function_name, |
| 79 | "otel.kind" = field::Empty, |
| 80 | { attribute::FAAS_TRIGGER } = &self.otel_attribute_trigger, |
| 81 | { attribute::FAAS_INVOCATION_ID } = req.context.request_id, |
| 82 | { attribute::FAAS_COLDSTART } = self.coldstart, |
| 83 | "tenant_id" = tenant_id |
| 84 | ) |
| 85 | } else { |
| 86 | tracing::info_span!( |
| 87 | "Lambda function invocation", |
| 88 | "otel.name" = req.context.env_config.function_name, |
| 89 | "otel.kind" = field::Empty, |
| 90 | { attribute::FAAS_TRIGGER } = &self.otel_attribute_trigger, |
| 91 | { attribute::FAAS_INVOCATION_ID } = req.context.request_id, |
| 92 | { attribute::FAAS_COLDSTART } = self.coldstart |
| 93 | ) |
| 94 | }; |
| 95 | |
| 96 | // After the first execution, we can set 'coldstart' to false |
| 97 | self.coldstart = false; |
| 98 | |
| 99 | let future = { |
| 100 | // Enter the span before calling the inner service |
| 101 | // to ensure that it's assigned as parent of the inner spans. |
| 102 | let _guard = span.enter(); |
| 103 | self.inner.call(req) |
| 104 | }; |
| 105 | OpenTelemetryFuture { |
| 106 | future: Some(future.instrument(span)), |
| 107 | flush_fn: self.flush_fn.clone(), |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /// Future created by [OpenTelemetryService]. |