micrometer icon indicating copy to clipboard operation
micrometer copied to clipboard

[jOOQ] Fix double instrumentation in MetricsDSLContext.fetchValue(SelectField) (#6659)

Open bhawnapannu2701 opened this issue 3 months ago • 0 comments

Problem jOOQ 3.20 introduced a new DefaultDSLContext#fetchValue(SelectField<T>) 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<T>):

  • 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 avatar Sep 19 '25 01:09 bhawnapannu2701