FSchumacher commented on issue #6309:
URL: https://github.com/apache/jmeter/issues/6309#issuecomment-2222610018

   You should not construct dynamic JSR 223 snippets within your tests, as 
those will end up in the metaspace.
   
   What you did is, for every sample, you created a new text snippet. That 
snippet gets compiled into a groovy (class), which ends up in the metaspace.
   
   The templating syntax `${...}` should be avoided by all means in (groovy) 
JSR 223 scripts. Those parts get replaced while JMeter runs the test. As you 
are generating random text for each call of the sampler, you will get a unique 
script.
   Another reason to not use templating inside groovy scripts, is that there is 
often a faster alternative. For your example, I believe the following snippet 
would be equivalent:
   
   ```groovy
   import org.apache.commons.lang3.RandomStringUtils;
   
   String randomString = RandomStringUtils.randomAlphanumeric(16)
   String hexString = randomString.getBytes("UTF-8").encodeHex();
   
   vars.put("trace_id", hexString);
   ``` 
   
   Another possibility would be to work with arguments and place the random 
bits with the templating syntax into the parameters section of the JSR 223 
sampler (or pre-processor).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to