Skip to content

Refactor fanout exporter concurrent dispatch#7486

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-concurrent-dispatch
Jun 13, 2026
Merged

Refactor fanout exporter concurrent dispatch#7486
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-concurrent-dispatch

Conversation

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

fanoutExporter.ExportSpans and fanoutExporter.Shutdown carried the same concurrent fan-out and error aggregation logic, differing only in the exporter method invoked. This change consolidates that shared behavior so future updates to fan-out semantics happen in one place.

  • Shared dispatch path

    • Add a private forEachExporter helper on fanoutExporter
    • Preserve the existing behavior: invoke all exporters concurrently, tolerate partial failures, and return joined errors
  • Public method simplification

    • Refactor ExportSpans to delegate span export through the helper
    • Refactor Shutdown to delegate exporter shutdown through the helper
  • Coverage update

    • Add focused test coverage for the extracted helper to verify all exporters are visited and callback errors are propagated
func (f *fanoutExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error {
	return f.forEachExporter(func(e sdktrace.SpanExporter) error {
		return e.ExportSpans(ctx, spans)
	})
}

func (f *fanoutExporter) Shutdown(ctx context.Context) error {
	return f.forEachExporter(func(e sdktrace.SpanExporter) error {
		return e.Shutdown(ctx)
	})
}

GitHub Advanced Security started work on behalf of lpcox June 13, 2026 14:23 View session
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 14:25
Copilot AI changed the title [WIP] Refactor duplicate code in fanoutExporter methods Refactor fanout exporter concurrent dispatch Jun 13, 2026
Copilot finished work on behalf of lpcox June 13, 2026 14:29
Copilot AI requested a review from lpcox June 13, 2026 14:29
GitHub Advanced Security started work on behalf of lpcox June 13, 2026 14:37 View session
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 14:38
@lpcox lpcox marked this pull request as ready for review June 13, 2026 15:50
Copilot AI review requested due to automatic review settings June 13, 2026 15:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the tracing fanout span exporter to centralize its concurrent fan-out and error aggregation behavior into a single private helper, reducing duplication between ExportSpans and Shutdown while preserving existing semantics.

Changes:

  • Extract shared concurrent dispatch + joined-error aggregation into (*fanoutExporter).forEachExporter.
  • Refactor ExportSpans and Shutdown to delegate to the shared helper.
  • Add a focused unit test validating that the helper visits all exporters and propagates callback errors.
Show a summary per file
File Description
internal/tracing/fanout.go Consolidates concurrent exporter iteration + error joining into forEachExporter, simplifying ExportSpans and Shutdown.
internal/tracing/fanout_test.go Adds targeted coverage for forEachExporter to ensure all exporters are invoked and errors are returned.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@lpcox lpcox merged commit e9371f6 into main Jun 13, 2026
40 checks passed
@lpcox lpcox deleted the copilot/duplicate-code-concurrent-dispatch branch June 13, 2026 16:00
Copilot AI added a commit that referenced this pull request Jun 13, 2026
Adapt debug logging to the refactored forEachExporter helper
introduced in main (Refactor fanout exporter concurrent dispatch #7486).
The op string parameter to forEachExporter carries operation context into
per-backend error log messages, satisfying the reviewer request to
identify which exporter failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants