Commit bac6ccb
authored
chore: consolidate agent code for otlp (#1132)
## Overview
Consolidates the OTLP agent code by merging grpc_agent.rs into agent.rs,
eliminating ~280 lines of duplicated code. A single Agent struct now
owns a shared TracePipeline and starts HTTP, gRPC, or both servers based
on config.
## Changes
- Introduced TracePipeline struct holding shared state (config,
processor, trace channels, stats generator) with a
process_and_send_traces method used by both HTTP and gRPC handlers
- TraceService (gRPC) is implemented directly on TracePipeline, removing
the redundant OtlpGrpcService struct
- Agent now holds Option<u16> for http_port/grpc_port, spawning
whichever protocols are configured
- Collapsed should_enable_otlp_http + should_enable_otlp_grpc into a
single should_enable_otlp_agent
- Deleted grpc_agent.rs
- Simplified start_otlp_agent in main.rs: one Agent, one spawn
## Bug fixes
- parse_port scheme handling — HTTP agent's split(':').nth(1) broke on
endpoints with schemes like http://localhost:4318. Replaced with the
gRPC version that strips http:///https:// prefixes and uses rsplit(':')
for IPv6 support
- Empty trace check — HTTP handler checked size_of_val(&traces) == 0,
which always evaluates to false (returns the 24-byte stack size of the
Vec struct). Replaced with traces.iter().all(Vec::is_empty) in the
shared pipeline
## Tests
Merged and deduplicated parse_port tests (gained scheme-handling
coverage), consolidated enablement tests into should_enable_otlp_agent.
All 28 OTLP tests pass, zero clippy warnings.1 parent 54ddaab commit bac6ccb
File tree
5 files changed
+312
-471
lines changed- bottlecap/src
- bin/bottlecap
- otlp
- integration-tests/tests
5 files changed
+312
-471
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 55 | + | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| |||
1357 | 1354 | | |
1358 | 1355 | | |
1359 | 1356 | | |
1360 | | - | |
1361 | | - | |
1362 | | - | |
1363 | | - | |
| 1357 | + | |
1364 | 1358 | | |
1365 | 1359 | | |
1366 | 1360 | | |
1367 | 1361 | | |
1368 | 1362 | | |
1369 | 1363 | | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
1375 | | - | |
1376 | | - | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
1392 | | - | |
1393 | | - | |
1394 | | - | |
1395 | | - | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1396 | 1372 | | |
1397 | | - | |
1398 | | - | |
1399 | | - | |
1400 | | - | |
1401 | | - | |
1402 | | - | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1403 | 1378 | | |
1404 | 1379 | | |
1405 | 1380 | | |
| |||
0 commit comments