OpenTelemetry.Instrumentation.Quartz 1.15.1-beta.1

QuartzNET Instrumentation for OpenTelemetry .NET

Status
Stability Beta
Code Owners @maldago

NuGet version badge NuGet download count badge codecov.io

Automatically instruments the Quartz jobs from Quartz.

Supported Frameworks

QuartzNET Instrumentation is only supported when using .NET Framework >= net472 and .NET Standard >= netstandard2.0. Quartznet461 support for activity sources has been removed, more information can be found here.

Installation

dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package --prerelease OpenTelemetry.Instrumentation.Quartz

Configuration

ASP.NET Core instrumentation example:

// Add QuartzNET inside ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
    services.AddQuartz(q =>
    {
        // base quartz scheduler, job and trigger configuration
    });

    // ASP.NET Core hosting
    services.AddQuartzServer(options =>
    {
        // when shutting down we want jobs to complete gracefully
        options.WaitForJobsToComplete = true;
    });
}

// Add OpenTelemetry and Quartz instrumentation
services.AddOpenTelemetry().WithTracing(x =>
{
    x.AddQuartzInstrumentation();
    x.AddOtlpExporter(config => {
      // Configure OTLP
    });
});

Filter traced operations

This option allows you to filter trace operations.

For example you can trace only execute operations using this snippet:

// ...
using OpenTelemetry.Instrumentation.Quartz.Implementation;
// ...
x.AddQuartzInstrumentation(
    opts =>
        opts.TracedOperations = new
        HashSet<string>(new[] {
            OperationName.Job.Execute,
}));

For full operation list please see: OperationName.

All operations are enabled by default.

Enrich

This option allows one to enrich the activity with additional information from the raw JobDetail object. The Enrich action is called only when activity.IsAllDataRequested is true. It contains the activity itself (which can be enriched), the name of the event, and the actual raw object.

For event names "OnStartActivity", "OnStopActivity", the actual object will be IJobDetail.

For event name "OnException", the actual object will be the exception thrown

The following code snippet shows how to add additional tags using Enrich.

// ...
using OpenTelemetry.Instrumentation.Quartz.Implementation;
using Quartz;
// ...
// Enable enriching an activity after it is created.
x.AddQuartzInstrumentation(opt =>
{
    opt.Enrich = (activity, eventName, quartzJobDetails) =>
    {
        // update activity
        if (quartzJobDetails is IJobDetail jobDetail)
        {
            activity.SetTag("customProperty", jobDetail.JobDataMap["customProperty"]);
            ...
        }
    };
})

References

No packages depend on OpenTelemetry.Instrumentation.Quartz.

.NET 8.0

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
1.20.0-beta.1 0 10/15/2026
1.19.0-beta.1 10 10/03/2026
1.18.0-beta.1 8 10/10/2026
1.17.0-beta.1 8 10/05/2026
1.16.0-beta.1 6 10/09/2026
1.15.1-beta.1 7 10/08/2026
1.15.0-beta.1 8 10/05/2026
1.14.0-beta.2 8 10/05/2026
1.14.0-beta.1 7 10/05/2026
1.13.0-beta.1 7 10/05/2026
1.12.0-beta.1 7 10/05/2026
1.11.0-beta.2 7 10/05/2026
1.11.0-beta.1 6 10/05/2026
1.10.0-beta.1 7 10/07/2026
1.0.0-beta.3 7 10/09/2026
1.0.0-beta.2 6 10/05/2026
1.0.0-beta.1 8 10/05/2026
1.0.0-alpha.3 8 10/05/2026
1.0.0-alpha.2 7 10/05/2026
1.0.0-alpha.1 7 10/05/2026