Skip to content

Commit

Permalink
[usm] add continuation_frames counter to ebpf.http2_telemetry_t
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-lipnesh committed Jan 14, 2025
1 parent 736a4fe commit 0c3c373
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/network/ebpf/c/protocols/http2/decoding-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ typedef struct {
// literal_value_exceeds_frame Count of times we couldn't retrieve the literal value due to reaching the end of the frame.
// exceeding_max_interesting_frames Count of times we reached the max number of frames per iteration.
// exceeding_max_frames_to_filter Count of times we have left with more frames to filter than the max number of frames to filter.
// continuation_frames Count of occurrences where a frame of type CONTINUATION was found.
// path_size_bucket Count of path sizes and divided into buckets.
// frames_split_count Count of times we tried to read more data than the end of the data end.
typedef struct {
__u64 request_seen;
__u64 response_seen;
Expand All @@ -236,6 +236,7 @@ typedef struct {
__u64 literal_value_exceeds_frame;
__u64 exceeding_max_interesting_frames;
__u64 exceeding_max_frames_to_filter;
__u64 continuation_frames;
__u64 path_size_bucket[HTTP2_TELEMETRY_PATH_BUCKETS+1];
} http2_telemetry_t;

Expand Down
8 changes: 6 additions & 2 deletions pkg/network/ebpf/c/protocols/http2/decoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,12 @@ static __always_inline void headers_parser(pktbuf_t pkt, void *map_key, conn_tup
}
bpf_memset(headers_to_process, 0, HTTP2_MAX_HEADERS_COUNT_FOR_PROCESSING * sizeof(http2_header_t));

__u8 interesting_headers = 0;

__u64 *global_dynamic_counter = get_dynamic_counter(tup);
if (global_dynamic_counter == NULL) {
goto delete_iteration;
}
__u8 interesting_headers = 0;
__u8 continuation_frames = 0;

#pragma unroll(HTTP2_MAX_FRAMES_FOR_HEADERS_PARSER_PER_TAIL_CALL)
for (__u16 index = 0; index < HTTP2_MAX_FRAMES_FOR_HEADERS_PARSER_PER_TAIL_CALL; index++) {
Expand All @@ -915,6 +915,9 @@ static __always_inline void headers_parser(pktbuf_t pkt, void *map_key, conn_tup
current_frame = frames_array[tail_call_state->iteration];
tail_call_state->iteration += 1;

if (current_frame.frame.type == kContinuationFrame) {
continuation_frames++;
}
if (current_frame.frame.type != kHeadersFrame) {
continue;
}
Expand All @@ -930,6 +933,7 @@ static __always_inline void headers_parser(pktbuf_t pkt, void *map_key, conn_tup
interesting_headers = pktbuf_filter_relevant_headers(pkt, global_dynamic_counter, &http2_ctx->dynamic_index, headers_to_process, current_frame.frame.length, http2_tel);
pktbuf_process_headers(pkt, &http2_ctx->dynamic_index, current_stream, headers_to_process, interesting_headers, http2_tel);
}
__sync_fetch_and_add(&http2_tel->continuation_frames, 1);

if (tail_call_state->iteration < HTTP2_MAX_FRAMES_ITERATIONS &&
tail_call_state->iteration < tail_call_state->frames_count &&
Expand Down
7 changes: 4 additions & 3 deletions pkg/network/protocols/http2/model_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ HTTP2Telemetry{
"literal values exceed message count": %d,
"messages with more frames than we can filter": %d,
"messages with more interesting frames than we can process": %d,
"continuation frames" : %d,
"path headers length distribution": {
"in range [0, 120)": %d,
"in range [120, 130)": %d,
Expand All @@ -456,7 +457,7 @@ HTTP2Telemetry{
"in range [180, infinity)": %d
}
}`, t.Request_seen, t.Response_seen, t.End_of_stream, t.End_of_stream_rst, t.Literal_value_exceeds_frame,
t.Exceeding_max_frames_to_filter, t.Exceeding_max_interesting_frames, t.Path_size_bucket[0], t.Path_size_bucket[1],
t.Path_size_bucket[2], t.Path_size_bucket[3], t.Path_size_bucket[4], t.Path_size_bucket[5], t.Path_size_bucket[6],
t.Path_size_bucket[7])
t.Exceeding_max_frames_to_filter, t.Exceeding_max_interesting_frames, t.Continuation_frames,
t.Path_size_bucket[0], t.Path_size_bucket[1], t.Path_size_bucket[2], t.Path_size_bucket[3],
t.Path_size_bucket[4], t.Path_size_bucket[5], t.Path_size_bucket[6], t.Path_size_bucket[7])
}
5 changes: 5 additions & 0 deletions pkg/network/protocols/http2/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type kernelTelemetry struct {
exceedingMaxInterestingFrames *libtelemetry.TLSAwareCounter
// exceedingMaxFramesToFilter Count of times we have left with more frames to filter than the max number of frames to filter.
exceedingMaxFramesToFilter *libtelemetry.TLSAwareCounter
// continuationFramesCount Count of occurrences where a frame of type CONTINUATION was found.
continuationFramesCount *libtelemetry.TLSAwareCounter
// fragmentedFrameCountRST Count of times we have seen a fragmented RST frame.
fragmentedFrameCountRST *libtelemetry.TLSAwareCounter
// fragmentedHeadersFrameEOSCount Count of times we have seen a fragmented headers frame with EOS.
Expand All @@ -58,6 +60,7 @@ func newHTTP2KernelTelemetry() *kernelTelemetry {
literalValueExceedsFrame: libtelemetry.NewTLSAwareCounter(metricGroup, "literal_value_exceeds_frame"),
exceedingMaxInterestingFrames: libtelemetry.NewTLSAwareCounter(metricGroup, "exceeding_max_interesting_frames"),
exceedingMaxFramesToFilter: libtelemetry.NewTLSAwareCounter(metricGroup, "exceeding_max_frames_to_filter"),
continuationFramesCount: libtelemetry.NewTLSAwareCounter(metricGroup, "continuation_frames"),
fragmentedDataFrameEOSCount: libtelemetry.NewTLSAwareCounter(metricGroup, "exceeding_data_end_data_eos"),
fragmentedHeadersFrameCount: libtelemetry.NewTLSAwareCounter(metricGroup, "exceeding_data_end_headers"),
fragmentedHeadersFrameEOSCount: libtelemetry.NewTLSAwareCounter(metricGroup, "exceeding_data_end_headers_eos"),
Expand All @@ -81,6 +84,7 @@ func (t *kernelTelemetry) update(tel *HTTP2Telemetry, isTLS bool) {
t.literalValueExceedsFrame.Add(int64(telemetryDelta.Literal_value_exceeds_frame), isTLS)
t.exceedingMaxInterestingFrames.Add(int64(telemetryDelta.Exceeding_max_interesting_frames), isTLS)
t.exceedingMaxFramesToFilter.Add(int64(telemetryDelta.Exceeding_max_frames_to_filter), isTLS)
t.continuationFramesCount.Add(int64(telemetryDelta.Continuation_frames), isTLS)
for bucketIndex := range t.pathSizeBucket {
t.pathSizeBucket[bucketIndex].Add(int64(telemetryDelta.Path_size_bucket[bucketIndex]), isTLS)
}
Expand All @@ -104,6 +108,7 @@ func (t *HTTP2Telemetry) Sub(other HTTP2Telemetry) *HTTP2Telemetry {
Literal_value_exceeds_frame: t.Literal_value_exceeds_frame - other.Literal_value_exceeds_frame,
Exceeding_max_interesting_frames: t.Exceeding_max_interesting_frames - other.Exceeding_max_interesting_frames,
Exceeding_max_frames_to_filter: t.Exceeding_max_frames_to_filter - other.Exceeding_max_frames_to_filter,
Continuation_frames: t.Continuation_frames - other.Continuation_frames,
Path_size_bucket: computePathSizeBucketDifferences(t.Path_size_bucket, other.Path_size_bucket),
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/network/protocols/http2/types_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0c3c373

Please sign in to comment.