Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

feat: include User agent#747

Merged
thiagotnunes merged 4 commits intogoogleapis:masterfrom
mohanli-ml:user-agent
Dec 15, 2020
Merged

feat: include User agent#747
thiagotnunes merged 4 commits intogoogleapis:masterfrom
mohanli-ml:user-agent

Conversation

@mohanli-ml
Copy link
Copy Markdown
Contributor

Configure the UserAgent in addition to x-goog-api-client. This will be needed for DirectPath.

@mohanli-ml mohanli-ml requested a review from a team December 15, 2020 03:14
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the googleapis/java-spanner API. label Dec 15, 2020
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Dec 15, 2020
Comment on lines 384 to 388
options.getSpannerStubSettings().toBuilder()
.setTransportChannelProvider(channelProvider)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
options.getSpannerStubSettings().toBuilder()
.setTransportChannelProvider(channelProvider)
options
.getSpannerStubSettings()
.toBuilder()
options
.getSpannerStubSettings()
.executeSqlSettings()
.getRetrySettings()
.toBuilder()

Comment on lines 423 to 433
options.getInstanceAdminStubSettings().toBuilder()
.setTransportChannelProvider(channelProvider)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
options.getInstanceAdminStubSettings().toBuilder()
.setTransportChannelProvider(channelProvider)
options
.getInstanceAdminStubSettings()
.toBuilder()
options
.getDatabaseAdminStubSettings()
.toBuilder()

options
.getInstanceAdminStubSettings()
.toBuilder()
options.getInstanceAdminStubSettings().toBuilder()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
options.getInstanceAdminStubSettings().toBuilder()
options
.getInstanceAdminStubSettings()
.toBuilder()

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 15, 2020

Codecov Report

Merging #747 (a075cff) into master (0fd859d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #747   +/-   ##
=========================================
  Coverage     85.05%   85.06%           
  Complexity     2556     2556           
=========================================
  Files           142      142           
  Lines         13930    13938    +8     
  Branches       1326     1326           
=========================================
+ Hits          11848    11856    +8     
  Misses         1526     1526           
  Partials        556      556           
Impacted Files Coverage Δ Complexity Δ
...m/google/cloud/spanner/spi/v1/GapicSpannerRpc.java 83.39% <100.00%> (+0.17%) 81.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0fd859d...a075cff. Read the comment docs.

.setHeaderProvider(mergedHeaderProvider)

// Inject client library version to `user-agent`
.setHeaderProvider(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are overriding the header provider here, instead of adding to it. We have to manually construct a new provider that will encapsulate the existing one the the new one:

private static final String USER_AGENT_KEY = "user-agent";
private static final String CLIENT_LIBRARY_LANGUAGE = "spanner-java";

Map<String, String> headersWithUserAgent = ImmutableMap.<String, String>builder()
    .put(USER_AGENT_KEY, CLIENT_LIBRARY_LANGUAGE + "/" + GaxProperties.getLibraryVersion(GapicSpannerRpc.class)))
    .putAll(mergedHeaderProvider.getHeaders())
    .build();
final HeaderProvider headerProviderWithUserAgent = FixedHeaderProvider.create(headersWithUserAgent);

...
.setHeaderProvider(headerProviderWithUserAgent);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

@thiagotnunes thiagotnunes merged commit fc63bc3 into googleapis:master Dec 15, 2020
thiagotnunes pushed a commit that referenced this pull request May 6, 2021
* chore: add DirectPath fallback integration test

* feat: include User agent
rajatbhatta pushed a commit to rajatbhatta/java-spanner that referenced this pull request Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spanner Issues related to the googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants