question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to set CreationPolicy with AuditApi attribute

See original GitHub issue

Now, it’s not possible to set CreationPolicy by AuditApi attribute. It would be great to allow it.

An example:

public class SomeController : ApiController
{
    [AuditApi(EventTypeName = "FooCalled"]
    public async IActionResult FooAction()
    {
       // the audit event is saved on dispose because scope's CreationPolicy is EventCreationPolicy.InsertOnEnd
   }

    [AuditApi(EventTypeName = "BarDone", CreationPolicy=EventCreationPolicy.Manual)] // <-- this isn't possible now
    public async IActionResult BarAction()
    {
       // the audit event is discarded by default
       ...
       if (done) {
         // the audit event is saved
          await this.GetCurrentAuditScope().Save();
       }
    }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pinggicommented, Nov 25, 2021

You are right actually. There won’t be the response info but there wouldn’t be anyway with the manual policy configured globally by Configuration.Setup().WithCreationPolicy(EventCreationPolicy.Manual).

I will leave it up to you. I think I can implement it like you mentioned that the provider will check the response status and whether there was an exception and based on this will decide about the sending.

Thank you.

0reactions
thepirat000commented, Nov 25, 2021

ok, I can add that config. But note the webapi audit event will not have the response information at the moment of saving, with the approach you’re suggesting.

That’s why I thought it would be better to let the data provider decide which event should be sent/saved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CreationPolicy attribute - AWS CloudFormation
Use the CreationPolicy attribute to determine how long to wait before the status of a stack resource proceeds to create complete or create...
Read more >
Cloudformation "CreationPolicy" attribute not working
The documenation uses CreationPolicy attribute and cfn-signal to notify AWS Cloudformation that Instance1 has come up. I tried the code.
Read more >
Audit.WebApi
An extensible framework to audit executing operations in .NET and .NET Core. - Audit.NET/src/Audit.WebApi/README.md at master · thepirat000/Audit.NET.
Read more >
AWS CloudFormation CreationPolicy vs WaitCondition
WaitCondition is a CloudFormation resource in itself, whereas CreationPolicy is an attribute associated with other resources.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found