NickCraver / StackExchange.Exceptional

Error handler used for the Stack Exchange network
https://nickcraver.com/StackExchange.Exceptional/
Apache License 2.0
863 stars 171 forks source link

MemoryErrorStore does not respect ApplicationName #168

Closed Danthar closed 3 years ago

Danthar commented 5 years ago

Using v2.0.0 im initialising the MemoryErrorStore like so: However the ApplicationName setting is not respecting the log UI still shows "My Application"

settings.DefaultStore = new StackExchange.Exceptional.Stores.MemoryErrorStore(new ErrorStoreSettings()
                {
                    ApplicationName = "Test",
                    RollupPeriod = TimeSpan.FromMinutes(30),
                    Size = 5000
                });

Note that this is in an asp.net (netFull) application. And im not using any of the web.config stuff other then the httpmodule initialisation.

Note that using the config setting:

<Exceptional applicationName="Test name">
  </Exceptional>

Does work.

NickCraver commented 4 years ago

I am unable to repro this locally (name comes across correctly) - do you have anything in your web.config when this happens? I'm not sure what combination triggers your case here but would like to fix it!

Danthar commented 4 years ago

I'll provide some snippets this week.

Op zo 27 okt. 2019 15:17 schreef Nick Craver notifications@github.com:

I am unable to repro this locally (name comes across correctly) - do you have anything in your web.config when this happens? I'm not sure what combination triggers your case here but would like to fix it!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NickCraver/StackExchange.Exceptional/issues/168?email_source=notifications&email_token=AAHQ3FY2KZYSV5T5FSUAA5LQQWPIVA5CNFSM4HOIKARKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECK7NGI#issuecomment-546698905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHQ3F6XGQX7DJJFGG642K3QQWPIVANCNFSM4HOIKARA .

Danthar commented 4 years ago

We have absolutely no exceptional config in our web.config. Except for the modules:

<system.webServer>

 <modules runAllManagedModulesForAllRequests="true">
  <add name="ErrorStore" type="StackExchange.Exceptional.ExceptionalModule, StackExchange.Exceptional"/>
<add name="ContainerDisposal" type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web" preCondition="managedHandler"/>
      <remove name="ApplicationInsightsWebTracking"/>
      <remove name="TelemetryCorrelationHttpModule"/>
      <add name="TelemetryCorrelationHttpModule"
        type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="managedHandler"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
        preCondition="managedHandler"/>
      <add name="AttributedInjection" type="Autofac.Integration.Web.Forms.AttributedInjectionModule, Autofac.Integration.Web"/>
</modules>

So there is some gore there. But nothing that i would expect to be an issue.

Then in our routing config we have this:

 routes.MapRoute("Exceptional", "Exceptions/{*resource}", new { controller = "Admin", action= "Exceptions" });

The Admin controller contains nothing more then this:

  public Task Exceptions() => ExceptionalModule.HandleRequestAsync(System.Web.HttpContext.Current);
Danthar commented 4 years ago

Addendum. I thought that maybe we simply call the Exceptional.Configure method to late. But thats not it either. Its being called in the Application_Start of the global.asax

Danthar commented 4 years ago

Found it.

var applicationName = "UBER TEST CASE";
 Exceptional.Configure(settings =>
            {
                settings.AppendFullStackTraces = true;
                settings.GetCustomData = (exception, data) =>
                {
                    //some custom metrics are added here
                };
                settings.DefaultStore = new StackExchange.Exceptional.Stores.MemoryErrorStore(new ErrorStoreSettings()
                {
                    ApplicationName = applicationName, //<-- ZE SETTING, IT DOES NOTHING
                    RollupPeriod = TimeSpan.FromMinutes(30),
                    Size = 5000
                });
                settings.DefaultStore.Settings.ApplicationName = applicationName; //<-- ZE SETTING, IT STILL DOES NOTHING
                settings.Ignore.Regexes = new HashSet<Regex>()
                {
                    new Regex(@"The client disconnected\.$"), 
                    new Regex(@"Invalid viewstate\.$"), //die viewstate shit
                };
            });
            Exceptional.Settings.Store.ApplicationName = applicationName; // THIS SETTING WORKS
Danthar commented 4 years ago

So i don't know if this is user error or not. But i'd expect passing the application name setting in the defaultstore initialisation to work. Afterwards. I was able to reduce setting the DefaultStore thingy to just this:

   settings.Store.RollupPeriod = TimeSpan.FromMinutes(30);
                settings.Store.Size = 5000;
                settings.Store.ApplicationName = applicationName;

And that works just as you would expect. So i guess its user error. But then i wonder, why is the DefaultStore a viable setting in the first place ?

NickCraver commented 3 years ago

Apologies for not updating here, but this was fixed a while back - we found the initialization order issue by accident when doing something else with Stack Overflow. Now both cases should work :)