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

Current version of sink doesn't support fingerprits #13

Open
chromigo opened this issue Oct 9, 2018 · 1 comment
Open

Current version of sink doesn't support fingerprits #13

chromigo opened this issue Oct 9, 2018 · 1 comment

Comments

@chromigo
Copy link

chromigo commented Oct 9, 2018

Hi

Our team use this sink and I notice that current version has not fignerprint support. Will you add this support in next releases?

I tried to add this support into sink by myself but solution is not convenient and seems dirty - combination of custom enricher and some logic in sink

class FingerprintEnricher : ILogEventEnricher
    {
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            if (logEvent.MessageTemplate.Text.StartsWith("test"))//some logic to check
            {
                logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(
                    "Fingerprint", new[] { "Source: some source" }));
            }
        }
    }

in SerilogSink.Emit

            var fingerPrints = logEvent.Properties.Where(pair => pair.Key == "Fingerprint").Select(e => e.Value).ToArray();
            foreach (var fingerPrint in fingerPrints)
            {
                sentryEvent.Fingerprint.Add(fingerPrint.ToString());
            }

On the other side we have new sentry sdk with static call

SentrySdk.ConfigureScope(scope =>
{
    scope.SetFingerprint(new[] { "my-view-function" });
});

It may be more sense to rewrite current sink to new sdk.

@chromigo
Copy link
Author

chromigo commented Oct 10, 2018

Another variant to add in sink

            var fingerPrint = logEvent.Properties
                .Where(e =>string.Equals(e.Key, "fingerprint", StringComparison.OrdinalIgnoreCase))
                .Select(e => e.Value)
                .FirstOrDefault();
            if (fingerPrint != null && !string.IsNullOrEmpty(fingerPrint.ToString()))
            {
                sentryEvent.Fingerprint.Add(fingerPrint.ToString());
            }

Use case:
logger.Log("{fingerprint} Some Message {some other parametr}", exception, fingerprint, param1)

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

No branches or pull requests

2 participants