Skip to content

Commit

Permalink
Enable mux tracing
Browse files Browse the repository at this point in the history
Summary: Enable mux tracing. If the kernel version is too old, turn it off due to instruction limits. Enable mux_trace_bpf_test.

Test Plan: Existing tests

Reviewers: #stirling, jps

Reviewed By: #stirling, jps

Subscribers: jps

Signed-off-by: Ryan Cheng <rcheng@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D11652

GitOrigin-RevId: 604e9bf
  • Loading branch information
chengruizhe authored and copybaranaut committed Jun 22, 2022
1 parent 2ae7c89 commit b12f6a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/stirling/source_connectors/socket_tracer/mux_trace_bpf_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "src/stirling/source_connectors/socket_tracer/testing/container_images.h"
#include "src/stirling/source_connectors/socket_tracer/testing/socket_trace_bpf_test_fixture.h"
#include "src/stirling/testing/common.h"
#include "src/stirling/utils/linux_headers.h"

namespace px {
namespace stirling {
Expand Down Expand Up @@ -147,9 +148,16 @@ inline auto EqMuxRecord(const mux::Record& x) {
// Test Scenarios
//-----------------------------------------------------------------------------

TEST_F(MuxTraceTest, DISABLED_Capture) {
// Uncomment to enable tracing
// FLAGS_stirling_conn_trace_pid = server_.process_pid();
TEST_F(MuxTraceTest, Capture) {
// If kernel version is older than 5.2, we turn off some protocol tracers due to instruction
// limits.
constexpr uint32_t kLinux5p2VersionCode = 328192;
auto kernel_version = utils::GetKernelVersion();
if (!kernel_version.ok() || kernel_version.ConsumeValueOrDie().code() < kLinux5p2VersionCode) {
VLOG(1) << "Mux Tracing is turned off for kernel version older than 5.2.";
return;
}

StartTransferDataThread();

ASSERT_OK(RunThriftMuxClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "src/stirling/source_connectors/socket_tracer/proto/sock_event.pb.h"
#include "src/stirling/source_connectors/socket_tracer/protocols/http/utils.h"
#include "src/stirling/source_connectors/socket_tracer/protocols/http2/grpc.h"
#include "src/stirling/utils/linux_headers.h"
#include "src/stirling/utils/proc_path_tools.h"

// 50 X less often than the normal sampling frequency. Based on the conn_stats_table.h's
Expand Down Expand Up @@ -89,8 +90,7 @@ DEFINE_bool(stirling_enable_nats_tracing, true,
"If true, stirling will trace and process NATS messages.");
DEFINE_bool(stirling_enable_kafka_tracing, true,
"If true, stirling will trace and process Kafka messages.");
DEFINE_bool(stirling_enable_mux_tracing,
gflags::BoolFromEnv("PL_STIRLING_TRACER_ENABLE_MUX", false),
DEFINE_bool(stirling_enable_mux_tracing, gflags::BoolFromEnv("PL_STIRLING_TRACER_ENABLE_MUX", true),
"If true, stirling will trace and process Mux messages.");

DEFINE_bool(stirling_disable_self_tracing, true,
Expand Down Expand Up @@ -163,6 +163,15 @@ void SocketTraceConnector::InitProtocolTransferSpecs() {
#define TRANSFER_STREAM_PROTOCOL(protocol_name) \
&SocketTraceConnector::TransferStream<protocols::protocol_name::ProtocolTraits>

// If kernel version is older than 5.2, we turn off some protocol tracers due to instruction
// limits.
constexpr uint32_t kLinux5p2VersionCode = 328192;
auto kernel_version = utils::GetKernelVersion();
if (!kernel_version.ok() || kernel_version.ConsumeValueOrDie().code() < kLinux5p2VersionCode) {
VLOG(1) << "Turning off mux protocol tracer due to eBPF instruction limit.";
FLAGS_stirling_enable_mux_tracing = false;
}

// PROTOCOL_LIST: Requires update on new protocols.

// We popluate transfer_specs_by_protocol so that we guarantee the protocol_transfer_specs_
Expand Down

0 comments on commit b12f6a4

Please sign in to comment.