Closed
Description
Hi,
I wanted to propose a small enhancement to the OpenTelemetry tracing layer implementation in the AWS Lambda Rust runtime.
Currently, in otel.rs, the tracing span for Lambda invocations doesn't include a way to specify the span kind (e.g., server, client). Adding this capability could improve how systems are represented in observability platforms.
My suggestion: we could add an otel.kind
field to the span creation, initialized as empty. This would allow users to set the span kind in their handlers if needed. For example:
let span = tracing::info_span!(
"Lambda function invocation",
"otel.name" = req.context.env_config.function_name,
"otel.kind" = field::Empty, // New field for span kind
{ traceconv::FAAS_TRIGGER } = &self.otel_attribute_trigger,
{ traceconv::FAAS_INVOCATION_ID } = req.context.request_id,
{ traceconv::FAAS_COLDSTART } = self.coldstart
);
Users could then set the span kind in their handler like this:
use tracing::Span;
async fn handler(event: Value, _: Context) -> Result<Value, Error> {
let span = Span::current();
span.record("otel.kind", "server");
// Handler logic...
}
This change should be backward compatible and provide more flexibility for users. I'd love to hear your thoughts on this, and happy to propose a PR!
Metadata
Metadata
Assignees
Labels
No labels