You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by "FSchumacher (via GitHub)" <gi...@apache.org> on 2023/04/29 12:24:12 UTC

[GitHub] [jmeter] FSchumacher opened a new pull request, #5869: Add more variables to template to compute sampler names

FSchumacher opened a new pull request, #5869:
URL: https://github.com/apache/jmeter/pull/5869

   ## Description
   
   Add more variables to the mini template language to name samplers when recording a test via HTTPS Script recorder
   
   The new variables are
    * method - HTTP method of the request
    * host   - host of the URL recorded (called domain in the sampler)
    * scheme - scheme of the URL recorded (called protocol in the sampler)
    * port   - port of the URL recorded
    * url    - URL as recorded
   
   ## Motivation and Context
   
   In Issue #5820 a user asked to provide more variables, specifically the `url`. 
   
   ## How Has This Been Tested?
   
   Added a unit test
   
   ## Types of changes
   <!--- What types of changes does your code introduce? Delete as appropriate -->
   - New feature (non-breaking change which adds functionality)
   
   ## Checklist:
   <!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
   <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
   - [x] My code follows the [code style][style-guide] of this project.
   - [x] I have updated the documentation accordingly.
   
   [style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines
   


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi merged pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi merged PR #5869:
URL: https://github.com/apache/jmeter/pull/5869


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] alexsch01 commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "alexsch01 (via GitHub)" <gi...@apache.org>.
alexsch01 commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1576947547

   guess i won't be a contributor officially....oh well


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] FSchumacher commented on a diff in pull request #5869: Add more variables to template to compute sampler names

Posted by "FSchumacher (via GitHub)" <gi...@apache.org>.
FSchumacher commented on code in PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#discussion_r1186168217


##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();
         }
+        sampler.setName(MessageFormat.format(format,valuesArray));
     }
 
     private String getFormat(int httpSampleNameMode, String format) {
         if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_FORMATTER) {
             return format.replaceAll("#\\{name([,}])", "{0$1")
                     .replaceAll("#\\{path([,}])", "{1$1")
-                    .replaceAll("#\\{counter([,}])", "{2$1");
+                    .replaceAll("#\\{method([,}])", "{2$1")
+                    .replaceAll("#\\{host([,}])", "{3$1")
+                    .replaceAll("#\\{scheme([,}])", "{4$1")
+                    .replaceAll("#\\{port([,}])", "{5$1")
+                    .replaceAll("#\\{url([,}])", "{6$1")
+                    .replaceAll("#\\{counter([,}])", "{7$1");

Review Comment:
   You mean, if the user sets the format string to `#{counter} => {0}` and expects JMeter to not touch the `{0}`?
   We had no reports into that direction, so I think the chances are low, it is a problem for many people. 



-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] alexsch01 commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "alexsch01 (via GitHub)" <gi...@apache.org>.
alexsch01 commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1536261801

   Can we have this reviewed?


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1577120220

   What do you mean by `contributor label`?


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on a diff in pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on code in PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#discussion_r1186161123


##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();
         }
+        sampler.setName(MessageFormat.format(format,valuesArray));
     }
 
     private String getFormat(int httpSampleNameMode, String format) {
         if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_FORMATTER) {
             return format.replaceAll("#\\{name([,}])", "{0$1")
                     .replaceAll("#\\{path([,}])", "{1$1")
-                    .replaceAll("#\\{counter([,}])", "{2$1");
+                    .replaceAll("#\\{method([,}])", "{2$1")
+                    .replaceAll("#\\{host([,}])", "{3$1")
+                    .replaceAll("#\\{scheme([,}])", "{4$1")
+                    .replaceAll("#\\{port([,}])", "{5$1")
+                    .replaceAll("#\\{url([,}])", "{6$1")
+                    .replaceAll("#\\{counter([,}])", "{7$1");

Review Comment:
   How about making a first round of replaces that replaces all `{[0-9]+}` with their escaped representations?
   In other words, let's keep `{0}` literal since that might be something the user wants to have in the sample name.
   
   A yet another option is to escape all `{` characters to avoid `MessageFormat` failures.



-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] FSchumacher commented on a diff in pull request #5869: Add more variables to template to compute sampler names

Posted by "FSchumacher (via GitHub)" <gi...@apache.org>.
FSchumacher commented on code in PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#discussion_r1186158435


##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();
         }
+        sampler.setName(MessageFormat.format(format,valuesArray));
     }
 
     private String getFormat(int httpSampleNameMode, String format) {
         if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_FORMATTER) {
             return format.replaceAll("#\\{name([,}])", "{0$1")
                     .replaceAll("#\\{path([,}])", "{1$1")
-                    .replaceAll("#\\{counter([,}])", "{2$1");
+                    .replaceAll("#\\{method([,}])", "{2$1")
+                    .replaceAll("#\\{host([,}])", "{3$1")
+                    .replaceAll("#\\{scheme([,}])", "{4$1")
+                    .replaceAll("#\\{port([,}])", "{5$1")
+                    .replaceAll("#\\{url([,}])", "{6$1")
+                    .replaceAll("#\\{counter([,}])", "{7$1");

Review Comment:
   Yes, that would be a nicer option, but I didn't find a way to enable that easily, so I opted to implicitly say: it was never documented and merely an implementation detail.



-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1537114844

   TL;DR: adding new language constructs to existing languages is not easy. We should refrain from extending existing languages.
   
   ```java
   MessageFormat.format("Hello {")
   ```
   
   yields
   
   ```
   java.lang.IllegalArgumentException: Unmatched braces in the pattern.
   	at java.base/java.text.MessageFormat.applyPattern(MessageFormat.java:521)
   	at java.base/java.text.MessageFormat.<init>(MessageFormat.java:371)
   	at java.base/java.text.MessageFormat.format(MessageFormat.java:860)
   ```
   
   `MessageFormat.format("Doesn't contain quote")` yields `Doesnt contain quote`.
   
   So we should either declare that the format uses `MessageFormat` patterns (with all the `'` for escapes), or we should declare we use a completely different language with its own escapes.
   
   If we go with `MessageFormat`, then we should assume people could use `'` for literal parts like `Doesn''t contain quote` for expressing `Doesn't`.
   
   That means we must not blindly replace `#{...}` as it might be inside quotes.
   If we continue with `MessageFormat`, we should probably use proper quote handling when replacing `#{url}`-like named placeholders.
   
   
   


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] alexsch01 commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "alexsch01 (via GitHub)" <gi...@apache.org>.
alexsch01 commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1540020208

   @FSchumacher @vlsi I think we should somehow disallow use of #{any digit} since it was never documented
   
   Do we know of any users who actually use that syntax?


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1577129676

   I added your name via `Co-authored-by` in the commit message (see https://github.com/apache/jmeter/commit/ae8c1ec2ba18c74f7900a474989877d26d369915, https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors), and the link to your profile exists in `changes.xml`.
   
   WDYT?


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1540037128

   The documentation did mention MessageFormat which implies `{0}` was somewhat documented.
   
   I would like to move forward here, however, it is sad that we expose unintended placeholders


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] alexsch01 commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "alexsch01 (via GitHub)" <gi...@apache.org>.
alexsch01 commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1530070360

   I made a pull request @FSchumacher 
   https://github.com/FSchumacher/jmeter/pull/1


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on a diff in pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on code in PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#discussion_r1186134805


##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();
         }
+        sampler.setName(MessageFormat.format(format,valuesArray));
     }
 
     private String getFormat(int httpSampleNameMode, String format) {
         if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_FORMATTER) {
             return format.replaceAll("#\\{name([,}])", "{0$1")
                     .replaceAll("#\\{path([,}])", "{1$1")
-                    .replaceAll("#\\{counter([,}])", "{2$1");
+                    .replaceAll("#\\{method([,}])", "{2$1")
+                    .replaceAll("#\\{host([,}])", "{3$1")
+                    .replaceAll("#\\{scheme([,}])", "{4$1")
+                    .replaceAll("#\\{port([,}])", "{5$1")
+                    .replaceAll("#\\{url([,}])", "{6$1")
+                    .replaceAll("#\\{counter([,}])", "{7$1");

Review Comment:
   In theory, users might have used `{2}` in their scripts for "counter", and if we move counter to `{7}` that would break their scripts.
   
   I wonder if we can keep `#{counter}` at position `{2}` even thought that was not properly documented.



##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();
         }
