title: JOOQ listeners: context data is not cleaned between two queries
body: <p>In my current project, I use java 11/JOOQ 3.15/Micronaut/Micrometer. In order to have relevant SQL metrics, I would like to put a name on my JOOQ queries.</p>
  <p>To do that, I have tried to use the <code>ctx.data()</code> field combined with a custom ExecuteListener.</p>
  <p>Let's take a really simplified listener:</p>
  <pre class="lang-java prettyprint-override"><code>@Singleton
  public class JooqListener extends DefaultExecuteListener {
  
      transient StopWatch watch;
      private final MeterRegistry meterRegistry;
  
      public JooqListener(MeterRegistry meterRegistry) {
          this.meterRegistry = meterRegistry;
      }
      
      @Override
      public void executeStart(ExecuteContext ctx) {
          watch = new StopWatch();
      }
  
      @Override
      public void fetchEnd(ExecuteContext ctx) {
          Tags prometheusTag = Tags.of(&quot;queryName&quot;, ctx.configuration().data(&quot;queryName&quot;).toString());
          meterRegistry.timer(&quot;sql.query.timer&quot;, prometheusTag)
              .record(watch.split(), TimeUnit.NANOSECONDS);
      }
      // I have tried to remove the data manually, but not working
      @Override
      public void end(ExecuteContext ctx) {
          ctx.configuration().data().remove(&quot;queryName&quot;);
      }
  }
  </code></pre>
  <p>If I send 2 different queries from two different repositories, like for example:</p>
  <pre class="lang-java prettyprint-override"><code>DSLContext context = DSL.using(jooqConfiguration);
  context.data(&quot;queryName&quot;, &quot;query1&quot;);
  return context.select(1).from(&quot;dual&quot;).fetch();
  </code></pre>
  <p>And just after, let say I'm not attentive and I forgot to name my query:</p>
  <pre class="lang-java prettyprint-override"><code>DSLContext context = DSL.using(jooqConfiguration);
  return context.select(2).from(&quot;dual&quot;).fetch();
  </code></pre>
  <p><code>ctx.configuration().data(&quot;queryName&quot;)</code> in my listener will always contain &quot;query1&quot;, which I didn't expect because ExecuteListeners are listening query by query, and furthermore, I have created two different DSLContexts. It looks like the <code>ctx.data()</code> cannot be cleaned but just overwritten.</p>
  <p>Is it an expected behaviour? Is there an other object/method I should use which can be limited to the query scope? (I searched a lot on google but &quot;data&quot; keyword is a little bit annoying...)</p>
  <p>Thank you</p>