Commit c5a2045
perf: cache the key used for OTEL traces and metrics (#3814)
* perf: cache the key used for OTEL traces and metrics
The HeaderInterceptor creates a key consisting of the database name and method name
that is used for OpenTelemetry attributes and metrics. The number of unique keys is
low. However, the key is constructed from the DatabaseName and method name every time,
which leads to a lot of string creation:
1. The DatabaseName.toString() method is called every time. This constructs a new string.
2. The result of DatabaseName.toString() is concatenated with the methodName to create yet
another string.
Instead of creating the key every time, we can cache the key values without doing the string
creation and concatenation every time.
* chore: generate libraries at Thu Apr 10 11:15:55 UTC 2025
---------
Co-authored-by: cloud-java-bot <[email protected]>1 parent a2780ed commit c5a2045
File tree
2 files changed
+11
-2
lines changed- google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1
2 files changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | | - | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| |||
201 | 203 | | |
202 | 204 | | |
203 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
204 | 213 | | |
205 | 214 | | |
206 | 215 | | |
| |||
0 commit comments