+        sampler.setName(MessageFormat.format(format,valuesArray));
     }
 
     private String getFormat(int httpSampleNameMode, String format) {
         if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_FORMATTER) {
             return format.replaceAll("#\\{name([,}])", "{0$1")
                     .replaceAll("#\\{path([,}])", "{1$1")
-                    .replaceAll("#\\{counter([,}])", "{2$1");
+                    .replaceAll("#\\{method([,}])", "{2$1")
+                    .replaceAll("#\\{host([,}])", "{3$1")
+                    .replaceAll("#\\{scheme([,}])", "{4$1")
+                    .replaceAll("#\\{port([,}])", "{5$1")
+                    .replaceAll("#\\{url([,}])", "{6$1")
+                    .replaceAll("#\\{counter([,}])", "{7$1");

Review Comment:
   In theory, users might have used `{2}` in their scripts for "counter", and if we move counter to `{7}` that would break their scripts.
   
   I wonder if we can keep `#{counter}` at position `{2}` even though that was not properly documented.



-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] FSchumacher commented on a diff in pull request #5869: Add more variables to template to compute sampler names

Posted by "FSchumacher (via GitHub)" <gi...@apache.org>.
FSchumacher commented on code in PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#discussion_r1186155033


##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();

Review Comment:
   To answer your first request (not really), I have no idea, I guess, it was to filter out proxy requests.
   About your second concern. I wanted to get around using a full blown ArrayList, but it is probably better to go for readability and use it anyway.



-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on a diff in pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on code in PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#discussion_r1186173927


##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();
         }
+        sampler.setName(MessageFormat.format(format,valuesArray));
     }
 
     private String getFormat(int httpSampleNameMode, String format) {
         if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_FORMATTER) {
             return format.replaceAll("#\\{name([,}])", "{0$1")
                     .replaceAll("#\\{path([,}])", "{1$1")
-                    .replaceAll("#\\{counter([,}])", "{2$1");
+                    .replaceAll("#\\{method([,}])", "{2$1")
+                    .replaceAll("#\\{host([,}])", "{3$1")
+                    .replaceAll("#\\{scheme([,}])", "{4$1")
+                    .replaceAll("#\\{port([,}])", "{5$1")
+                    .replaceAll("#\\{url([,}])", "{6$1")
+                    .replaceAll("#\\{counter([,}])", "{7$1");

Review Comment:
   > expects JMeter to not touch the {0}?
   
   That is right. I expect if we expose only `#{...}`, then we should avoid touching things like `{0}`.



-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] alexsch01 commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "alexsch01 (via GitHub)" <gi...@apache.org>.
alexsch01 commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1577099145

   @vlsi Thanks for merging the commit
   
   Can I have the contributor label? It may not be possible now


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] alexsch01 commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "alexsch01 (via GitHub)" <gi...@apache.org>.
alexsch01 commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1577149477

   Ok


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on a diff in pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on code in PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#discussion_r1186133062


##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java:
##########
@@ -359,18 +361,42 @@ protected void computeSamplerName(HTTPSamplerBase sampler,
         String prefix = StringUtils.defaultString(request.getPrefix(), "");
         int httpSampleNameMode = request.getHttpSampleNameMode();
         String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
+        String url = null;
+        try {
+            url = sampler.getUrl().toString();
+        } catch (MalformedURLException e) {
+            url = "MALFORMED-URL";
+            log.warn("Could not get URL to name sample", e);
+        }
+        List<Object> values = Arrays.asList(
+                prefix,
+                sampler.getPath(),
+                sampler.getMethod(),
+                sampler.getDomain(),
+                sampler.getProtocol(),
+                sampler.getPort(),
+                url
+        );
+        Object[] valuesArray;
         if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
+            valuesArray = values.toArray(new Object[values.size() + 1]);
+            valuesArray[values.size()] = incrementRequestNumberAndGet();
         } else {
-            sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+            valuesArray = values.toArray();

Review Comment:
   I just wonder: is there a real reason to allow "request number" only in case the method is not CONNECT?
   What if we always supply the "request number", and we increase "request number" only in case the method matches?
   
   The dance with `toArray[size+1]` looks strange.
   



-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] vlsi commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1554608766

   @FSchumacher , are you goring to merge this? Do you think it is mergeable?


-- 
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-unsubscribe@jmeter.apache.org

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


[GitHub] [jmeter] alexsch01 commented on pull request #5869: Add more variables to template to compute sampler names

Posted by "alexsch01 (via GitHub)" <gi...@apache.org>.
alexsch01 commented on PR #5869:
URL: https://github.com/apache/jmeter/pull/5869#issuecomment-1529958697

   I tested the latest version of this branch and it works very well for #{url} - showing full URL in JMeter sidebar
   
   Appreciate you very much. Thanks :)


-- 
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-unsubscribe@jmeter.apache.org

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