This repository was archived by the owner on Mar 26, 2026. It is now read-only.
Commit 3e532ab
authored
fix: Client side metrics should record the version number of @google-cloud/bigtable not the customer package version (#1752)
## Description
A bug was discovered where the client side metrics being recorded on the backend service had the wrong version number. The version number being recorded actually matched the version number on the customer's package.json file instead of the version number of the Node Bigtable package being used.
To correct this, the line of code at https://togithub.com/googleapis/nodejs-bigtable/blob/2a960922747ed0f8d0e798113fd4434852382217/src/client-side-metrics/operation-metrics-collector.ts#L52 which is currently reading the package.json file relative to the working directory of the node process should instead read the package.json file location relative to the location of operation-metrics-collector.ts so that the version number of the Node Bigtable dependency is always recorded instead of the version number from the customer's package.json file.
## Impact
Corrects the bug and ensures that the right version number is always recorded for client side metrics.
## Files affected
**samples/readSnippets:** A code snippet that will run in the samples test and fail if the metrics handler receives the wrong version of the client library
**samples/test/reads.js:** The new samples test that runs the code snippet in readSnippets and fails if the metrics handler receives the wrong version of the client library
**src/client-side-metrics/operation-metrics-collector.ts:** The source code changes that ensure the version number recorded will always match the Bigtable client library version number
**test-common/test-metrics-handler.ts:** A new class, similar to the existing class for testing data sent to the metrics handler that also preserves the version name when it reaches the metrics handler
## Testing
A new system test or unit test will not catch this bug since their working directories all reference the package.json file in the nodejs-bigtable project. So instead, I created a fake customer project with the script from https://gist.github.com/danieljbruce/bba73fa5d9919866d82b8968ceb45cc3 which gets the wrong version number at https://togithub.com/googleapis/nodejs-bigtable/blob/2a960922747ed0f8d0e798113fd4434852382217/src/client-side-metrics/operation-metrics-collector.ts#L52, but gets the right version number when this line of code is corrected with the changes in this PR.
I also found a way to create a samples test which will fail without the source code changes from this PR. It should ensure going forward that the right version gets recorded for client side metrics.1 parent be5b598 commit 3e532ab
4 files changed
Lines changed: 116 additions & 2 deletions
File tree
- src/client-side-metrics
- test/metrics-collector/version
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
| 53 | + | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments