rollbar / Rollbar.NET

Rollbar for .NET
https://docs.rollbar.com/docs/dotnet
MIT License
67 stars 44 forks source link

A way to set a custom UUID #552

Closed jrouaix closed 4 years ago

jrouaix commented 4 years ago

Is your feature request related to a problem? Please describe. Well, at https://github.com/BeezUP let's say we don't have only rollbar as a logger, so we have a unique error identifier of our own. Could we have a way to provide it to your api so it can override your UUID creation (https://github.com/rollbar/Rollbar.NET/blob/bf94ed51597b9ffd378e4dfa3c740c15e6ceb0f0/Rollbar/DTOs/Data.cs#L156), so our errorId will match everywhere in the system and many monitoring dashboards.

Describe the solution you'd like Somewhere in those lines, a way to override the UUID prior to send the exception.

            var package = new ExceptionPackage(exception);
            _rollbar.Error(package);
akornich commented 4 years ago

@jrouaix , i think something like this may work for you now:

IRollbarPackage package = new ExceptionPackage(exception);
var custom = new Dictionary<string, object>();
custom["BeezUp.Logs.CorrelationID"] = Guid.New; // or whatever you use...
package = new CustomKeyValuePackageDecorator(package, custom);
_rollbar.Error(package); 

Let me know if that is nor what you were looking for...

jrouaix commented 4 years ago

Thank you @akornich but we already have this as a custom value. What we want is the possibility to provide a user generated UUID as it's possible with your rest api (https://explorer.docs.rollbar.com/#operation/create-item) but not exposed by your official client library. Do you have an idea to customize this one without forking your official lib ?

jrouaix commented 4 years ago

Well, we really need this right away ... forking

jrouaix commented 4 years ago

https://github.com/BeezUP/Rollbar.NET By the way, i'll have to handle first https://github.com/rollbar/Rollbar.NET/issues/529 Then i'll push a PR

jrouaix commented 4 years ago

Do you have an idea to customize this one without forking your official lib ?

ping @akornich ?

akornich commented 4 years ago

i am still waiting for the final word from our backend (payload processing) team regarding this one. the UUID is somewhat operationally essential for them. most people I talked suggest that a custom field should be the safest way to go about it. I'll try to get a more definitive answer by tomorrow. stay tuned...

jrouaix commented 4 years ago

Found your decorators ... could it be as simple as this ? image

akornich commented 4 years ago

@jrouaix , correct, a package decorator would be the way to go with custom UUID value. Another option would be to define your own payload transform delegate (but that would be a less flexible option).

akornich commented 4 years ago

@jrouaix , i guess, if you can guarantee the custom UUID value uniqueness, you should be fine. Just FYI, the UUID is used during the payload ingestion process to remove duplicates. To define your own UUID value, your options are:

  1. create a dedicated package decorator for setting the UUID and apply it to a package to be sent.
  2. OR build an instance of Rollbar.DTOs.Data and explicitly set UUID on it, then send it to Rollbar.
  3. OR modify the payload's UUID within custom-defined payload transformation delegate.

Option 1 is the recommended way of doing it as the most flexible and reusable one.

akornich commented 4 years ago

@jrouaix, so are good for now can we close this issue? By the way, your PR for offline persistence is included in the latest v3.13.0-beta release. Thanks for the help!

jrouaix commented 4 years ago

Yep, and it was indeed compatible with older versions of the client, so we didn't have to wait for the vNext. thank you !