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

Add context to metrics reporting of buffer-full events #1566

Merged
merged 12 commits into from
Jan 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def on_finish(span)
n = spans.size + 1 - max_queue_size
if n.positive?
spans.shift(n)
report_dropped_spans(n, reason: 'buffer-full')
report_dropped_spans(n, reason: 'buffer-full', function: 'on_finish')
end
spans << span
@condition.signal if spans.size > batch_size
Expand Down Expand Up @@ -123,7 +123,7 @@ def force_flush(timeout: nil) # rubocop:disable Metrics/MethodLength
n = spans.size + snapshot.size - max_queue_size
if n.positive?
snapshot.shift(n)
report_dropped_spans(n, reason: 'buffer-full')
report_dropped_spans(n, reason: 'buffer-full', function: 'force_flush')
end
spans.unshift(snapshot) unless snapshot.empty?
@condition.signal if spans.size > max_queue_size / 2
Expand Down Expand Up @@ -204,8 +204,8 @@ def report_result(result_code, batch)
end
end

def report_dropped_spans(count, reason:)
@metrics_reporter.add_to_counter('otel.bsp.dropped_spans', increment: count, labels: { 'reason' => reason })
def report_dropped_spans(count, reason:, function: nil)
@metrics_reporter.add_to_counter('otel.bsp.dropped_spans', increment: count, labels: { 'reason' => reason, OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => function }.compact)
end

def fetch_batch
Expand Down