Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Default Throttle Logging #1

Closed
CraigKennedy opened this issue Dec 18, 2013 · 6 comments
Closed

Default Throttle Logging #1

CraigKennedy opened this issue Dec 18, 2013 · 6 comments

Comments

@CraigKennedy
Copy link
Contributor

Provide a default implementation of the IThrottleLogger that logs to Diagnostic Trace or provide a default implementation of the ITraceWriter. This will allow the throttle messages to dump straight to the logging pipeline that might already be in place.

@CraigKennedy
Copy link
Contributor Author

Here is a possible example of what I envision it could look like:

public class TracingThrottleLogger : IThrottleLogger
{
    public void Log(ThrottleLogEntry entry)
    {
        var trace = GlobalConfiguration.Configuration.Services.GetService(typeof(ITraceWriter)) as ITraceWriter;
        if (null != trace)
        {
            trace.Info(null, "WebApiThrottle", "{0} Request {1} to endpoint {2} from client {3} has been throttled (blocked), quota {4}/{5} exceeded by {6}",
                entry.LogDate, entry.RequestId, entry.ClientIp, entry.RateLimit,
                entry.Endpoint, entry.RateLimitPeriod, entry.TotalRequests);
        }
    }
}

@stefanprodan
Copy link
Owner

Hello Craig, I don't want to create more dependencies for WebApiThrottle by adding WebApi.Tracing reference. Your ITraceWriter implementation is best suited in the Demo project, I will provide there an working example and I will update the documentation accordingly. Thanks for your feedback, I appreciate it.

@CraigKennedy
Copy link
Contributor Author

What do you think about instead of using ITraceWriter, using System.Diagnostics.Trace instead?

I have a Trace Listener that forwards messages from the trace to my logging framework. This might accomplish my desire to not have to create/manage a throttle logger implementation and not introduce a dependency to the package.

@stefanprodan
Copy link
Owner

Seems that ITraceWriter doesn't need a reference to System.Web.Http.Tracing, this interface is part of System.Web.Http. I think that the TracingThrottleLogger you've added covers all logging needs.

@CraigKennedy
Copy link
Contributor Author

What kind of timeframe is there on the publish to NuGet?

On Dec 18, 2013, at 11:11 AM, Stefan Prodan <notifications@github.commailto:notifications@github.com> wrote:

Seems that ITraceWriter doesn't need a reference to System.Web.Http.Tracing, this interface is part of System.Web.Http. I think that the TracingThrottleLogger you've added covers all logging needs.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-30854590.

@stefanprodan
Copy link
Owner

I have a TeamCity server that deploys to Nuget, it's running now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants