Skip to content

Commit ef4872c

Browse files
committed
edit README.md to fit proposed README format
1 parent a420c31 commit ef4872c

File tree

1 file changed

+61
-28
lines changed

1 file changed

+61
-28
lines changed

README.md

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# AWS Lambda OpenTracing Java SDK
22

3-
## Purpose
3+
This SDK provides Open Tracing instrumentation for AWS Lambda. Releases for this project will be on an "as needed" basis. As new features of Lambda come out we will evaluate them and if useful will add support for them here.
44

5-
Open Tracing instrumentation for AWS Lambda [RequestHandler](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestHandler.java) and [RequestStreamHandler](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestStreamHandler.java).
5+
Versioning will have the following format: {majorVersion}.{minorVersion}.{pointVersion}
66

7-
## How it Works
7+
### How it Works
88

9-
The SDK provides `TracingRequestHandler` and `TracingRequestStreamHandler` interfaces that extend AWS' Lambda request handlers. When a Lambda function that is using an implementation of either tracing request handler is invoked, the handler will obtain the globally registered OpenTracing [Tracer](https://opentracing.io/docs/overview/tracers/) and create/start an OpenTracing [Span](https://opentracing.io/docs/overview/spans/) to capture timing information and `key:value` pairs ([Tags/Logs](https://opentracing.io/docs/overview/tags-logs-baggage/)) detailing the trace data.
9+
The SDK provides [`TracingRequestHandler`](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestHandler.java) and [`TracingRequestStreamHandler`](https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestStreamHandler.java) interfaces that extend AWS' Lambda request handlers. When a Lambda function that is using an implementation of either tracing request handler is invoked, the handler will obtain the globally registered OpenTracing [Tracer](https://opentracing.io/docs/overview/tracers/) and create/start an OpenTracing [Span](https://opentracing.io/docs/overview/spans/) to capture timing information and `key:value` pairs ([Tags/Logs](https://opentracing.io/docs/overview/tags-logs-baggage/)) detailing the trace data.
1010

1111
As part of the implementation the user must override the tracing handler's `doHandleRequest` method which is called by the handler interface's `handleRequest` method.
1212

13-
## Collected Span Tags/Logs
13+
### Collected Span Tags/Logs
1414

15-
Lambda attributes:
15+
Below are a list of the collected Lambda attributes:
1616

1717
| Tag key | Tag type | Note |
1818
| :------------------------------: | :-------: | :---------------------------------------------------------------: |
@@ -21,7 +21,7 @@ Lambda attributes:
2121
| `aws.lambda.eventSource.arn` | `String` | ARN of the invocation source |
2222
| `aws.lambda.coldStart` | `boolean` | Indicates if Lambda invocation was a cold start, omitted if false |
2323

24-
Exception log:
24+
Below are a list of the collected exception attributes:
2525

2626
| Log key | Log type | Note |
2727
| :------------: | :---------------------: | :----------------------------------------------: |
@@ -31,34 +31,31 @@ Exception log:
3131
| `stack` | `Throwable` stacktrace | The the stack trace information of the throwable |
3232
| `error.kind` | `String` `"Exception"` | Indicates that the error was an `Exception` |
3333

