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

Split single step instrument entry point #3931

Merged
merged 4 commits into from
Sep 20, 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
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Metrics/BlockNesting:
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/datadog/single_step_instrument.rb'
- 'lib/datadog/appsec/autoload.rb'
- 'lib/datadog/opentelemetry/api/trace/span.rb'
- 'lib/datadog/opentelemetry/sdk/trace/span.rb'
Expand Down
2 changes: 1 addition & 1 deletion lib-injection/host_inject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def bundler_supported?

bundle_add_cmd = "bundle add #{gem} --skip-install --version #{gem_version_mapping[gem]} "
bundle_add_cmd << ' --verbose ' if ENV['DD_TRACE_DEBUG'] == 'true'
bundle_add_cmd << '--require datadog/auto_instrument' if gem == 'datadog'
bundle_add_cmd << '--require datadog/single_step_instrument' if gem == 'datadog'

utils.debug "Injection with `#{bundle_add_cmd}`"

Expand Down
12 changes: 12 additions & 0 deletions lib/datadog/single_step_instrument.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

#
# Entrypoint file for single step instrumentation.
#
# This file's path is private. Do not reference this file.
#
begin
require_relative 'auto_instrument'
rescue StandardError, LoadError => e
warn "Single step instrumentation failed: #{e.class}:#{e.message}\n\tSource:\n\t#{Array(e.backtrace).join("\n\t")}"
end
Empty file.
23 changes: 23 additions & 0 deletions spec/datadog/single_step_instrument_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RSpec.describe 'Single step instrument', skip: !Process.respond_to?(:fork) do
it do
expect_in_fork do
expect_any_instance_of(Object)
.to receive(:require_relative).with('auto_instrument').and_raise(LoadError)

expect do
load 'datadog/single_step_instrument.rb'
end.to output(/Single step instrumentation failed/).to_stderr
end
end

it do
expect_in_fork do
expect_any_instance_of(Object)
.to receive(:require_relative).with('auto_instrument').and_raise(StandardError)

expect do
load 'datadog/single_step_instrument.rb'
end.to output(/Single step instrumentation failed/).to_stderr
end
end
end
Loading