Skip to content

Conversation

@paul-kraftlauget
Copy link
Contributor

Fixes #16923

Also removes compile warning

@wing328
Copy link
Member

wing328 commented Mar 8, 2025

please follow step 3 in PR checklist to update the samples so that CI can test the change

cc @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10)

@paul-kraftlauget
Copy link
Contributor Author

To test this, the test would need to generate the client code for a REST service that has query parameters or path parameters, write some code to call that, set up wiremock to mock a REST call, fire the call off, check the Spring metrics that it is templated and does not contain the raw path or query params. This is the behaviour that needs tested. And when generated code is compiled, there shouldn't be any warnings.

I looked at the test cases for spring. I didn't see any that run the spring environment with the generated code. If there is a good way to test the behaviour by running generated code, could you please point me to an example?

@wing328
Copy link
Member

wing328 commented Apr 1, 2025

did you test the fix locally in your environment to confirm it works for your use cases?

@wing328 wing328 added this to the 7.13.0 milestone Apr 1, 2025
@paul-kraftlauget
Copy link
Contributor Author

Yes, I have been running the fix in production, by using the gradle plugin config:

templateResourcePath.set("$projectDir/src/main/resources/custom_template")

And this exact fix in the file:

./src/main/resources/custom_template/infrastructure/ApiClient.kt.mustache

The metrics are correct, using templated metrics:

 {
  "name" : "http.client.requests",
  "baseUnit" : "seconds",
  "measurements" : [ 
  ...
   {
    "tag" : "uri",
    "values" : [ "/user/{userId}", "/v4/content/{contentId}", "/oauth/token" ]
  }
  ...
   ]
}

@paul-kraftlauget
Copy link
Contributor Author

Without the fix, the metrics look like this:

{
  "name" : "http.client.requests",
  "baseUnit" : "seconds",
  "measurements" : [
  ... 
   {
    "tag" : "uri",
    "values" : [ "/oauth/token", "none" ]
  },
  ... 
   ]
}

The REST client calls with templates just appear as uri -> "none", so you don't even see the endpoints being called.

@wing328
Copy link
Member

wing328 commented Apr 25, 2025

can you please resolve the merge conflicts when you've time?

@paul-kraftlauget
Copy link
Contributor Author

I opened a new PR with the merge conflicts resolved. See #21148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][Kotlin][WebClient] Using String templates for path causes incorrect URI variables resolution

2 participants