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

feat(otel): allow to configure the faas.trigger attribute of the span #903

Merged
merged 3 commits into from
Jun 30, 2024

Conversation

Oliboy50
Copy link
Contributor

@Oliboy50 Oliboy50 commented Jun 28, 2024

📬 Issue #, if available:
#898 (comment)

✍️ Description of changes:
Allow to configure the faas.trigger attribute of the OpenTelemetry layer span which is currently hardcoded to http
Small breaking change: the faas.trigger default value is now datasource instead of http

🔏 By submitting this pull request

  • I confirm that I've ran cargo +nightly fmt.
  • I confirm that I've ran cargo clippy --fix.
  • I confirm that I've made a best effort attempt to update all relevant documentation.
  • I confirm that my contribution is made under the terms of the Apache 2.0 license.

tracer_provider.force_flush();
})
// Set the "faas.trigger" attribute of the span (defaults to "http" otherwise)
.with_trigger("datasource"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capture d’écran 2024-06-28 à 15 37 34

Copy link
Contributor Author

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
Capture d’écran 2024-06-30 à 15 25 35

otel_attribute_trigger: self
.otel_attribute_trigger
.clone()
.unwrap_or_else(|| "http".to_string()),
Copy link
Contributor Author

@Oliboy50 Oliboy50 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a doubt here, I don't know if the OpenTelemetryLayer::layer() is executed each time the lambda is invoked... or if it's call only on coldstarts during the Runtime construction

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 http directly in the OpenTelemetryLayer::new() function... but it would allocate a String for nothing when users will use with_trigger right after (i.e. OpenTelemetryLayer::new().with_trigger("datasource") would allocate http for nothing)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

layer() is only executed when the runtime starts, so this would be invoked only once. It makes me wonder if datasource should be the default, it's more generic than http. I'm ok with one allocation to initialize the service.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

@Oliboy50 Oliboy50 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes me wonder if datasource should be the default, it's more generic than http

Yes datasource or even other, but this would be a breaking change, so let me know if you really want me to change the current default value 🙏

looking at the spec, maybe using an enum for the datasource makes more sense since there are only a few trigger types defined

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?
Also note that the current specs for faas.trigger are still experimental... and even the opentelemetry_semantic_conventions does not expose such an enum yet (don't know why though) 🤷
That being said, let me know if we should expose an enum here (should we name it OpenTelemetryFaasTrigger?) 🙏

OpenTelemetry docs for reference

Capture d’écran 2024-06-28 à 21 17 23

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes datasource or even other, but this would be a breaking change, so let me know if you really want me to change the current default value 🙏

This is fine. I don't think anyone is really using this yet.

That being said, let me know if we should expose an enum here (should we name it OpenTelemetryFaasTrigger?) 🙏

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 other if at some point there are more types and they need to wait for a release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍

@Oliboy50 Oliboy50 mentioned this pull request Jun 28, 2024
2 tasks
@Oliboy50 Oliboy50 force-pushed the oliboy50-configure-faas-trigger branch from 74d5c51 to 5d824be Compare June 30, 2024 13:40
Copy link
Contributor

@calavera calavera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@calavera calavera merged commit 9b88cea into awslabs:main Jun 30, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants