GithubHelp home page GithubHelp logo

Comments (10)

martintmk avatar martintmk commented on June 26, 2024 4

If the EventSeverityOverrides is exposed as an IDictionary then you can not enforce the usage of the TryGetValue inside the user provided delegate. People could still use the indexer.

It's either delegate or dictionary. I am gravitating towards using the delegate to override the severity (defaults to null) due to greater flexibility. In our code we would just invoke the delegate (if provided) just before logging/metering and it would change the severity for that event.

With either solution, it'd be great if it could be applied to specific pipelines (as opposed to globally).

You can explicitly call ConfigureTelemetry and it will override the telemetry just for that pipeline. Note about cloning the default options.

services.AddResiliencePipeline("my-key", (builder, context) =>
{
    builder.AddConcurrencyLimiter(10);

    // Resolve pre-configured options
    var global = context.GetOptions<TelemetryOptions>();
    var copy = new TelemetryOptions(global);

    // Modify the copy
    ...

    // Apply telemetry just for this pipeline
    builder.ConfigureTelemetry(copy);
});

Alternatively, we can allow ConfigureTelemetry to accept multiple options and it would merge them together transparently (without doing the cloning stuff).

from polly.

martincostello avatar martincostello commented on June 26, 2024 1

As far as I'm aware, as you've indicated, there's no way to change the severities at this time. It seems a reasonable suggestion to be able to allow this to be customised though.

from polly.

martintmk avatar martintmk commented on June 26, 2024 1

Thinking we could introduce something like this:

public class TelemetryOptions
{
    // ... existing properties

    public IDictionary<string, ResilienceEventSeverity> EventSeverityOverrides { get; set; }
}

BY default, it would be empty. If specified one could override the built-in severity for events. Also, I think we can downgrade the OnRejected to Warning. Error seems too high indeed.

Usage:

services.Configure<TelemetryOptions>(options =>
{
    options.EventSeverityOverrides["OnRateLimiterRejected"] = ResilienceEventSeverity.Information;
}); 

from polly.

martincostello avatar martincostello commented on June 26, 2024 1

Constants or not, we wouldn't get exceptions because we'd use TryGetValue() not the indexer.

from polly.

peter-csala avatar peter-csala commented on June 26, 2024

☝🏻 seems a bit error-prone. Non-existing key overrides would result in KeyNotFoundException.

Introducing hierarchical constants might be a better option IMHO.

options.EventSeverityOverrides[TelemetryNames.RateLimiter.OnRejected] = ResilienceEventSeverity.Information;

from polly.

martintmk avatar martintmk commented on June 26, 2024

Since this is for advanced scenarios, the user can put whatever strings they want into the dictionary. If the name does not match up with existing telemetry events, we won't do any overrides.

Alternatively, we can allow delegate to be used (faster API and more flexible):

public class TelemetryOptions
{
    // ... existing properties
    public Func<ResilienceEvent, ResilienceEventSeverity>? ResilienceEventSeverityProvider { get; set; }
}

from polly.

wjrogers avatar wjrogers commented on June 26, 2024

The delegate would be more flexible because it could conditionally change the severity based on other properties of the event. The static dictionary would be okay, too, though. With either solution, it'd be great if it could be applied to specific pipelines (as opposed to globally).

from polly.

peter-csala avatar peter-csala commented on June 26, 2024

Constants or not, we wouldn't get exceptions because we'd use TryGetValue() not the indexer.

If the EventSeverityOverrides is exposed as an IDictionary then you can not enforce the usage of the TryGetValue inside the user provided delegate. People could still use the indexer.

from polly.

github-actions avatar github-actions commented on June 26, 2024

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

from polly.

wjrogers avatar wjrogers commented on June 26, 2024

not stale

from polly.

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.