Skip to content

Commit 75507d5

Browse files
authored
Merge branch 'master' into master-fcfangcc
2 parents 97f2e04 + 02f281d commit 75507d5

File tree

7 files changed

+65
-2
lines changed

7 files changed

+65
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
`vector top` terminal UI now shows `disabled` in the Memory Used column when the connected Vector instance was not started with `--allocation-tracing`, instead of displaying misleading zeros. A new `GetAllocationTracingStatus` gRPC endpoint is queried on connect to determine the status.
2+
3+
authors: pront

lib/vector-api-client/src/client.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use tonic::transport::{Channel, Endpoint};
55
use crate::{
66
error::{Error, Result},
77
proto::{
8+
GetAllocationTracingStatusRequest, GetAllocationTracingStatusResponse,
89
GetComponentsRequest, GetComponentsResponse, GetMetaRequest, GetMetaResponse,
910
HealthRequest, HealthResponse, MetricName, StreamComponentAllocatedBytesRequest,
1011
StreamComponentAllocatedBytesResponse, StreamComponentMetricsRequest,
@@ -77,6 +78,17 @@ impl Client {
7778
Ok(response.into_inner())
7879
}
7980

81+
/// Check whether allocation tracing is active on the connected Vector instance
82+
pub async fn get_allocation_tracing_status(
83+
&mut self,
84+
) -> Result<GetAllocationTracingStatusResponse> {
85+
let client = self.ensure_connected()?;
86+
let response = client
87+
.get_allocation_tracing_status(GetAllocationTracingStatusRequest {})
88+
.await?;
89+
Ok(response.into_inner())
90+
}
91+
8092
// ========== Streaming RPCs ==========
8193

8294
/// Stream periodic heartbeat timestamps

lib/vector-top/src/dashboard.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ impl<'a> Widgets<'a> {
349349
self.human_metrics,
350350
),
351351
#[cfg(feature = "allocation-tracing")]
352-
r.allocated_bytes.human_format_bytes(),
352+
if state.allocation_tracing_active {
353+
r.allocated_bytes.human_format_bytes()
354+
} else {
355+
"disabled".to_string()
356+
},
353357
if self.human_metrics {
354358
r.errors.human_format()
355359
} else {

lib/vector-top/src/metrics.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,5 +569,21 @@ pub async fn init_components(
569569
})
570570
.collect::<BTreeMap<_, _>>();
571571

572-
Ok(state::State::new(rows))
572+
let mut state = state::State::new(rows);
573+
574+
#[cfg(feature = "allocation-tracing")]
575+
{
576+
// Allocation tracing is a compile-time + startup-time setting on the
577+
// server, so querying once per connection is sufficient. On error
578+
// (e.g. older server without this RPC) we default to false, matching
579+
// pre-existing behavior. This is re-evaluated on every reconnect via
580+
// the retry loop in `subscription()`.
581+
state.allocation_tracing_active = client
582+
.get_allocation_tracing_status()
583+
.await
584+
.map(|r| r.enabled)
585+
.unwrap_or(false);
586+
}
587+
588+
Ok(state)
573589
}

lib/vector-top/src/state.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ pub struct State {
122122
pub sort_state: SortState,
123123
pub filter_state: FilterState,
124124
pub ui: UiState,
125+
/// Set to `true` once we receive the first `AllocatedBytes` event,
126+
/// indicating the connected Vector instance has allocation tracing active.
127+
#[cfg(feature = "allocation-tracing")]
128+
pub allocation_tracing_active: bool,
125129
}
126130

127131
#[derive(Debug, Clone, Copy)]
@@ -343,6 +347,8 @@ impl State {
343347
ui: UiState::default(),
344348
sort_state: SortState::default(),
345349
filter_state: FilterState::default(),
350+
#[cfg(feature = "allocation-tracing")]
351+
allocation_tracing_active: false,
346352
}
347353
}
348354

proto/vector/observability.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ service ObservabilityService {
1717
// Get information about configured components (sources, transforms, sinks)
1818
rpc GetComponents(GetComponentsRequest) returns (GetComponentsResponse);
1919

20+
// Check whether allocation tracing is active on this instance
21+
rpc GetAllocationTracingStatus(GetAllocationTracingStatusRequest) returns (GetAllocationTracingStatusResponse);
22+
2023
// ========== Real-time Metric Streams ==========
2124
// All streaming RPCs send periodic updates at the specified interval
2225

@@ -54,6 +57,12 @@ message GetMetaResponse {
5457
string hostname = 2;
5558
}
5659

60+
message GetAllocationTracingStatusRequest {}
61+
62+
message GetAllocationTracingStatusResponse {
63+
bool enabled = 1;
64+
}
65+
5766
// ========== Component Messages ==========
5867

5968
message GetComponentsRequest {

src/api/grpc/service.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,19 @@ impl observability::Service for ObservabilityService {
436436
Ok(Response::new(GetMetaResponse { version, hostname }))
437437
}
438438

439+
async fn get_allocation_tracing_status(
440+
&self,
441+
_request: Request<GetAllocationTracingStatusRequest>,
442+
) -> Result<Response<GetAllocationTracingStatusResponse>, Status> {
443+
#[cfg(feature = "allocation-tracing")]
444+
let enabled = crate::internal_telemetry::allocations::is_allocation_tracing_enabled();
445+
#[cfg(not(feature = "allocation-tracing"))]
446+
let enabled = false;
447+
Ok(Response::new(GetAllocationTracingStatusResponse {
448+
enabled,
449+
}))
450+
}
451+
439452
async fn get_components(
440453
&self,
441454
request: Request<GetComponentsRequest>,

0 commit comments

Comments
 (0)