Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report sdk version in user-agent #810

Merged
merged 11 commits into from
Nov 21, 2022
Merged

Conversation

addjuarez
Copy link
Contributor

@addjuarez addjuarez commented Nov 16, 2022

Signed-off-by: addjuarez addiajuarez@gmail.com

Description

Report the sdk version inside user-agent header.

HTTP: useragent="dapr-sdk-java/v1.7.1"
gRPC: useragent="dapr-sdk-java/v1.8.0-SNAPSHOT grpc-java-netty/1.42.1"

Please explain the changes you've made

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@addjuarez addjuarez requested review from a team as code owners November 16, 2022 19:46
public final class ActorUtils {

private static String version = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to sdkVersion

InputStream in = new ByteArrayInputStream(new byte[0]);
try {
Properties properties = new Properties();
in = ActorUtils.class.getResourceAsStream("/app.properties");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it a try with resources block so that input stream is properly closed even on exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, wasn't aware of this feature.

InputStream in = new ByteArrayInputStream(new byte[0]);
try {
Properties properties = new Properties();
in = Version.class.getResourceAsStream("/app.properties");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor

@mukundansundar mukundansundar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change app.properties to sdk_version.properties?

@mukundansundar
Copy link
Contributor

@addjuarez can you check why the build seems to be failing?

public final class ActorUtils {

private static String sdkVersion = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actor sdk import sdk module.
So can't we just use Version.getSdkVersion() command from there?

*
* @return String version of sdk.
*/
public static String getVersion() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static String getVersion() {
public static String getSdkVersion() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addjuarez just one small change. Thanks

@@ -0,0 +1 @@
version=${project.version}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version=${project.version}
sdk_version=${project.version}

try (InputStream input = Version.class.getResourceAsStream("/sdk_version.properties");) {
Properties properties = new Properties();
properties.load(input);
sdkVersion = "dapr-sdk-java/v" + properties.getProperty("version");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will exception be thrown if some other property is there and not version? Won't it return a null instead?

@mukundansundar
Copy link
Contributor

@addjuarez build passes. Please fix dco

Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
@codecov
Copy link

codecov bot commented Nov 18, 2022

Codecov Report

Merging #810 (479c86f) into master (622844b) will increase coverage by 0.06%.
The diff coverage is 68.18%.

@@             Coverage Diff              @@
##             master     #810      +/-   ##
============================================
+ Coverage     77.56%   77.62%   +0.06%     
- Complexity     1157     1161       +4     
============================================
  Files           104      105       +1     
  Lines          3628     3647      +19     
  Branches        419      419              
============================================
+ Hits           2814     2831      +17     
- Misses          600      603       +3     
+ Partials        214      213       -1     
Impacted Files Coverage Δ
...ctors/src/main/java/io/dapr/actors/ActorUtils.java 73.33% <ø> (ø)
...main/java/io/dapr/actors/runtime/ActorRuntime.java 54.54% <0.00%> (-2.22%) ⬇️
sdk/src/main/java/io/dapr/client/Headers.java 0.00% <ø> (ø)
sdk/src/main/java/io/dapr/utils/Version.java 75.00% <75.00%> (ø)
...c/main/java/io/dapr/actors/client/ActorClient.java 64.00% <100.00%> (+4.90%) ⬆️
...rc/main/java/io/dapr/client/DaprClientBuilder.java 66.66% <100.00%> (ø)
sdk/src/main/java/io/dapr/client/DaprHttp.java 92.30% <100.00%> (+0.06%) ⬆️
sdk/src/main/java/io/dapr/utils/Retry.java 75.00% <0.00%> (+25.00%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@mukundansundar mukundansundar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mukundansundar mukundansundar added this to the v1.8 milestone Nov 18, 2022
Copy link
Member

@artursouza artursouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, follow up with an integration test that validates the user agent.

@artursouza artursouza merged commit bc9de9f into dapr:master Nov 21, 2022
@addjuarez addjuarez deleted the user-agent branch November 13, 2023 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants