Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ability to define span.kind for OpenTelemetry Layer #945

Closed
alessandrobologna opened this issue Nov 30, 2024 · 2 comments
Closed

Comments

@alessandrobologna
Copy link
Contributor

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!

@maxday
Copy link
Contributor

maxday commented Dec 12, 2024

closing this as #946 as been merged.

@maxday maxday closed this as completed Dec 12, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants