Coder Social home page Coder Social logo

Comments (5)

thepirat000 avatar thepirat000 commented on June 16, 2024

Looks like you're getting a timeout from cosmosDB when trying to save the audit event.

Is your audit event too large?

Have you seen Diagnose and troubleshoot Azure Cosmos DB .NET SDK request timeout exceptions? Maybe you need to customize the timeout.

from audit.net.

wouter-b avatar wouter-b commented on June 16, 2024

You could be right about the audit event size. I'll dive into that.
Is there any way I could catch the Exception? So, I can log the exception and continue.

from audit.net.

thepirat000 avatar thepirat000 commented on June 16, 2024

Also, you could implement your own data provider, by inheriting from AzureCosmosDataProvider and adding your custom try/catch mechanism in the Insert Audit Event logic.

For example:

public class AzureCosmosCustomProvider : AzureCosmosDataProvider
{
    public AzureCosmosCustomProvider() : base() { }
    public AzureCosmosCustomProvider(Action<IAzureCosmosProviderConfigurator> config) : base(config) { }

    public override object InsertEvent(AuditEvent auditEvent)
    {
        try
        {
            return base.InsertEvent(auditEvent);
        }
        catch (CosmosException ex) when (ex.StatusCode == HttpStatusCode.RequestTimeout)
        {
            // timed out
            return null;
        }
    }

    public override async Task<object> InsertEventAsync(AuditEvent auditEvent, CancellationToken cancellationToken = default)
    {
        try
        {
            return await base.InsertEventAsync(auditEvent, cancellationToken);
        }
        catch (CosmosException ex) when (ex.StatusCode == HttpStatusCode.RequestTimeout)
        {
            // timed out
            return null;
        }
    }
}

Then you can set up the data provider like this:

Audit.Core.Configuration.Setup()
    .Use(new AzureCosmosCustomProvider(_ => _
        .Endpoint(...)
        .Database(...)
        .Container(...)
        .AuthKey(...)));

from audit.net.

thepirat000 avatar thepirat000 commented on June 16, 2024

If you're looking for a retry mechanism. check this: #372 (comment)

from audit.net.

wouter-b avatar wouter-b commented on June 16, 2024

A big thanks, your suggestions will solve my issue 👍

from audit.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.