micrometer
micrometer copied to clipboard
[jOOQ] Fix double instrumentation in MetricsDSLContext.fetchValue(SelectField) (#6659)
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.