34-
## How to Use
35-
36-
1. Add the `java-aws-lambda` dependency to your project.
37-
- **Option A:** [Build the project from sources](#build-the-project) and [add the jar to your project as a Gradle dependency](#add-artifact-to-gradle-project)
38-
- **Option B:** Add gradle or maven dependency to your project: [TODO N/A for Beta](https://mvnrepository.com)
39-
2. Implement the `TracingRequestHandler` interface as shown in the [example](#example-usage), defining the Lambda function input and output types that your function requires.
40-
3. Override the `doHandleRequest` method from the interface and execute your function logic within it. *Note:* If you are refactoring a pre-existing Lambda handler to take advantage of this SDK's tracing request handler make sure that it overrides `doHandleRequest` but not `handleRequest`.
41-
4. Register the OpenTracing Tracer of your choice.
42-
5. See Amazon's documentation on [creating a ZIP deployment package for a Java Lambda function](https://docs.aws.amazon.com/lambda/latest/dg/create-deployment-pkg-zip-java.html)
43-
6. When creating your Lambda function in AWS Lambda console the handler for the given example would be entered as `com.handler.example.MyLambdaHandler::handleRequest` or just `com.handler.example.MyLambdaHandler`, the latter of which will use `handleRequest` as the handler method by default. *Note:* `handleRequest` is used as the handler entry point as it will call `doHandleRequest`.
44-
45-
## Build the Project
46-
47-
Run jar task: `./gradlew java-aws-lambda:jar`
48-
49-
Artifact: `java-aws-lambda/java-aws-lambda/build/libs/java-aws-lambda.jar`
50-
51-
## Add Artifact to Gradle Project
52-
53-
Include the jar by adding it as a dependency in your `build.gradle` file:
34+
### How to Use
5435

36+
#### Add Dependency
37+
You can either build the project locally as described below and then add the jar dependency into your gradle (or maven) file:
5538
```groovy
5639
dependencies {
5740
compile files('/path/to/java-aws-lambda.jar')
5841
}
5942
```
43+
Or you can add the dependency like so:
44+
```
45+
dependencies {
46+
// TODO verify this is correct when released
47+
implementation "com.newrelic.opentracing.aws:java-aws-lambda:X.X.X"
48+
}
49+
```
50+
51+
#### Implement
52+
1. Implement the `TracingRequestHandler` interface as shown in the [example](#example-usage), defining the Lambda function input and output types that your function requires.
53+
2. Override the `doHandleRequest` method from the interface and execute your function logic within it. *Note:* If you are refactoring a pre-existing Lambda handler to take advantage of this SDK's tracing request handler make sure that it overrides `doHandleRequest` but not `handleRequest`.
54+
3. Register the OpenTracing Tracer of your choice.
55+
4. See Amazon's documentation on [creating a ZIP deployment package for a Java Lambda function](https://docs.aws.amazon.com/lambda/latest/dg/create-deployment-pkg-zip-java.html)
56+
5. When creating your Lambda function in AWS Lambda console the handler for the given example would be entered as `com.handler.example.MyLambdaHandler::handleRequest` or just `com.handler.example.MyLambdaHandler`, the latter of which will use `handleRequest` as the handler method by default. *Note:* `handleRequest` is used as the handler entry point as it will call `doHandleRequest`.
6057

61-
## Example Usage
58+
#### Example Usage
6259

6360
```java
6461
package com.handler.example;
@@ -97,3 +94,39 @@ public class MyLambdaHandler implements TracingRequestHandler<Map<String, Object
9794
}
9895
}
9996
```
97+
98+
99+
## Getting Started
100+
101+
### Requirements
102+
103+
* AWS Lambda instance
104+
* Java 8
105+
* Gradle
106+
107+
### Building
108+
Run the following gradle task:
109+
```
110+
./gradlew java-aws-lambda:jar
111+
```
112+
113+
This generates a jar artifact in the following subdirectory:
114+
```
115+
java-aws-lambda/java-aws-lambda/build/libs/java-aws-lambda.jar
116+
```
117+
118+
### Testing
119+
Run the following gradle task:
120+
```
121+
./gradlew test
122+
```
123+
124+
### Contributing
125+
Full details are available in our CONTRIBUTING file;
126+
127+
We'd love to get your contributions to improve AWS Lambda OpenTracing Java SDK! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at open-source@newrelic.com.
128+
129+
### Licensing
130+
The AWS Lambda OpenTracing Java SDK is licensed under the Apache 2.0 License.
131+
132+
The AWS Lambda OpenTracing Java SDK also uses source code from third party libraries. Full details on which libraries are used and the terms under which they are licensed can be found in the third party notices document.

0 commit comments

Comments
 (0)