Should OpenTelemetry::Internal::ProxyTracerProvider implement force_flush? #1401
Replies: 2 comments 10 replies
-
Some more information, the gem has its instrumentation inline, it is never installed like the instrumentation I can see in |
Beta Was this translation helpful? Give feedback.
-
I'd like to discuss how end users could ensure spans are flushed when the API does not have the force flush method. Given the following:
Example code for these below. If the force flush does not become part of the API how can end users actually ensure that this is the behaviour they get? Some options I can think of:
Any other ideas or comments on this? require 'bundler/inline'
require 'securerandom'
gemfile do
source 'https://rubygems.org'
gem 'opentelemetry-api', require: false
gem 'opentelemetry-sdk', require: false
end
ENV["OTEL_LOG_LEVEL"] = "debug"
ENV["OTEL_TRACES_EXPORTER"] = "console"
# Example OSS library that applications depend on ------------------------------
module OssLibraryCode
require 'opentelemetry'
module Runner
def self.work
puts "Forking work"
fork do
do_work(SecureRandom.uuid)
end
end
def self.do_work(name)
puts " doing work - #{name}"
end
end
end
# OpenTelemetry community instrumentation --------------------------------------
module OpenTelemetry::RunnerPatch
TRACER = OpenTelemetry.tracer_provider.tracer('OpenTelemetry::RunnerTracing')
def self.prepended(base)
class << base
prepend ClassMethods
end
end
module ClassMethods
def do_work(name)
TRACER.in_span("work: #{name}") do
super
end
# If .force_flush was part of the API
# OpenTelemetry.tracer_provider.force_flush
end
end
end
OssLibraryCode::Runner.prepend(OpenTelemetry::RunnerPatch)
# End user application ---------------------------------------------------------
module EndUserApplication
require 'opentelemetry-sdk'
OpenTelemetry::SDK.configure
def self.start
OssLibraryCode::Runner.work
end
end
EndUserApplication.start |
Beta Was this translation helpful? Give feedback.
-
I have an a few applications that all use the same gem, the gem is instrumented with OpenTelemetry. I have the SDK configured on only some of the applications. The gem makes a call to force_flush because it does some work in a fork and then exits and I wish to make sure all spans are flushed before it exits.
I may have not set up the gem or the applications correctly but when the SDK is not configured I see the
ProxyTracerProvider
instance doesn't have theforce_flush
method.Should the API also implement this force flush method, as a no-op? Is there some configuration I am missing?
Here is an example demonstrating this:
Will result in:
Beta Was this translation helpful? Give feedback.
All reactions