Skip to content

Conversation

@bhawnapannu2701
Copy link

Problem
jOOQ 3.20 introduced a new DefaultDSLContext#fetchValue(SelectField) overload
that internally delegates to select(field).fetchValue(). With builder-level
instrumentation in MetricsDSLContext, that delegation leads to double
instrumentation (two jooq.query timers) and tag loss.

Solution
Override MetricsDSLContext.fetchValue(SelectField):

  • For TableField: build the select via this context (select(field).from(table).fetchOne().value1()) so instrumentation triggers once.
  • For non-table fields: delegate to super.fetchValue(field) to avoid an extra select(...) hop.

Verification
New JUnit 5 test MetricsDSLContextFetchValueTest executes
jooq.tag("name","fetchValue").fetchValue(DSL.inline(42)) against H2.
Before this change two samples were recorded; now exactly one sample is recorded.

Fixes #6659.

@bhawnapannu2701 bhawnapannu2701 force-pushed the fix-fetchvalue-double-instrumentation branch from 4056488 to a89e9f3 Compare September 19, 2025 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[jOOQ] MetricsDSLContext calls time() twice on fetchValue(SelectField) path, causing tag loss

1 participant