Coder Social home page Coder Social logo

kanadaj / sentry.monitor Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 0.0 71 KB

Sentry cron monitoring integration for Hangfire and Quartz

License: MIT License

C# 100.00%
crash-reporting cronjob hangfire quartz-net quartz-scheduler sentry sentry-monitor

sentry.monitor's Introduction

Sentry.Monitor

Hangfire

Usage

You need to add the Sentry JobFilter to the Hangfire global configuration via the UseSentryMonitor(HttpClient, string) helper method:

services.AddHangfire((serviceProvider, config) => config.
	.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
	.UseSimpleAssemblyNameTypeSerializer()
	.UseRecommendedSerializerSettings()
	// Add SentryMonitorJobFilter to Hangfire
	.UseSentryMonitor(
	    serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient("SentryMonitor"), 
	    configuration["Sentry:Dsn"]
    )
);

Then you need to add [SentryMonitorId("00000000-0000-0000-0000000000")] to your job method or the containing class, with the appropriate monitor ID retrieved from sentry.

If you use Microsoft.Extensions.DependencyInjection to configure your scheduler, you can use AddHangfireSentryMonitor() along wth UseSentryMonitor() instead:

// Register and configure SentryMonitorClient
services.AddHangfireSentryMonitor();

services.AddHangfire((serviceProvider, config) => config.
	.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
	.UseSimpleAssemblyNameTypeSerializer()
	.UseRecommendedSerializerSettings()
	// Add SentryMonitorJobFilter to Hangfire
	.UseSentryMonitor(serviceProvider)
);

Quartz

Usage

When configuring your scheduler, add the Sentry JobListener to the scheduler:

scheduler.ListenerManager
    .AddSentryMonitor(
        serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient("SentryMonitor"), 
        configuration["Sentry:Dsn"]
    );

If you use Microsoft.Extensions.DependencyInjection to configure your scheduler, you can use the AddQuartzSentryMonitor() extension method instead:

// This call is optional and only needed if you want to add custom Quartz configuration; AddQuartzSentryMonitor also calls AddQuartz to add the listener 
services.AddQuartz(config => {});

// Add SentryMonitorJobListener to Quartz
services.AddQuartzSentryMonitor();

Then you need to add [SentryMonitorId("00000000-0000-0000-0000000000")] to your IJob class, with the appropriate monitor ID retrieved from sentry.

sentry.monitor's People

Contributors

kanadaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.