[go: nahoru, domu]

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

Model trace IDs and event IDs in simulator #974

Open
Chriscbr opened this issue Dec 13, 2022 · 4 comments
Open

Model trace IDs and event IDs in simulator #974

Chriscbr opened this issue Dec 13, 2022 · 4 comments
Labels
🎨 sdk SDK 🕹️ simulator Related to the `sim` compilation target

Comments

@Chriscbr
Copy link
Contributor
Chriscbr commented Dec 13, 2022

I noticed that the traces from the simulator don't match what I initially expected. What I'm going to explain is based on my little knowledge of event sourcing and reading some logging APIs.

A trace is a group of events that are related to each other and can span across many resources and any amount of time. For example, a serverless app that provides an HTTP endpoint that expects an image URL, puts it on a queue, downloads the image, compresses it, and then puts it on a bucket, could generate traces like the following:

1:00am Endpoint (Type=EndpointCalled, TraceId=trace_abc123, EventId=event_1)
1:00am Function (Type=FunctionCalled, TraceId=trace_abc123, EventId=event_2)
1:01am UrlsQueue (Type=MessageAdded, TraceId=trace_abc123, EventId=event_3)
1:05am DownloadAndCompressImageFunction (Type=FunctionCalled, TraceId=trace_abc123, EventId=event_4)
1:10am Bucket (Type=FileAdded, TraceId=trace_abc123, EventId=event_5)

Also, these events usually have another property parentID which references the parent event that generated them. In Event Sourcing, Trace IDs are named Correlation ID and Parent IDs are named Causation IDs. See the following image:

image

More information on this link: https://blog.arkency.com/correlation-id-and-causation-id-in-evented-systems/.

I'm okay with either naming (traceId and parentId, or correlationId and causationId) but I think we should have those properties. As for the Simulator API, I'd suggest to use the following naming instead (since it's not handling traces per se):

simulator.onEvent({
  callback(event) {},
});

@Chriscbr please, have a look! Let's discuss it if you have time 🙏🏻

_Originally posted by @skyrpex in #918

@Chriscbr
Copy link
Contributor Author

@skyrpex and I discussed this a little bit offline, what we came up with was something like this:

  • every Trace should have an id (always unique), a parentId (reference to another trace that "caused" the current trace), and a traceId (reference to the first trace in the current sequence of correlated events)
  • The SDK should create a new trace context when there isn't already one, and use it to group correlated events together through the traceId field
  • Discussed the idea of giving traces both start and end timestamps - for now let's skip this, and instead create two traces for situations (representing the start and end of some event) when this is needed

@skyrpex let me know if I missed anything.

@skyrpex
Copy link
Contributor
skyrpex commented Dec 15, 2022

It looks good to me, except that what you call traces I call it events. So, the SDK logs events which have an ID, a parent ID, and a trace ID. A trace is a group of events (can be in the shape of a tree).

@Chriscbr Chriscbr transferred this issue from another repository Dec 21, 2022
@Chriscbr Chriscbr added 🎨 sdk SDK 🕹️ simulator Related to the `sim` compilation target labels Dec 21, 2022
@github-actions
Copy link

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions
Copy link
github-actions bot commented May 1, 2023

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎨 sdk SDK 🕹️ simulator Related to the `sim` compilation target
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

3 participants