Added SchedulerListener Instrumentation for Scheduler-level errors in Quartz#19117
Added SchedulerListener Instrumentation for Scheduler-level errors in Quartz#19117angad-2 wants to merge 20 commits into
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR extends the Quartz 2.0 instrumentation to emit spans for genuine scheduler-level errors reported through SchedulerListener.schedulerError, complementing the existing job-execution instrumentation. It registers a new TracingSchedulerListener from QuartzTelemetry.configure(Scheduler) (used by both the library and javaagent paths), backed by a dedicated Instrumenter<SchedulerError, Void>. To avoid double-recording, the listener skips emitting a span whenever a span is already active on the current thread (the case when Quartz surfaces a job failure through schedulerError).
Changes:
- Adds
TracingSchedulerListener,SchedulerError, andSchedulerErrorAttributesExtractor(recordsquartz.scheduler.name), wired via a new scheduler-errorInstrumenterinQuartzTelemetryBuilder. - Registers the scheduler listener alongside the job listener in
QuartzTelemetry.configure, mirroring the existing dedup/exception-handling pattern. - Adds a
schedulerErrortest in the sharedAbstractQuartzTestcovering both library and javaagent modules.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.../TracingSchedulerListener.java |
New listener that emits a span for genuine scheduler errors, skipping when a span is already active. |
.../SchedulerError.java |
New request object holding scheduler name and error message. |
.../SchedulerErrorAttributesExtractor.java |
Adds the quartz.scheduler.name attribute on span start. |
.../QuartzTelemetryBuilder.java |
Builds a dedicated scheduler-error instrumenter and passes it to QuartzTelemetry. |
.../QuartzTelemetry.java |
Registers the scheduler listener and stores the new instrumenter. |
.../AbstractQuartzTest.java |
Adds a schedulerError test asserting the produced span. |
Pull request dashboard statusStatus last refreshed: 2026-07-21 23:34:07 UTC.
This automated status or its linked feedback items may be incorrect. If something looks wrong, report it with the result you expected. |
…ge() (null-guarded).
…ail job nested classes are now the last members of the file again
laurit
left a comment
There was a problem hiding this comment.
@jaydeluca with this PR quartz instrumentation will emit an event in case you wish to add this to the collected metadata
…n to log record and renamed event to quartz.scheduler.exception
…duler log suppression
…eprecated config support
…deprecation timeline
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
instrumentation/quartz-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/quartz/v2_0/QuartzSingletons.java:35
- [Testing] This one-release compatibility branch is not exercised: both
testExperimentaltasks now set only the replacement property, so a typo or translation regression in the deprecated key could ship while all Quartz tests pass. Add a javaagent test task usingotel.instrumentation.quartz.experimental-span-attributes=true(and, if practical, verify the warning) to preserve the promised fallback until 3.0.
// Support the deprecated config key until 3.0.
Boolean deprecatedExperimentalSpanAttributes =
config.getBoolean("experimental_span_attributes/development");
…uartz config migration
…eprecated config warning
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
instrumentation/quartz-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/quartz/v2_0/QuartzSingletons.java:31
- [Testing] The compatibility branch for the deprecated property is not exercised: both experimental test tasks were switched to the replacement property, so a typo or precedence regression here could silently break the promised one-release fallback. Add a dedicated test/task that configures
otel.instrumentation.quartz.experimental-span-attributesand verifies experimental telemetry remains enabled; ideally also cover new-key precedence and the warning.
// Support the deprecated config key until 3.0.
Boolean deprecatedExperimentalSpanAttributes =
config.getBoolean("experimental_span_attributes/development");
| if (parentContext.get(TracingJobListener.JOB_CONTEXT_KEY) != null) { | ||
| return; |
There was a problem hiding this comment.
suppress only the job-execution duplicate scheduler error
…nly the job-execution duplicate scheduler error
Description
Adds scheduler-level instrumentation to the Quartz integration via
org.quartz.SchedulerListener, addressing part of #14628.A new
TracingSchedulerListener(registered byQuartzTelemetry.configure) handlesSchedulerListener.schedulerError. Since a scheduler error is a point-in-time occurrence with no duration, it is emitted as a log-based event (not a span):quartz.scheduler.exception, severityERRORSchedulerExceptionrecorded viasetException(...)quartz.scheduler.nameattribute (experimental — see below)The scheduler name is also added to the existing job execution spans.
Design notes / scope
schedulerError, on the same thread while a job is running. That failure is already recorded on the job span, so emitting an event there would duplicate it.TracingJobListenersets a context marker while a job executes, andTracingSchedulerListenersuppresses only when that marker is present — so genuine scheduler-level errors that occur under an unrelated span are still emitted.quartz.scheduler.name(a non-semconv attribute, on both the event and job spans) is only emitted when the existingcaptureExperimentalSpanAttributesoption is enabled, consistent with howjob.systemis gated.SchedulerListenercould group the DB spans Quartz emits internally. That isn't achievable here — these listener hooks are point-in-time events with no start/end bracket around the internal DB work, so there is no span to parent those queries to.What's NOT included
JobListener/job-execution span attributes beyond the scheduler name — tracked separately in Include messaging attributes in Quartz spans #14624.Testing
schedulerErrortest plus scheduler-name assertions on job spans inAbstractQuartzTest, exercised by both the library and javaagent modules, in the default and experimental-attribute runs.