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

Telemetry for AWS requests #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andrewhr
Copy link
Contributor

This patch add Telemetry support for all AWS requests.

For context, what this patch aims is to eventually map those Telemetry spans into semantic OpenTelemetry traces. This inform what kind of metadata we need to provide on those spans:

  • Client: which itself includes useful information like target region.
  • ServiceMetadata: this is the most important one, with info about the target Service itself;
  • Action: the operation name, more on that bellow;
  • Input: the input sent by the user, more on that bellow;

The action value is not provided on REST requests, and requires to re-generate code. A companion PR can be sent to aws-codegen, it this feature is accepted. Given AWS.Request is a private implementation for the generated code, I assume this change is not breaking from user perspective.

The input AFAICT would be useful to extract service-specific information like, for example, the table names of DynamoDB.

@andrewhr
Copy link
Contributor Author

I recommend to disable whitespaces to review this PR, most of the diff is just indentation due :telemetry.span.

@andrewhr andrewhr changed the title Telemetry for AWS requests Draft: Telemetry for AWS requests Dec 21, 2021
@andrewhr andrewhr marked this pull request as draft December 21, 2021 16:27
@andrewhr andrewhr changed the title Draft: Telemetry for AWS requests Telemetry for AWS requests Dec 21, 2021
@andrewhr andrewhr marked this pull request as ready for review December 21, 2021 16:27
Copy link
Contributor

@philss philss left a comment

Choose a reason for hiding this comment

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

Just a minor issue :)

end

def request_rest(
%Client{} = client,
%ServiceMetadata{} = metadata,
action,
Copy link
Contributor

Choose a reason for hiding this comment

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

This action does not exist for REST services (at least not available now). The closest thing to it sees to be conjunction of HTTP method and the path. WDYT of using that for the action field?

We could do something like:

"#{http_method |> Atom.to_string() |> String.upcase()} #{path}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added those on new generated code.

The reason of why action is desirable, by OpenTelemetry docs (and some reference implementation) the spans should be named as ServiceName.OperationName.

Does that makes sense?

@andrewhr
Copy link
Contributor Author

Hey @philss, thanks for taking time to review!

Sorry, I didn't made the message that clear. With little changes to code generator, we can have those action names for REST calls as well. I'll provide some PR to that repo as follow-up.

I've kept the changes to auto-generated code in a separate commit to help you review how that looks like.

Thanks once more for your time! 🙇

@philss
Copy link
Contributor

philss commented Dec 21, 2021

@andrewhr oh man, sorry. I didn't read the description entirely. That makes sense! 👍
Please ping me in the aws-codegen PR when it's ready. :)

This patch add Telemetry support for all AWS requests.

For context, what this patch aims is to eventually map those Telemetry
spans into [semantic OpenTelemetry traces][1]. This inform what kind of
metadata we need to provide on those spans:
* Client: which itself includes useful information like target region.
* ServiceMetadata: this is the most important one, with info about the
target Service itself;
* Action: the operation name, more on that bellow;
* Input: the input sent by the user, more on that bellow;

The `action` value is not provided on REST requests, and requires to
re-generate code. A companion PR can be sent to aws-codegen project, it
this feature is accepted. Given `AWS.Request` is a private implementation
for the generated code, I assume this change is not breaking from user
perspective.

The `input` AFAICT would be useful to extract service-specific
information like, for example, the table names of DynamoDB.

[1]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-sdk.md
@andrewhr andrewhr force-pushed the telemetry-spans-for-operations branch from 2d1e4a2 to 2aaeda5 Compare December 1, 2022 14:55
@andrewhr
Copy link
Contributor Author

andrewhr commented Dec 1, 2022

Sorry @philss , this PR was accumulating dust in my hard drive.

I rebased against latest master - which includes the ServiceMedata changes - and published the companion PR here aws-beam/aws-codegen#90.

Thanks a bunch! 🙇

@philss
Copy link
Contributor

philss commented Dec 1, 2022

@andrewhr no problem! I will check both PRs later today. Thank you! 💜

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