Skip to content

Commit

Permalink
Revert "fix: inline code indentation"
Browse files Browse the repository at this point in the history
This reverts commit e888b5e.
  • Loading branch information
aswanson-nr committed Jun 21, 2021
1 parent e888b5e commit f6b2a7a
Showing 1 changed file with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ On this page, you will learn how to manually instrument your lambda function. It
3. In your Lambda code, import our components, create an application, and update how you start your Lambda. See our [GitHub repo for an example of an instrumented Lambda](https://github.com/newrelic/go-agent/blob/master/_integrations/nrlambda/example/main.go).
4. Optional: Add [custom events](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/glossary#custom-event) that will be associated with your Lambda invocation by using the [`RecordCustomEvent` API](https://docs.newrelic.com/docs/agents/go-agent/features/create-custom-events-insights-go). For example:

```go
func handler(ctx context.Context) {
if txn := newrelic.FromContext(ctx); nil != txn {
txn.Application().RecordCustomEvent("MyEvent", map[string]interface{}{
"zip": "zap",
})
}
fmt.Println("hello world!")
}
```
```go
func handler(ctx context.Context) {
if txn := newrelic.FromContext(ctx); nil != txn {
txn.Application().RecordCustomEvent("MyEvent", map[string]interface{}{
"zip": "zap",
})
}
fmt.Println("hello world!")
}
```
5. Build and zip your Lambda function and upload it to AWS.


Expand All @@ -53,14 +53,14 @@ func handler(ctx context.Context) {

1. Build the binary for execution on Linux. This produces a binary file called `main`. You can use:

```
$ GOOS=linux go build -o main
```
```
$ GOOS=linux go build -o main
```
2. Zip the binary into a deployment package using:

```
$ zip deployment.zip main
```
```
$ zip deployment.zip main
```
3. Upload the zip file to AWS using either the AWS Lambda console or the AWS CLI. Name the handler `main` (to match the name given during the binary build).
</Collapser>
</CollapserGroup>
Expand Down Expand Up @@ -99,13 +99,13 @@ $ zip deployment.zip main

1. In your project’s `build.gradle` file, include our OpenTracing AWS Lambda Tracer and the AWS Lambda OpenTracing SDK dependencies:

```
dependencies {
compile("com.newrelic.opentracing:java-aws-lambda:2.1.0")
compile("com.newrelic.opentracing:newrelic-java-lambda:2.1.1")
compile("io.opentracing:opentracing-util:0.33.0")
}
```
```
dependencies {
compile("com.newrelic.opentracing:java-aws-lambda:2.1.0")
compile("com.newrelic.opentracing:newrelic-java-lambda:2.1.1")
compile("io.opentracing:opentracing-util:0.33.0")
}
```
2. Implement the AWS Lambda `RequestHandler` interface as shown in the [Java Lambda example](https://github.com/newrelic/newrelic-lambda-tracer-java#usage) and override the `doHandleRequest` method.
3. In the `doHandleRequest` method, call the `LambdaTracing.instrument(...)` API to create a root span to trace the lambda function's execution. This is also where you will define your business logic for the lambda function.
4. Register a `LambdaTracer.INSTANCE` as the OpenTracing Global tracer, as shown in the [Java Lambda example](https://github.com/newrelic/newrelic-lambda-tracer-java#usage).
Expand Down Expand Up @@ -141,10 +141,10 @@ dependencies {
Note: `NewRelic.OpenTracing.AmazonLambda.Tracer` depends on version 1.2.0+ of `Amazon.Lambda.APIGatewayEvent` NuGet package. If the environment already uses a lower version of `Amazon.Lambda.APIGatewayEvent`, the New Relic package may produce errors such as `System.MissingMethodException` .
2. Import the NuGet package and OpenTracing utils:

```
using OpenTracing.Util;
using NewRelic.OpenTracing.AmazonLambda;
```
```
using OpenTracing.Util;
using NewRelic.OpenTracing.AmazonLambda;
```

3. Instrument your function, as shown in this example:

Expand Down Expand Up @@ -357,19 +357,19 @@ require('@newrelic/aws-sdk');
// Other module loads go under the two require statements above
module.exports.handler = newrelic.setLambdaHandler((event, context, callback) => {
// This is your handler function code
console.log('Lambda executed');
callback();
// This is your handler function code
console.log('Lambda executed');
callback();
});
```
4. Optional: You can also add [custom events](/docs/using-new-relic/welcome-new-relic/getting-started/glossary#custom-event) to your Lambda using the [`recordCustomEvent` API](/docs/agents/nodejs-agent/api-guides/nodejs-agent-api#record_custom_event). For example:

```
module.exports.handler = newrelic.setLambdaHandler((event, context, callback) => {
newrelic.recordCustomEvent(‘MyEventType’, {foo: ‘bar’});
newrelic.recordCustomEvent(‘MyEventType’, {foo: ‘bar’});
console.log('Lambda executed');
callback();
console.log('Lambda executed');
callback();
});
```
5. Zip your Lambda function and the Node.js agent folder together. Requirements and recommendations:
Expand Down

0 comments on commit f6b2a7a

Please sign in to comment.