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

feat: add untraced wrapper to common utils #580

Merged
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: 4 additions & 0 deletions common/lib/opentelemetry/common/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def utf8_encode(string, binary: false, placeholder: STRING_PLACEHOLDER)

placeholder
end

def untraced
OpenTelemetry::Trace.with_span(OpenTelemetry::Trace::Span.new) { yield }
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def export(span_data, timeout: nil)
@transport.write(@serializer.serialize(batch))
end

untraced do
OpenTelemetry::Common::Utilities.untraced do
@transport.flush
end
SUCCESS
Expand Down Expand Up @@ -74,10 +74,6 @@ def invalid_url?(url)
true
end

def untraced
OpenTelemetry::Trace.with_span(OpenTelemetry::Trace::Span.new) { yield }
end

def encoded_batches(span_data)
span_data.group_by(&:resource).map do |resource, spans|
process = Encoder.encoded_process(resource)
Expand Down
6 changes: 1 addition & 5 deletions exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/AbcSize, Metrics/Cyclo
retry_count = 0
timeout ||= @timeout
start_time = Time.now
untraced do # rubocop:disable Metrics/BlockLength
OpenTelemetry::Common::Utilities.untraced do # rubocop:disable Metrics/BlockLength
request = Net::HTTP::Post.new(@path)
request.body = if @compression == 'gzip'
request.add_field('Content-Encoding', 'gzip')
Expand Down Expand Up @@ -179,10 +179,6 @@ def handle_redirect(location)
# TODO: figure out destination and reinitialize @http and @path
end

def untraced
OpenTelemetry::Trace.with_span(OpenTelemetry::Trace::Span.new) { yield }
end

def measure_request_duration
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
begin
Expand Down