-
Notifications
You must be signed in to change notification settings - Fork 359
feat(otel): allow to configure the faas.trigger attribute of the span #903
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ use tracing::{instrument::Instrumented, Instrument}; | |
/// a function to flush OpenTelemetry after the end of the invocation. | ||
pub struct OpenTelemetryLayer<F> { | ||
flush_fn: F, | ||
otel_attribute_trigger: Option<String>, | ||
} | ||
|
||
impl<F> OpenTelemetryLayer<F> | ||
|
@@ -18,7 +19,20 @@ where | |
{ | ||
/// Create a new [OpenTelemetryLayer] with the provided flush function. | ||
pub fn new(flush_fn: F) -> Self { | ||
Self { flush_fn } | ||
Self { | ||
flush_fn, | ||
otel_attribute_trigger: None, | ||
} | ||
} | ||
|
||
/// Configure the `faas.trigger` attribute of the OpenTelemetry span. | ||
/// Defaults to `http` if not set. | ||
/// See https://opentelemetry.io/docs/specs/semconv/attributes-registry/faas/ for the list of possible triggers. | ||
pub fn with_trigger<T: Into<String>>(self, trigger: T) -> Self { | ||
Self { | ||
otel_attribute_trigger: Some(trigger.into()), | ||
..self | ||
} | ||
} | ||
} | ||
|
||
|
@@ -33,6 +47,10 @@ where | |
inner, | ||
flush_fn: self.flush_fn.clone(), | ||
coldstart: true, | ||
otel_attribute_trigger: self | ||
.otel_attribute_trigger | ||
.clone() | ||
.unwrap_or_else(|| "http".to_string()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a doubt here, I don't know if the because if it's called for each lambda invocation, maybe we should do best than that to avoid performance issues? For example, we could defaults to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at the spec, maybe using an enum for the datasource makes more sense since there are only a few trigger types defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes
The OpenTelemetry specs do not seem to move fast, but if they do, don't you think that this could be an issue for the users to wait for the aws-lambda-runtime releases to keep up with the OpenTelemetry specs evolution? OpenTelemetry docs for reference![]() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is fine. I don't think anyone is really using this yet.
That name is fine by me. I understand that's experimental, but if someone wants to use it, it's hard to know what's supported on a string. People can still use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done 👍 |
||
} | ||
} | ||
} | ||
|
@@ -42,6 +60,7 @@ pub struct OpenTelemetryService<S, F> { | |
inner: S, | ||
flush_fn: F, | ||
coldstart: bool, | ||
otel_attribute_trigger: String, | ||
} | ||
|
||
impl<S, F> Service<LambdaInvocation> for OpenTelemetryService<S, F> | ||
|
@@ -61,7 +80,7 @@ where | |
let span = tracing::info_span!( | ||
"Lambda function invocation", | ||
"otel.name" = req.context.env_config.function_name, | ||
{ traceconv::FAAS_TRIGGER } = "http", | ||
{ traceconv::FAAS_TRIGGER } = &self.otel_attribute_trigger, | ||
{ traceconv::FAAS_INVOCATION_ID } = req.context.request_id, | ||
{ traceconv::FAAS_COLDSTART } = self.coldstart | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to use "pubsub" since "datasource" is the new default value
