Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit b2fff5b

Browse files
authored
Update aws-sdk README
1 parent 161ad51 commit b2fff5b

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

packages/plugin-aws-sdk/README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ npm install --save opentelemetry-plugin-aws-sdk
1010

1111
## Usage
1212

13-
To load a specific plugin (**aws-sdk** in this case), specify it in the Node Tracer's configuration
13+
To load this plugin, specify it in the Node Tracer's configuration:
1414

1515
```js
16-
const { NodeTracerProvider } = require("opentelemetry-plugin-aws-sdk");
16+
const { NodeTracerProvider } = require("@opentelemetry/node");
1717

1818
const provider = new NodeTracerProvider({
1919
plugins: {
@@ -42,18 +42,32 @@ This plugin patch the internal `Request` object, which means that each sdk opera
4242
Each span will have the following attributes:
4343
| Attribute Name | Type | Description | Example |
4444
| -------------- | ---- | ----------- | ------- |
45-
| "component" | string | Always equals "aws-sdk" | "aws-sdk" |
46-
| "aws.operation" | string | The method name for the request. | for `SQS.sendMessage(...)` the operation is "sendMessage" |
47-
| "aws.signature.version" | string | Aws version of authentication signature on the request. | "v4" |
48-
| "aws.region" | string | Region name for the request | "eu-west-1" |
49-
| "aws.service.api" | string | The sdk class name for the service | "SQS" |
50-
| "aws.service.identifier" | string | Identifier for the service in the sdk | "sqs" |
51-
| "aws.service.name" | string | Abbreviation name for the service | "Amazon SQS" |
52-
| "aws.request.id" | uuid | Request unique id, as returned from aws on response | "01234567-89ab-cdef-0123-456789abcdef" |
53-
| "aws.error" | string | information about a service or networking error, as returned from aws | "UriParameterError: Expected uri parameter to have length >= 1, but found "" for params.Bucket" |
45+
| `component` | string | Always equals "aws-sdk" | "aws-sdk" |
46+
| `aws.operation` | string | The method name for the request. | for `SQS.sendMessage(...)` the operation is "sendMessage" |
47+
| `aws.signature.version` | string | AWS version of authentication signature on the request. | "v4" |
48+
| `aws.region` | string | Region name for the request | "eu-west-1" |
49+
| `aws.service.api` | string | The sdk class name for the service | "SQS" |
50+
| `aws.service.identifier` | string | Identifier for the service in the sdk | "sqs" |
51+
| `aws.service.name` | string | Abbreviation name for the service | "Amazon SQS" |
52+
| `aws.request.id` | uuid | Request unique id, as returned from aws on response | "01234567-89ab-cdef-0123-456789abcdef" |
53+
| `aws.error` | string | information about a service or networking error, as returned from AWS | "UriParameterError: Expected uri parameter to have length >= 1, but found "" for params.Bucket" |
5454

5555
### Custom User Attributes
56-
The plugin user can configure a hook function which will be called before each request, with the request object and the relevant span. This hook can be used to add custom attributes to the span with any logic. For example, user can add interesting attributes from the `request.params`, and write custom logic based on the service and operation.
56+
The plugin user can configure a `preRequestHook` function which will be called before each request, with the request object and the corrosponding span.
57+
This hook can be used to add custom attributes to the span with any logic.
58+
For example, user can add interesting attributes from the `request.params`, and write custom logic based on the service and operation.
59+
Usage example:
60+
```js
61+
awsPluginConfig = {
62+
enabled: true,
63+
path: "opentelemetry-plugin-aws-sdk",
64+
preRequestHook: (span, request) => {
65+
if (span.attributes["aws.service.api"] === 's3') {
66+
span.setAttribute("s3.bucket.name", request.params["Bucket"]);
67+
}
68+
}
69+
};
70+
```
5771

5872
### Specific Service Logic
5973
AWS contains dozens of services accessible with the JS SDK. For many services, the default attributes specified above are enough, but other services have specific [trace semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions), or need to inject/extract intra-process context, or set intra-process context correctly.

0 commit comments

Comments
 (0)