I'm not sure how I see the ExecuteContext + ExecuteListener helping as the issue is not global instrumenting but rather tagging specific SQL calls.
The only way I see this working ostensibly (given that DSL has no way to pass down adhoc data) regardless of whether or not I use an ExecuteListener is to use nasty threadlocals.
That is store the metric name I want with a static utility method that sets the metric in a threadlocal before I call jOOQ and then have my spy/ExecuteListener use the threadlocal and clean it up.
While I can do this I still find it unusual that a tool that can generate SQL programmatically not allow me to generate SQL comments.
Perhaps a comment method should be added to the DSL as a feature? For all SQL you could provide
public CHAIN __(String comment) that does "-- comments" and then a dialect specific one for providing "/* */" as I believe the C style is not in the SQL standard.
However given the nature of the DSL fluent return value chaining this is probably a rather massive change as it would be needed on every SQL step.
That being said adding SQL comments has been even useful for non metric reasons as the comment provides reference when looking into database logs.
For now I will threadlocal and ask for forgiveness later :)