Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bpf/generictracer/k_tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,13 @@ int obi_handle_buf_with_args(void *ctx) {
}
}
}

http_send_large_buffer(info,
(void *)args->u_buf,
args->bytes_len,
args->packet_type,
args->direction,
k_large_buf_action_append);
} else if (still_responding(info)) {
info->end_monotime_ns = bpf_ktime_get_ns();
}
Expand Down
6 changes: 6 additions & 0 deletions bpf/generictracer/protocol_http.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,12 @@ __obi_protocol_http(struct pt_regs *ctx, unsigned char *(*tp_loop_fn)(unsigned c
return 0;
}
} else if ((args->packet_type == PACKET_TYPE_RESPONSE) && (info->status == 0)) {
http_send_large_buffer(info,
(void *)args->u_buf,
args->bytes_len,
args->packet_type,
args->direction,
k_large_buf_action_init);
handle_http_response(
args->small_buf, &args->pid_conn, info, args->bytes_len, args->direction, args->ssl);
} else if (still_reading(info)) {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/shirou/gopsutil/v3 v3.24.5
github.com/stretchr/testify v1.11.1
github.com/tklauser/go-sysconf v0.3.15
github.com/vektah/gqlparser/v2 v2.5.30
github.com/vishvananda/netlink v1.3.1
github.com/vladimirvivien/gexe v0.5.0
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
Expand Down
26 changes: 6 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/AlessandroPomponio/go-gibberish v0.0.0-20191004143433-a2d4156f0396 h1
github.com/AlessandroPomponio/go-gibberish v0.0.0-20191004143433-a2d4156f0396/go.mod h1:2VCDG9kHYQ5vfYUqeoB7foVlcvIvB7rp9LxTELLD1qU=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.29.0 h1:UQUsRi8WTzhZntp5313l+CHIAT95ojUI2lpP/ExlZa4=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.29.0/go.mod h1:Cz6ft6Dkn3Et6l2v2a9/RpN7epQ1GtDlO6lj8bEcOvw=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go-v2 v1.38.1 h1:j7sc33amE74Rz0M/PoCpsZQ6OunLqys/m5antM0J+Z8=
Expand Down Expand Up @@ -232,8 +234,6 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
Expand All @@ -246,6 +246,8 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
Expand All @@ -269,18 +271,16 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4=
github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso=
github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE=
github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo=
github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0=
github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4=
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
Expand Down Expand Up @@ -482,9 +482,7 @@ golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
Expand Down Expand Up @@ -513,14 +511,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 h1:
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:kXqgZtrWaf6qS3jZOCnCH7WYfrvFjkC51bM8fz3RsCA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4=
google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand All @@ -534,18 +526,12 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.34.0 h1:L+JtP2wDbEYPUeNGbeSa/5GwFtIA662EmT2YSLOkAVE=
k8s.io/api v0.34.0/go.mod h1:YzgkIzOOlhl9uwWCZNqpw6RJy9L2FK4dlJeayUoydug=
k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM=
k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk=
k8s.io/apiextensions-apiserver v0.33.0 h1:d2qpYL7Mngbsc1taA4IjJPRJ9ilnsXIrndH+r9IimOs=
k8s.io/apiextensions-apiserver v0.33.0/go.mod h1:VeJ8u9dEEN+tbETo+lFkwaaZPg6uFKLGj5vyNEwwSzc=
k8s.io/apimachinery v0.34.0 h1:eR1WO5fo0HyoQZt1wdISpFDffnWOvFLOOeJ7MgIv4z0=
k8s.io/apimachinery v0.34.0/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4=
k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/client-go v0.34.0 h1:YoWv5r7bsBfb0Hs2jh8SOvFbKzzxyNo0nSb0zC19KZo=
k8s.io/client-go v0.34.0/go.mod h1:ozgMnEKXkRjeMvBZdV1AijMHLTh3pbACPvK7zFR+QQY=
k8s.io/client-go v0.34.1 h1:ZUPJKgXsnKwVwmKKdPfw4tB58+7/Ik3CrjOEhsiZ7mY=
k8s.io/client-go v0.34.1/go.mod h1:kA8v0FP+tk6sZA0yKLRG67LWjqufAoSHA2xVGKw9Of8=
k8s.io/component-base v0.33.0 h1:Ot4PyJI+0JAD9covDhwLp9UNkUja209OzsJ4FzScBNk=
Expand Down
5 changes: 5 additions & 0 deletions pkg/app/request/metric_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ func DBSystemName(val string) attribute.KeyValue {
return attribute.Key(attr.DBSystemName).String(val)
}

func GraphqlOperationType(val string) attribute.KeyValue {
// TODO: replace once it's available in semconv
return attribute.Key(attr.GraphQLOperationType).String(val)
}

func ErrorType(val string) attribute.KeyValue {
return attribute.Key(attr.ErrorType).String(val)
}
Expand Down
28 changes: 27 additions & 1 deletion pkg/app/request/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ const (
DBMySQL
)

const (
HTTPSubtypeNone = 0 // http
HTTPSubtypeGraphQL = 1 // http + graphql
)

//nolint:cyclop
func (t EventType) String() string {
switch t {
Expand Down Expand Up @@ -159,6 +164,12 @@ type MessagingInfo struct {
Partition int `json:"partition"`
}

type GraphQL struct {
Document string `json:"document"`
OperationName string `json:"operationName"`
OperationType string `json:"operationType"`
}

// Span contains the information being submitted by the following nodes in the graph.
// It enables comfortable handling of data from Go.
// REMINDER: any attribute here must be also added to the functions SpanOTELGetters,
Expand Down Expand Up @@ -195,6 +206,7 @@ type Span struct {
SQLCommand string `json:"-"`
SQLError *SQLError `json:"-"`
MessagingInfo *MessagingInfo `json:"-"`
GraphQL *GraphQL `json:"-"`

// OverrideTraceName is set under some conditions, like spanmetrics reaching the maximum
// cardinality for trace names.
Expand All @@ -217,7 +229,7 @@ type SpanAttributes map[string]string
func spanAttributes(s *Span) SpanAttributes {
switch s.Type {
case EventTypeHTTP:
return SpanAttributes{
attrs := SpanAttributes{
"method": s.Method,
"status": strconv.Itoa(s.Status),
"url": s.Path,
Expand All @@ -228,6 +240,12 @@ func spanAttributes(s *Span) SpanAttributes {
"serverAddr": SpanHost(s),
"serverPort": strconv.Itoa(s.HostPort),
}
if s.SubType == HTTPSubtypeGraphQL && s.GraphQL != nil {
attrs["graphqlDocument"] = s.GraphQL.Document
attrs["graphqlOperationName"] = s.GraphQL.OperationName
attrs["graphqlOperationType"] = s.GraphQL.OperationType
}
return attrs
case EventTypeHTTPClient:
return SpanAttributes{
"method": s.Method,
Expand Down Expand Up @@ -562,6 +580,14 @@ func (s *Span) TraceName() string {
}
switch s.Type {
case EventTypeHTTP, EventTypeHTTPClient:
if s.Type == EventTypeHTTP && s.SubType == HTTPSubtypeGraphQL && s.GraphQL != nil {
if s.GraphQL.OperationType != "" {
return "GraphQL " + s.GraphQL.OperationType
} else {
return "GraphQL Operation"
}
}

name := s.Method
if s.Route != "" {
name += " " + s.Route
Expand Down
21 changes: 21 additions & 0 deletions pkg/app/request/span_getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ func spanOTELGetters(name attr.Name) (attributes.Getter[*Span, attribute.KeyValu
getter = func(span *Span) attribute.KeyValue { return Job(span.Service.Job()) }
case attr.Instance:
getter = func(span *Span) attribute.KeyValue { return Job(span.Service.UID.Instance) }
case attr.GraphQLDocument:
getter = func(s *Span) attribute.KeyValue {
if s.Type == EventTypeHTTP && s.SubType == HTTPSubtypeGraphQL && s.GraphQL != nil {
return semconv.GraphqlDocument(s.GraphQL.Document)
}
return semconv.GraphqlDocument("")
}
case attr.GraphQLOperationName:
getter = func(s *Span) attribute.KeyValue {
if s.Type == EventTypeHTTP && s.SubType == HTTPSubtypeGraphQL && s.GraphQL != nil {
return semconv.GraphqlOperationName(s.GraphQL.OperationName)
}
return semconv.GraphqlOperationName("")
}
case attr.GraphQLOperationType:
getter = func(s *Span) attribute.KeyValue {
if s.Type == EventTypeHTTP && s.SubType == HTTPSubtypeGraphQL && s.GraphQL != nil {
return GraphqlOperationType(s.GraphQL.OperationType)
}
return GraphqlOperationType("")
}
}
// default: unlike the Prometheus getters, we don't check here for service name nor k8s metadata
// because they are already attributes of the Resource instead of the attributes.
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/ebpf_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ type EBPFTracer struct {

// MongoDB requests cache size.
MongoRequestsCacheSize int `yaml:"mongo_requests_cache_size" env:"OTEL_EBPF_BPF_MONGO_REQUESTS_CACHE_SIZE"`

// Configure data extraction/parsing based on protocol
PayloadExtraction PayloadExtraction `yaml:"payload_extraction"`
}

// Per-protocol data buffer size in bytes.
Expand Down
18 changes: 18 additions & 0 deletions pkg/config/payload_extraction.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package config

type PayloadExtraction struct {
HTTP HTTPConfig `yaml:"http"`
}

type HTTPConfig struct {
// GraphQL payload extraction and parsing
GraphQL GraphQLConfig `yaml:"graphql"`
}

type GraphQLConfig struct {
// Enable GraphQL payload extraction and parsing
Enabled bool `yaml:"enabled" env:"OTEL_EBPF_HTTP_GRAPHQL_ENABLED"`
}
29 changes: 29 additions & 0 deletions pkg/ebpf/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type EBPFParseContext struct {
postgresPreparedStatements *simplelru.LRU[postgresPreparedStatementsKey, string]
postgresPortals *simplelru.LRU[postgresPortalsKey, string]
kafkaTopicUUIDToName *simplelru.LRU[kafkaparser.UUID, string]
payloadExtraction config.PayloadExtraction
}

type EBPFEventContext struct {
Expand All @@ -157,6 +158,7 @@ func NewEBPFParseContext(cfg *config.EBPFTracer) *EBPFParseContext {
postgresPortals *simplelru.LRU[postgresPortalsKey, string]
kafkaTopicUUIDToName *simplelru.LRU[kafkaparser.UUID, string]
mongoRequestCache PendingMongoDBRequests
payloadExtraction config.PayloadExtraction
)

h2c, _ := lru.New[uint64, h2Connection](1024 * 10)
Expand Down Expand Up @@ -192,6 +194,8 @@ func NewEBPFParseContext(cfg *config.EBPFTracer) *EBPFParseContext {
}

mongoRequestCache = expirable.NewLRU[MongoRequestKey, *MongoRequestValue](cfg.MongoRequestsCacheSize, nil, 0)

payloadExtraction = cfg.PayloadExtraction
}

return &EBPFParseContext{
Expand All @@ -203,6 +207,7 @@ func NewEBPFParseContext(cfg *config.EBPFTracer) *EBPFParseContext {
postgresPreparedStatements: postgresPreparedStatements,
postgresPortals: postgresPortals,
kafkaTopicUUIDToName: kafkaTopicUUIDToName,
payloadExtraction: payloadExtraction,
}
}

Expand Down Expand Up @@ -404,3 +409,27 @@ func (connInfo *BPFConnInfo) reqHostInfo() (source, target string) {

return srcStr, dstStr
}

func isClientEvent(et uint8) bool {
switch request.EventType(et) {
case request.EventTypeGRPCClient, request.EventTypeHTTPClient, request.EventTypeRedisClient,
request.EventTypeKafkaClient, request.EventTypeSQLClient, request.EventTypeMongoClient,
request.EventTypeFailedConnect:
return true
}

return false
}

func directionByPacketType(pt uint8, isClient bool) uint8 {
if isClient {
if pt == packetTypeRequest {
return directionSend
}
return directionRecv
}
if pt == packetTypeRequest {
return directionRecv
}
return directionSend
}
Loading