diff --git a/instrumentation/active_job/example/active_job.rb b/instrumentation/active_job/example/active_job.rb index 4850014d96..d7f13e7fdb 100644 --- a/instrumentation/active_job/example/active_job.rb +++ b/instrumentation/active_job/example/active_job.rb @@ -84,7 +84,7 @@ def perform class DoItNowJob < ::ActiveJob::Base def perform - puts <<~EOS + $stderr.puts <<~EOS -------------------------------------------------- Called with perform_now! diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb index 215fca970b..b174028d7d 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb @@ -38,7 +38,7 @@ module Handlers def subscribe return unless Array(@subscriptions).empty? - tracer = Instrumentation.instance.tracer + tracer = OpenTelemetry.tracer_provider.tracer(ActiveJob.name, ActiveJob::VERSION) mapper = Mappers::Attribute.new config = ActiveJob::Instrumentation.instance.config parent_span_provider = OpenTelemetry::Instrumentation::ActiveJob diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb index 76cb54ed17..b07ea1c2bd 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb @@ -74,8 +74,10 @@ def finish(_name, _id, payload) def finish_span(span, tokens) # closes the span after all attributes have been finalized begin - span&.status = OpenTelemetry::Trace::Status.ok if span&.status&.code == OpenTelemetry::Trace::Status::UNSET - span&.finish + if span&.recording? + span&.status = OpenTelemetry::Trace::Status.ok if span&.status&.code == OpenTelemetry::Trace::Status::UNSET + span&.finish + end rescue StandardError => e OpenTelemetry.handle_error(exception: e) end