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

Support aws EventBridge instrumentation #4166

Open
calindurnea opened this issue Jul 29, 2024 · 2 comments · May be fixed by #4208
Open

Support aws EventBridge instrumentation #4166

calindurnea opened this issue Jul 29, 2024 · 2 comments · May be fixed by #4208

Comments

@calindurnea
Copy link

calindurnea commented Jul 29, 2024

Is your feature request related to a problem? Please describe.
I would like to have a module that enables instrumentation of AWS lambdas that use EventBridge as a trigger.

Describe the solution you'd like
When a lambda gets triggered by an EventBridge event I would like instrumentation to be tracked similarly to how the AWS SQS functions.

Describe alternatives you've considered
I have attempted to use the lambda layers and then start custom transactions to continue the tracing. When doing this I have encountered issues with the custom traces not being sent to elasticsearch, I could only see the default trace that the layer generate on a new lambda invocation, but without any other context (for example the traceparent)

I would be open to giving it a shot at implementing this myself. I am open to any feedback or guidelines.

@trentm
Copy link
Member

trentm commented Jul 30, 2024

Hi @calindurnea,
I (we, Elastic) won't have the time to implement this myself. I should be able to give you some support/review if you attempt to implement this yourself.

Some notes to get you started:

I haven't used EventBridge myself, so my help might be limited.
I'm not sure if there will be a good or easy story for distributed tracing, i.e. for passing around trace-id, span-id, and flags (typically done with the traceparent header in HTTP). This APM agent doesn't do anything with AWS X-Ray.

@trentm trentm removed the triage label Jul 30, 2024
@calindurnea
Copy link
Author

Hello @trentm,
Thank you for the reply!
I will attempt to implement this and see how it goes. I appreciate the information, and I will reach out if anything.

calindurnea added a commit to calindurnea/apm-agent-nodejs that referenced this issue Sep 1, 2024
<!--

Replace this comment with a description of what's being changed by this PR.

If this PR should close an issue, please add one of the magic keywords
(e.g. Fixes) followed by the issue number. For more info see:
https://help.github.com/articles/closing-issues-using-keywords/

-->

Resolves elastic#4166.
Extends the aws lambda handled triggers with eventbridge specific events.

The minimum event structure is based on  https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events-structure.html and it contains:
```json
{
  "detail-type": "event name",
  "source": "event source",
  "detail": {
    JSON object
  }
}
```

The full event that can be handled is the following:
```json
{
  "version": "0",
  "id": "UUID",
  "detail-type": "event name",
  "source": "event source",
  "account": "ARN",
  "time": "timestamp",
  "region": "region",
  "resources": [
    "ARN"
  ],
  "detail": {
    "traceparent": "00-traceId-spanId",
    ...
  }
}
```

### Checklist

- [x] Implement code
- [x] Add tests
- [ ] Update TypeScript typings
- [ ] Update documentation
- [x] Add CHANGELOG.asciidoc entry
- [x] Commit message follows [commit guidelines](https://github.com/elastic/apm-agent-nodejs/blob/main/CONTRIBUTING.md#commit-message-guidelines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants