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

Tracing / logging / auditing as capability #249

Open
mknet opened this issue Jun 26, 2024 · 2 comments
Open

Tracing / logging / auditing as capability #249

mknet opened this issue Jun 26, 2024 · 2 comments

Comments

@mknet
Copy link

mknet commented Jun 26, 2024

Hello everybody,

I try to implement the kind of auditing / tracing as a capability. The idea behind it is that the shell gets the info that "something happened" and the shell decides what to do with this info.
On the rust side I try to use a crate like tracing so I can just reuse the macros and the existing implementation. I tried to implement a custom subscriber forwarding the tracing events to the capability's operation method (I call the method trace).
Now I got this dilemma: I need the instance of the core so I can invoke the capability operation within the method update. In order to invoke update I invoke process_event with an internal event Trace. The invocation of process_event happens in the custom tracing subscriber. Now, when I process an other event I end in the following stack:

  1. Root (business) event passed to process_event
  2. Handle event in update
  3. Invoke tracing event
  4. Handle tracing event by invoking process_event

And this leads to the error rwlock write lock would result in deadlock within implementation of process_event. If I got it right the reason is, that self.model.write() is invoked twice without releasing the lock in the stack.

Now, I want to ask you guys what you think. How can we implement a kind of auditing / tracing / logging capability reusing implementations which already exist.
I am open to every idea or hint.

Thanks for your interest and support.

@StuartHarris
Copy link
Member

Hey @mknet apologies for slow response, but happy to help. I like the idea of a tracing subscriber as a capability. I'm a little confused as to why you're calling process_event from the shell-side of the capability. Maybe you have some code you can share? I'd be up for adding tracing to one of the examples (probably the counter), where the shell side records the subscribed events and spans to local storage or something. Would that be useful?

@mknet
Copy link
Author

mknet commented Jul 4, 2024

@StuartHarris Thanks for reaching out to me.

I'm a little confused as to why you're calling process_event from the shell-side of the capability.

The idea behind it, is that the tracing subscriber catches the tracing events and provides them via capability. I see no other option for forwarding the event to a capability than going through process_event.

Maybe you have some code you can share?

This does makes a lot of sense. Unfortunately, I cannot share my original code. I will provide a sample project and will come back to you asap.

I'd be up for adding tracing to one of the examples (probably the counter), where the shell side records the subscribed events and spans to local storage or something. Would that be useful?

Yes, I guess this would help. At least it will show your thoughts about this topic. So, please go ahead. Thanks!

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

No branches or pull requests

2 participants