Commit a184f0d
authored
fix(sidekick/rust): Ensure detailed-tracing-attributes flag is fully propagated (#2438)
This commit fixes the propagation of the `detailed-tracing-attributes`
flag to all necessary annotation structs and updates the templates to
correctly utilize the flag. See #2435 and #2252
For googleapis/google-cloud-rust#3239
Specifically:
- Adds `DetailedTracingAttributes` field to `modelAnnotations` and
`serviceAnnotations` in `annotate.go` to make the flag accessible in
`lib.rs.mustache` and service-level sections of `transport.rs.mustache`.
- Updates `annotateModel` and `annotateService` to populate the new
fields.
- Adds comprehensive unit tests in `annotate_test.go` to verify the
`DetailedTracingAttributes` flag is correctly set across
`modelAnnotations`, `serviceAnnotations`, `methodAnnotation`, and
`pathBindingAnnotation` based on the codec options.
- Modifies `lib.rs.mustache` to initialize the static
`INSTRUMENTATION_CLIENT_INFO` using `std::sync::LazyLock` to accommodate
the non-const `default()` function.
- Updates `transport.rs.mustache` to correctly dereference the
`LazyLock` when calling `with_instrumentation` (i.e.,
`&*crate::info::INSTRUMENTATION_CLIENT_INFO`).
These changes ensure that the conditional code blocks in both
`lib.rs.mustache` and `transport.rs.mustache` related to detailed
tracing are generated correctly based on the
`detailed-tracing-attributes` flag.
Tested:
- Ran `go test -race ./...` in the librarian repository to ensure all
unit tests pass, including new tests for flag propagation in
annotations.
- Manually regenerated the `google-cloud-showcase-v1beta1` client in a
local `google-cloud-rust` clone using the modified librarian:
1. With `--codec-option=detailed-tracing-attributes=true`: - Verified
`src/generated/showcase/src/lib.rs` contains the
`INSTRUMENTATION_CLIENT_INFO` static (using `LazyLock`). - Verified
`src/generated/showcase/src/transport.rs` includes
`.with_instrumentation(&*crate::info::INSTRUMENTATION_CLIENT_INFO)`
calls within the `if tracing_is_enabled` blocks in the `new` methods. -
Confirmed the crate builds and tests pass: `cargo build -p
google-cloud-showcase-v1beta1` `cargo test -p
google-cloud-showcase-v1beta1`
2. With the flag off (default):
- Verified the above tracing-specific code is absent.
3. By setting `detailed-tracing-attributes = "true"` in
`src/generated/showcase/.sidekick.toml` and running refresh without the
codec option, confirming the config file is also respected.1 parent c1a4ced commit a184f0d
File tree
2 files changed
+154
-11
lines changed- internal/sidekick/internal/rust
2 files changed
+154
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
554 | 560 | | |
555 | 561 | | |
556 | 562 | | |
557 | | - | |
| 563 | + | |
| 564 | + | |
558 | 565 | | |
559 | 566 | | |
560 | 567 | | |
| |||
668 | 675 | | |
669 | 676 | | |
670 | 677 | | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
678 | 686 | | |
679 | 687 | | |
680 | 688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
219 | 257 | | |
220 | 258 | | |
221 | 259 | | |
| |||
1120 | 1158 | | |
1121 | 1159 | | |
1122 | 1160 | | |
1123 | | - | |
1124 | 1161 | | |
1125 | 1162 | | |
1126 | 1163 | | |
| |||
1153 | 1190 | | |
1154 | 1191 | | |
1155 | 1192 | | |
1156 | | - | |
1157 | 1193 | | |
1158 | 1194 | | |
1159 | 1195 | | |
| |||
1169 | 1205 | | |
1170 | 1206 | | |
1171 | 1207 | | |
1172 | | - | |
1173 | 1208 | | |
1174 | 1209 | | |
1175 | 1210 | | |
| |||
1213 | 1248 | | |
1214 | 1249 | | |
1215 | 1250 | | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
1216 | 1313 | | |
1217 | 1314 | | |
1218 | 1315 | | |
| |||
1525 | 1622 | | |
1526 | 1623 | | |
1527 | 1624 | | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
1528 | 1663 | | |
1529 | 1664 | | |
1530 | 1665 | | |
| |||
0 commit comments