Skip to content

Commit

Permalink
Only trace framer operations if in an active trace.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 31, 2025
1 parent c912997 commit 0e572b2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/traces/provider/protocol/http2/framer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@

Traces::Provider(Protocol::HTTP2::Framer) do
def write_connection_preface
return super unless Traces.active?

Traces.trace("protocol.http2.framer.write_connection_preface") do
super
end
end

def read_connection_preface
return super unless Traces.active?

Traces.trace("protocol.http2.framer.read_connection_preface") do
super
end
end

def write_frame(frame)
return super unless Traces.active?

attributes = {
"frame.length" => frame.length,
"frame.class" => frame.class.name,
Expand All @@ -34,6 +40,8 @@ def write_frame(frame)
end

def read_frame(...)
return super unless Traces.active?

Traces.trace("protocol.http2.framer.read_frame") do |span|
super.tap do |frame|
span["frame.length"] = frame.length
Expand All @@ -45,6 +53,8 @@ def read_frame(...)
end

def flush
return super unless Traces.active?

Traces.trace("protocol.http2.framer.flush") do
super
end
Expand Down

0 comments on commit 0e572b2

Please sign in to comment.