Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default tags to outgoing errors #526

Open
bmoscao opened this issue Apr 3, 2024 · 2 comments
Open

Add default tags to outgoing errors #526

bmoscao opened this issue Apr 3, 2024 · 2 comments

Comments

@bmoscao
Copy link

bmoscao commented Apr 3, 2024

Is your feature request related to a problem? Please describe.
With the deprecation of the following code, we can no longer hook centralized handlers on the SendingMessage event easily.
We used this approach to enrich all outgoing messages with tags that captured environment info, like service name, instance, etc.

builder.Services.AddRaygun(builder.Configuration, new RaygunMiddlewareSettings
{
  // adds an optional example of over riding the client provider
  ClientProvider = new ExampleRaygunAspNetCoreClientProvider()
});

Describe the solution you'd like
Maybe an approach similar to IRaygunUserProvider or just extending RaygunSettings to allow for default tag list or configure event handlers directly on DI setup.

Describe alternatives you've considered
We considered getting the RaygunClient singleton from the DI container and adding the SendingMessage event handler, but it seems to be a bit of a hack.

@phillip-haydon
Copy link
Contributor

Thanks for raising the issue, definitely an oversight, we will have to have a think about the best way to amend this.

In the short term you could do:

builder.Services.AddSingleton(s => 
{
  var client = new RaygunClient(s.GetService<RaygunSettings>()!, s.GetService<IRaygunUserProvider>()!);

  client.SendingMessage += (sender, eventArgs) =>
  {
    eventArgs.Message.Details.Tags.Add("Fruits!");
  };

  return client;
});

builder.Services.AddRaygun(builder.Configuration);

This should let you hook into the original functionality directly. Obviously this isn't an elegant solution, but it should unblock you while we decide on a cleaner solution.

@phillip-haydon
Copy link
Contributor

https://raygun.com/forums/thread/186954

I was thinking of Tags being in settings but thinking about this forum post and this issue it might be worth while having a collection of 'plugins' or 'filters' which are invoked just before sending to allow for this custom type functionality.

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

No branches or pull requests

2 participants