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

[PoC] Register partial transaction in AWS extn #1352

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lahsivjar
Copy link
Contributor

@lahsivjar lahsivjar commented Nov 17, 2022

Register the transaction with lambda extension to handle unexpected failures and crashes. In these unexpected cases, the lambda extension will create a proxy transaction on behalf of the agent.

Closes: #1323

@lahsivjar lahsivjar requested a review from axw November 17, 2022 07:11
} else {
resp, err := http.Post(
// TODO: @lahsivjar better way to get base URI
"http://localhost:8200/register/transaction",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@axw I wanted to keep the endpoints local to the lambda module. In the agent config I see that we have option for multiple APM server URLs so I am not sure what is the best way to get the base URI (I think it would always be localhost:8200 but hard coding like this is probably not the best idea)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'm not sure what the best approach is here. Since it's a special case, I also wouldn't want to complicate the main API.

ELASTIC_APM_SERVER_URLS (multiple URLs) is deprecated, and I think the only time you would set a non-default URL is for testing purposes. So I'd say just use os.Getenv("ELASTIC_APM_SERVER_URL") here, and default to http://localhost:8200.

@lahsivjar lahsivjar requested a review from a team November 17, 2022 10:18
Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

@lahsivjar thanks, I think this turned out pretty well. We could neaten it up a bit if we want to go ahead with it, but I think it's proven the approach can work.

@@ -258,6 +225,40 @@ func (w *modelWriter) buildModelError(out *model.Error, e *ErrorData) {
out.Culprit = truncateString(out.Culprit)
}

// BuildModelTransaction converts apm transaction to model transaction
Copy link
Member

Choose a reason for hiding this comment

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

I don't love exposing this just for Lambda. td.Context.build() mutates the transaction context, for one thing. I think it's okay as it is, but could be a source of bugs later down the line.

Maybe we could have a method which only copies immutable properties (IDs, sampled status, sample rate) to the model object? Or otherwise, perhaps we could expose those properties as methods on Transaction, and build the partial transaction model directly in module/apmlambda code. Would that be awful?

@lahsivjar lahsivjar changed the title Register partial transaction in AWS extn [PoC] Register partial transaction in AWS extn Nov 18, 2022
@apmmachine
Copy link
Contributor

apmmachine commented Nov 24, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview previewSnapshots

Expand to view the summary

Build stats

  • Duration: 3 min 4 sec

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run benchmark tests : Run the benchmark test.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POC: Improve AWS Lambda function support
3 participants