question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWS SDK Instrumentation should use AWS SDK values for `rpc` attributes

See original GitHub issue

Description

In the aws sdk instrumentation package, rpc attributes are set from the normalizedRequest.

https://github.com/aspecto-io/opentelemetry-ext-js/blob/243e19bcebb5f95df5b4a68cbf675aa6351ca3fb/packages/instrumentation-aws-sdk/src/utils.ts#L40-L47

normalizedRequest (v2 and v3) modify the request metadata values returned from the AWS SDK like this:

https://github.com/aspecto-io/opentelemetry-ext-js/blob/243e19bcebb5f95df5b4a68cbf675aa6351ca3fb/packages/instrumentation-aws-sdk/src/utils.ts#L15-L23

Specifically:

  • It converts the service name .toLowerCase()
  • It converts the operation name .toCamelCase()

However, the specs for AWS SDK instrumentation give examples that contradict these patterns.

- ref: rpc.service
brief: "The name of the service to which a request is made, as returned by the AWS SDK."
examples:
    - DynamoDB
    - S3
- ref: rpc.method
brief: "The name of the operation corresponding to the request, as returned by the AWS SDK"
examples:
    - GetItem
    - PutItem

Action Items

Based on the examples, we should return S3 instead of s3 and ListBuckets instead of listBuckets (for example).

This means using toUpperCase() and a modified version of toCamelCase() with the first character Upper Case.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Oberon00commented, Aug 4, 2021

@anuraaga please take a look, it seems like the spec could use some improvement in that area.

1reaction
blumamircommented, Aug 4, 2021

According to the cited thread you should be able to retrieve the operation name from the metadata. I would create a spec issue, asking for clarification. My gut feeling is that in doubt you should rather report what you have as-is than doing any string manipulation.

Thank you @Oberon00 for taking the time to read and comment here. I agree with your comment in general. Unfortunately, for aws-sdk js the situation is very complex:

in v2, the operation name is set with PascalCase in the apis (see example) but then later on changed to camelCase somewhere in the code which is what is accessible to the patching code. in v3, both the service name and the method are not accessible at all! there is simply no way to retrieve them other than extracting them from the class name or digging into some very deep private attributes which are not structured or documented.

I think that the sentence “as returned by the AWS SDK” is simply not valid for JS sdk specifically.

Since the spec is (deliberately?) blurry about what value should be set for these attributes, I’m ok with applying common sense and produce values (i.e PascalCase) that are consistent between v2, v3, the generic API reference, and the examples in otel spec. However, I will be happy if someone wants to take this issue, research all the complexity, and lead a discussion in the spec repo or anywhere else. I can help with such effort but it’s too time-consuming for me to lead it myself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS X-Ray Exporter should map `rpc` values to `aws` values
* value that the AWS-XRay backend understands. Specifically: rpc.service -> aws.service; rpc.method -> aws.operation; rpc.system is already used ...
Read more >
opentelemetry-instrumentation-aws-sdk - npm
Span Attributes ; rpc.service, string, The name of the service to which a request is made, as returned by the AWS SDK.
Read more >
Developing with Amazon S3 using the AWS SDKs, and ...
This section provides an overview of using AWS SDKs for developing Amazon S3 applications. This section also describes how you can test the...
Read more >
Set Amazon SNS topic attributes using an AWS SDK
The following code examples show how to set Amazon SNS topic attributes. Java. SDK for Java 2.x. Note.
Read more >
AWS X-Ray concepts
You choose the data to collect by modifying your application configuration or code to instrument incoming requests, downstream requests, and AWS SDK clients ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found