You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added opentelemetry to a rake task and noticed traces started posting after I added a sleep(10) to at_exit. I added tracer_provider.shutdown but it doesn't block and after looking into the jaeger implementation just returns SUCCESS.
If it helps explain what I am trying to do and always possible I am doing something wrong:
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/jaeger'
OpenTelemetry::SDK.configure do |c|
c.resource = OpenTelemetry::SDK::Resources::Resource.create(
'service.name' => 'service1' # Replace with your desired service name
)
c.add_span_processor(OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(OpenTelemetry::Exporter::Jaeger::AgentExporter.new(
host: "localhost",
port: 6831
)))
end
tracer_provider = OpenTelemetry::SDK::Trace::TracerProvider.new
MyAppTracer = OpenTelemetry.tracer_provider.tracer('service1')
# Register an at_exit hook
at_exit do
# Flush and shutdown the tracer
puts(" shutdown code: #{tracer_provider.shutdown(timeout: 60)}")
puts("Force flush code: #{tracer_provider.force_flush(timeout: 60)}")
#sleep(10)
end
task :test do |t|
MyAppTracer.in_span("#{t}") do |span|
span.add_attributes({
"task" => "#{t}"
})
trace_id = span.context.trace_id
puts "#{t} trace ID: #{trace_id.unpack1('H*')}"
puts "#{t} ran"
end
end
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I added opentelemetry to a rake task and noticed traces started posting after I added a
sleep(10)
toat_exit
. I addedtracer_provider.shutdown
but it doesn't block and after looking into the jaeger implementation just returnsSUCCESS
.If it helps explain what I am trying to do and always possible I am doing something wrong:
Thanks in advance for any help.
Beta Was this translation helpful? Give feedback.
All reactions