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

Go lambda support #129

Merged
merged 16 commits into from
Oct 29, 2021
Merged

Conversation

bhautikpip
Copy link
Contributor

Draft as replaces Otel go contrib with forked repo for otellambda package as otellambda is not merged into contrib yet. See PR here: open-telemetry/opentelemetry-go-contrib#882

Copy link
Contributor

@garrettwegan garrettwegan left a comment

Choose a reason for hiding this comment

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

Blocked on contrib #983, contrib #984, and aws-otel.github.io #142

TODO: see comments

go/README.md Outdated
Comment on lines 7 to 12
[OpenTelemetry Lambda SDK for Go]() includes tracing APIs to instrument Lambda handler. Follow the instructions on [user guide]() to manually instrument the Lambda handler.
For other instrumentations, such as http, you'll need to include the corresponding library instrumentation from the [instrumentation project](https://github.com/open-telemetry/opentelemetry-go) and modify your code to use it in your function.

## Provided Layer

[OpenTelemetry Lambda Layer for Collector]() includes OpenTelemetry Collector for Lambda components. Follow [user guide]() to apply this layer to your Lambda handler that's already been instrumented with OpenTelemetry Lambda Go SDK to enable end-to-end tracing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Links need to be inserted once the targets exist. These should be correct:

Suggested change
[OpenTelemetry Lambda SDK for Go]() includes tracing APIs to instrument Lambda handler. Follow the instructions on [user guide]() to manually instrument the Lambda handler.
For other instrumentations, such as http, you'll need to include the corresponding library instrumentation from the [instrumentation project](https://github.com/open-telemetry/opentelemetry-go) and modify your code to use it in your function.
## Provided Layer
[OpenTelemetry Lambda Layer for Collector]() includes OpenTelemetry Collector for Lambda components. Follow [user guide]() to apply this layer to your Lambda handler that's already been instrumented with OpenTelemetry Lambda Go SDK to enable end-to-end tracing.
[OpenTelemetry Lambda SDK for Go](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/aws/aws-lambda-go/otellambda) includes tracing APIs to instrument Lambda handler. Follow the instructions on [user guide]() to manually instrument the Lambda handler.
For other instrumentations, such as http, you'll need to include the corresponding library instrumentation from the [instrumentation project](https://github.com/open-telemetry/opentelemetry-go) and modify your code to use it in your function.
## Provided Layer
[OpenTelemetry Lambda Layer for Collector](https://aws-otel.github.io/docs/getting-started/lambda/lambda-go#lambda-layer) includes OpenTelemetry Collector for Lambda components. Follow [user guide](https://aws-otel.github.io/docs/getting-started/lambda/lambda-go#instrumentation) to apply this layer to your Lambda handler that's already been instrumented with OpenTelemetry Lambda Go SDK to enable end-to-end tracing.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove the section for the Provided layer because it is vendor-specific.

Copy link
Contributor

Choose a reason for hiding this comment

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

And also should remove reference to user guide. We should have a section on building the layer if possible like other layers have instead? E.g. https://github.com/open-telemetry/opentelemetry-lambda/tree/main/java#building

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. I think we should keep the guide since it's brief - https://github.com/aws-otel/aws-otel.github.io/pull/142/files. I also think rather than having documentation at 2 places we should only put it in a single place (official docs) which is easier to maintain. Also, sometime just in case if we update official doc and missed updating READEME it would confuse customers.

go/README.md Outdated

## Sample application

The [sample application]() shows the manual instrumentations of OpenTelemetry Lambda .NET SDK on a Lambda handler that triggers downstream requests to AWS S3 and HTTP.
Copy link
Contributor

Choose a reason for hiding this comment

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

This link also needs to be populated but is a little different because it points into the PR, can either just do the end goal url ("https://github.com/open-telemetry/opentelemetry-lambda/blob/main/go/sample-apps/function/function.go") or just a relative path ("./sample-apps/function/function.go").

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The [sample application]() shows the manual instrumentations of OpenTelemetry Lambda .NET SDK on a Lambda handler that triggers downstream requests to AWS S3 and HTTP.
The [sample application]() shows the manual instrumentations of OpenTelemetry Lambda Go SDK on a Lambda handler that triggers downstream requests to AWS S3 and HTTP.

Comment on lines 16 to 20
replace (
go.opentelemetry.io/contrib/detectors/aws/lambda => github.com/garrettwegan/opentelemetry-go-contrib/detectors/aws/lambda v0.0.0-20210730164323-986e366f4c23
go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda => github.com/garrettwegan/opentelemetry-go-contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda v0.0.0-20210730164323-986e366f4c23
go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig => github.com/garrettwegan/opentelemetry-go-contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig v0.0.0-20210730201622-eef81a9505f4
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove upon merge of contrib PRs #983 and #984 and run go mod tidy

Copy link
Contributor

Choose a reason for hiding this comment

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

Also need to upgrade to latest versions of OTel go dependencies (1.0.0+)


func main() {
lambda.Start(otellambda.WrapHandlerFunction(lambda_handler, xrayconfig.AllRecommendedOptions()...))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}

Copy link
Contributor

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

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

A few callouts we can change once this PR is unblocked

go/README.md Outdated
Comment on lines 7 to 12
[OpenTelemetry Lambda SDK for Go]() includes tracing APIs to instrument Lambda handler. Follow the instructions on [user guide]() to manually instrument the Lambda handler.
For other instrumentations, such as http, you'll need to include the corresponding library instrumentation from the [instrumentation project](https://github.com/open-telemetry/opentelemetry-go) and modify your code to use it in your function.

## Provided Layer

[OpenTelemetry Lambda Layer for Collector]() includes OpenTelemetry Collector for Lambda components. Follow [user guide]() to apply this layer to your Lambda handler that's already been instrumented with OpenTelemetry Lambda Go SDK to enable end-to-end tracing.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove the section for the Provided layer because it is vendor-specific.

go/README.md Outdated

## Sample application

The [sample application]() shows the manual instrumentations of OpenTelemetry Lambda .NET SDK on a Lambda handler that triggers downstream requests to AWS S3 and HTTP.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The [sample application]() shows the manual instrumentations of OpenTelemetry Lambda .NET SDK on a Lambda handler that triggers downstream requests to AWS S3 and HTTP.
The [sample application]() shows the manual instrumentations of OpenTelemetry Lambda Go SDK on a Lambda handler that triggers downstream requests to AWS S3 and HTTP.

variable "collector_layer_arn" {
type = string
description = "ARN for the Lambda layer containing the OpenTelemetry collector extension"
default = "arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-collector-ver-0-27-0:1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Will need to update this to latest

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
default = "arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-collector-ver-0-27-0:1"
default = "arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-collector-ver-0-29-1:1"

Comment on lines 16 to 20
replace (
go.opentelemetry.io/contrib/detectors/aws/lambda => github.com/garrettwegan/opentelemetry-go-contrib/detectors/aws/lambda v0.0.0-20210730164323-986e366f4c23
go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda => github.com/garrettwegan/opentelemetry-go-contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda v0.0.0-20210730164323-986e366f4c23
go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig => github.com/garrettwegan/opentelemetry-go-contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig v0.0.0-20210730201622-eef81a9505f4
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also need to upgrade to latest versions of OTel go dependencies (1.0.0+)

@bhautikpip bhautikpip marked this pull request as ready for review October 28, 2021 19:31
Copy link
Contributor

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

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

Few more comments, then lgtm

go/README.md Outdated

## Sample application

The [sample application]() shows the manual instrumentations of OpenTelemetry Lambda Go SDK on a Lambda handler that triggers downstream requests to AWS S3 and HTTP.
Copy link
Contributor

Choose a reason for hiding this comment

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

Link the sample app here.

go/README.md Outdated

## Provided SDK

[OpenTelemetry Lambda SDK for Go](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/aws/aws-lambda-go/otellambda) includes tracing APIs to instrument Lambda handler. Follow the instructions on [user guide](https://aws-otel.github.io/docs/getting-started/lambda/lambda-go) to manually instrument the Lambda handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[OpenTelemetry Lambda SDK for Go](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/aws/aws-lambda-go/otellambda) includes tracing APIs to instrument Lambda handler. Follow the instructions on [user guide](https://aws-otel.github.io/docs/getting-started/lambda/lambda-go) to manually instrument the Lambda handler.
[OpenTelemetry Lambda SDK for Go](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/aws/aws-lambda-go/otellambda) includes tracing APIs to instrument Lambda handler.

Can't have anything vendor-specific

variable "collector_layer_arn" {
type = string
description = "ARN for the Lambda layer containing the OpenTelemetry collector extension"
default = "arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-collector-ver-0-27-0:1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
default = "arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-collector-ver-0-27-0:1"
default = "arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-collector-ver-0-29-1:1"

go/sample-apps/deploy/variables.tf Outdated Show resolved Hide resolved
Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
@wangzlei wangzlei merged commit 941e6db into open-telemetry:main Oct 29, 2021
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.

None yet

5 participants