-
-
Notifications
You must be signed in to change notification settings - Fork 240
🚧 Feature/sentry.quartz (Quartz v4 Alpha version) #5505
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
Open
michaelmairegger
wants to merge
21
commits into
getsentry:main
Choose a base branch
from
michaelmairegger:feature/sentry.quartz
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ebced5a
feat: add Sentry.Quartz
michaelmairegger 25d9335
refactor: optimize cron information retrieval in SentryCronJobListener
michaelmairegger 6e8980d
refactor: swap ILogger dependency from SentryCronJobListener with IDi…
michaelmairegger 3c2b354
refactor: simplify Quartz configuration by removing redundant service…
michaelmairegger 399ba1f
refactor: migrate to Quartz v4.0.0 with .NET 10
michaelmairegger fecdedd
feat: include Sentry.Quartz in solution filter and generation scripts
michaelmairegger 1f5b78f
Merge remote-tracking branch 'upstream/main' into feature/sentry.quartz
michaelmairegger 625b3e8
feat: add Quartz sample showcasing Sentry integration
michaelmairegger b1c815b
fix: cursor github comments
michaelmairegger 92b8e1e
refactor: simplify Quartz configuration and update project to use Web…
michaelmairegger ce9ff8f
refactor: replace SentryCronJobListener with SentryCronJobMiddleware …
michaelmairegger fd03cb7
fix: handling issue where current region might throw a CultureNotFoun…
michaelmairegger 1abc08d
fix: sample project has different nuget package version
michaelmairegger 6bf1550
fix: skip middleware execution for non-cron triggers
michaelmairegger 8a53e47
refactor: rename and update Quartz extension method to AddSentryCronJob
michaelmairegger b698d17
feat: add SentryMetricsMiddleware to track Quartz job execution durat…
michaelmairegger c7a3068
refactor: simplify AddSentryCronJob method by removing unused service…
michaelmairegger a5a7323
feat: add SentryScopeMiddleware and extend Quartz integration with Ad…
michaelmairegger 37e4272
refactor: move non-cron trigger check to StartQuartz method
michaelmairegger 8e9c712
feat: add missing options parameter
michaelmairegger ba6f733
refactor: remove unused project reference to Sentry.AspNetCore in Sen…
michaelmairegger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.Extensions.Hosting; | ||
| using Quartz; | ||
| using Sentry.Quartz; | ||
|
|
||
| namespace Sentry.Samples.Quartz; | ||
|
|
||
| public static class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
| builder.WebHost.UseSentry(); | ||
|
|
||
| builder.Services.AddQuartz(quartz => | ||
| { | ||
| quartz.UseSentry(builder.Services, options => | ||
| { | ||
| var jobKey1 = new JobKey(nameof(FirstJob)); | ||
| quartz.AddJob<FirstJob>(opts => opts.WithIdentity(jobKey1)); | ||
| quartz.AddTrigger<FirstJob>(opts => opts.ForJob(jobKey1).WithIdentity($"{nameof(FirstJob)}-trigger").WithCronSchedule("*/10 * * ? * *")); | ||
|
|
||
| var jobKey2 = new JobKey(nameof(SecondJob)); | ||
| quartz.AddJob<SecondJob>(opts => opts.WithIdentity(jobKey2)); | ||
| quartz.AddTrigger<SecondJob>(opts => opts.ForJob(jobKey2).WithIdentity($"{nameof(SecondJob)}-trigger").WithCronSchedule("*/10 * * ? * *")); | ||
|
|
||
| var jobKey3 = new JobKey(nameof(ThirdJob)); | ||
| quartz.AddJob<ThirdJob>(opts => opts.WithIdentity(jobKey3)); | ||
| quartz.AddTrigger<ThirdJob>(opts => opts.ForJob(jobKey3).WithIdentity($"{nameof(ThirdJob)}-trigger").WithCronSchedule("*/10 * * ? * *")); | ||
|
|
||
| if (!builder.Environment.IsProduction()) | ||
| { | ||
| options.EnableUpsertCronMonitor = false; | ||
| } | ||
| }); | ||
|
michaelmairegger marked this conversation as resolved.
|
||
| }).AddQuartzHostedService(); | ||
|
|
||
| var app = builder.Build(); | ||
|
|
||
| app.Run(); | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| [SentryCronMonitorSlug("first-job")] | ||
| public class FirstJob : IJob | ||
| { | ||
| public async ValueTask Execute(IJobExecutionContext context, CancellationToken cancellationToken) | ||
| { | ||
| Console.WriteLine($"Starting to do some heavy work at: {DateTime.Now}"); | ||
| await Task.Delay(1000, cancellationToken); | ||
| Console.WriteLine($"Finished doing some heavy work at: {DateTime.Now}"); | ||
| } | ||
| } | ||
|
|
||
| [SentryCronMonitorSlug("job-that-throws")] | ||
| public class SecondJob : IJob | ||
| { | ||
| public async ValueTask Execute(IJobExecutionContext context, CancellationToken cancellationToken) | ||
| { | ||
| Console.WriteLine($"Starting to do some heavy work at: {DateTime.Now}"); | ||
| await Task.Delay(1000, cancellationToken); | ||
| Console.WriteLine($"Finished doing some heavy work at: {DateTime.Now}"); | ||
| throw new Exception(); | ||
| } | ||
| } | ||
|
|
||
| [SentryCronMonitorSlug("RecurringBackgroundJob")] | ||
| public class ThirdJob : IJob | ||
| { | ||
| public async ValueTask Execute(IJobExecutionContext context, CancellationToken cancellationToken) | ||
| { | ||
| Console.WriteLine($"Starting to do some heavy work at: {DateTime.Now}"); | ||
| await Task.Delay(1000, cancellationToken); | ||
| Console.WriteLine($"Finished doing some heavy work at: {DateTime.Now}"); | ||
| } | ||
| } | ||
41 changes: 41 additions & 0 deletions
41
samples/Sentry.Samples.Quartz/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/launchsettings.json", | ||
| "iisSettings": { | ||
| "windowsAuthentication": false, | ||
| "anonymousAuthentication": true, | ||
| "iisExpress": { | ||
| "applicationUrl": "http://localhost:5138/", | ||
| "sslPort": 44386 | ||
| } | ||
| }, | ||
| "profiles": { | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "hangfire", | ||
| "applicationUrl": "http://localhost:5138", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "hangfire", | ||
| "applicationUrl": "http://localhost:5138", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "IIS Express": { | ||
| "commandName": "IISExpress", | ||
| "launchBrowser": true, | ||
| "launchUrl": "hangfire", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Sentry for Hangfire | ||
|
|
||
| This is a standard ASP.NET Core app with nothing in it but Quartz. | ||
| To run this sample: | ||
|
|
||
| ```sh | ||
| dotnet run | ||
| ``` |
24 changes: 24 additions & 0 deletions
24
samples/Sentry.Samples.Quartz/Sentry.Samples.Quartz.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| </PropertyGroup> | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Quartz" Version="4.0.0-alpha.4" /> | ||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(Configuration)' == 'Release'"> | ||
| <SentryOrg>sentry-sdks</SentryOrg> | ||
| <SentryProject>sentry-dotnet</SentryProject> | ||
| <SentryUploadSymbols>true</SentryUploadSymbols> | ||
| <SentryUploadSources>true</SentryUploadSources> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\Sentry.Quartz\Sentry.Quartz.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| // Example configuration via JSON. Only a subset of the settings below: | ||
| // All Sentry settings can also be configured via code or environment variables: | ||
| "Sentry": { | ||
| // The DSN can also be set via environment variable | ||
| // "Dsn": "TODO: Configure your DSN here and uncomment this line", | ||
| // Opt-in for payload submission | ||
| "MaxRequestBodySize": "Always", | ||
| // Sends Cookies, User Id when one is logged on and user IP address to sentry. It's turned off by default. | ||
| "SendDefaultPii": true, | ||
| // Whether to add System.Diagnostics.Activity data to the event:: | ||
| // For more: https://github.com/dotnet/runtime/blob/master/src/libraries/System.Diagnostics.DiagnosticSource/src/ActivityUserGuide.md | ||
| "IncludeActivityData": true, | ||
| // Record any message with this level or higher as a breadcrumb (default is Information) | ||
| "MinimumBreadcrumbLevel": "Information", | ||
| // Don't only keep Warnings as Breadcrumb but actually send an event | ||
| "MinimumEventLevel": "Warning", | ||
| // Send the stack trace of captured messages (e.g: a LogWarning without an exception) | ||
| "AttachStackTrace": true, | ||
| // The flag below can be used to see the internal logs of the SDK in the applications log (it's off by default) | ||
| "Debug": true, | ||
| // By default the level is Debug but it can be changed to any level of SentryLevel enum | ||
| "DiagnosticLevel": "Error", | ||
| "DefaultTags": { | ||
| "default-key-in-config": "default-value" | ||
| } | ||
| }, | ||
| "Logging": { | ||
| "IncludeScopes": false, | ||
| "LogLevel": { | ||
| "Default": "Trace" | ||
| } | ||
| }, | ||
| "Kestrel": { | ||
| "EndpointDefaults": { | ||
| "Protocols": "Http2" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.