Commit db8d528
feat: add data model for client side metrics (#1187)
This PR revives googleapis/python-bigtable#923,
which was de-priotirized to work on the sync client. This PR brings it
back, working with both async and sync. It also adds a grpc interceptor,
as an improved way to capture metadata across both clients
---
## Design
The main architecture looks like this:
<img width="651" height="631"
alt="300137129-bebbb05a-20f0-45c2-9d38-e95a314edf64 drawio (1)"
src="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3Ca+href%3D"https://github.com/user-attachments/assets/c8318ac8-5f18-4027-9f64-4a40a8ab1d79">https://github.com/user-attachments/assets/c8318ac8-5f18-4027-9f64-4a40a8ab1d79"
/>
Most of the work is done by the ActiveOperationMetric class, which is
instantiated with each rpc call, and updated through the lifecycle of
the call. When the rpc is complete, it will call `on_operation_complete`
and `on_attempt_complete` on the MetricsHandler, which can then log the
completed data into OpenTelemetry (or theoretically, other locations if
needed)
Note that there are separate classes for active vs completed metrics
(`ActiveOperationMetric`, `ActiveAttemptMetric`,
`CompletedOperationMetric`, `CompletedAttemptMetric`). This is so that
we can keep fields mutable and optional while the request is ongoing,
but pass down static immutable copies once the attempt is completed and
no new data is coming
---------
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Mattie Fu <[email protected]>1 parent a1e74dd commit db8d528
File tree
20 files changed
+2555
-40
lines changed- packages/google-cloud-bigtable
- google/cloud/bigtable/data
- _async
- _metrics
- handlers
- _sync_autogen
- tests/unit/data
- _async
- _metrics
- _sync_autogen
20 files changed
+2555
-40
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
1039 | 1040 | | |
1040 | 1041 | | |
1041 | 1042 | | |
| 1043 | + | |
| 1044 | + | |
1042 | 1045 | | |
1043 | 1046 | | |
1044 | 1047 | | |
| |||
1753 | 1756 | | |
1754 | 1757 | | |
1755 | 1758 | | |
| 1759 | + | |
1756 | 1760 | | |
1757 | 1761 | | |
1758 | 1762 | | |
| |||
Lines changed: 99 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
16 | 25 | | |
17 | 26 | | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| 30 | + | |
21 | 31 | | |
22 | 32 | | |
23 | 33 | | |
| |||
26 | 36 | | |
27 | 37 | | |
28 | 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 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
29 | 90 | | |
30 | 91 | | |
31 | 92 | | |
| |||
35 | 96 | | |
36 | 97 | | |
37 | 98 | | |
38 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
39 | 103 | | |
40 | 104 | | |
41 | 105 | | |
42 | 106 | | |
43 | 107 | | |
44 | 108 | | |
| 109 | + | |
45 | 110 | | |
46 | 111 | | |
| 112 | + | |
47 | 113 | | |
48 | 114 | | |
| 115 | + | |
49 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
50 | 120 | | |
51 | 121 | | |
52 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
53 | 126 | | |
54 | 127 | | |
55 | 128 | | |
| |||
58 | 131 | | |
59 | 132 | | |
60 | 133 | | |
61 | | - | |
| 134 | + | |
62 | 135 | | |
63 | 136 | | |
64 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
65 | 141 | | |
66 | 142 | | |
67 | 143 | | |
68 | 144 | | |
69 | | - | |
| 145 | + | |
70 | 146 | | |
71 | 147 | | |
72 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
73 | 155 | | |
74 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
75 | 163 | | |
76 | 164 | | |
77 | 165 | | |
78 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
Lines changed: 35 additions & 0 deletions
| 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 | + | |
0 commit comments