Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method name into telemetry in Context#run #4103

Merged
merged 4 commits into from
Nov 14, 2024
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
4 changes: 2 additions & 2 deletions lib/datadog/appsec/processor/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(handle, telemetry:)
@events = []
@run_mutex = Mutex.new

@libddwaf_debug_tag = "libddwaf:#{WAF::VERSION::STRING}"
@libddwaf_debug_tag = "libddwaf:#{WAF::VERSION::STRING} method:ddwaf_run"
end

def run(persistent_data, ephemeral_data, timeout = WAF::LibDDWAF::DDWAF_RUN_TIMEOUT)
Expand Down Expand Up @@ -79,7 +79,7 @@ def try_run(persistent_data, ephemeral_data, timeout)
@context.run(persistent_data, ephemeral_data, timeout)
rescue WAF::LibDDWAF::Error => e
Datadog.logger.debug { "#{@libddwaf_debug_tag} execution error: #{e} backtrace: #{e.backtrace&.first(3)}" }
@telemetry.report(e, description: 'libddwaf internal low-level error')
@telemetry.report(e, description: 'libddwaf-rb internal low-level error')

[:err_internal, WAF::Result.new(:err_internal, [], 0.0, false, [], [])]
end
Expand Down
6 changes: 3 additions & 3 deletions spec/datadog/appsec/processor/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
end

it 'sends telemetry error' do
expect(telemetry).to receive(:error).with(/libddwaf:[\d.]+ execution error: :err_invalid_object/)
expect(telemetry).to receive(:error).with(/libddwaf:[\d.]+ method:ddwaf_run execution error: :err_invalid_object/)

context.run(input, {}, timeout)
end
Expand All @@ -269,9 +269,9 @@
let(:result) { context.run(input, {}, timeout) }

it 'sends telemetry report' do
expect(telemetry).to receive(:error).with(/libddwaf:[\d.]+ execution error: :err_internal/)
expect(telemetry).to receive(:error).with(/libddwaf:[\d.]+ method:ddwaf_run execution error: :err_internal/)
expect(telemetry).to receive(:report)
.with(kind_of(Datadog::AppSec::WAF::LibDDWAF::Error), description: 'libddwaf internal low-level error')
.with(kind_of(Datadog::AppSec::WAF::LibDDWAF::Error), description: 'libddwaf-rb internal low-level error')

expect(result.status).to eq(:err_internal)
end
Expand Down
Loading