-
Notifications
You must be signed in to change notification settings - Fork 32
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
FE Release 2024-09-16 #3129
FE Release 2024-09-16 #3129
Changes from 12 commits
9c01680
3eb681d
100324f
41eddc9
bf9e14b
651ce66
9504c26
2e517b3
913f0e2
da1678e
265aff4
e1d45dc
7ffafac
377a7fa
9aadad2
0357100
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package metrics | ||
|
||
// HeadersToMap converts a string of headers to a map. | ||
func HeadersToMap(val string) map[string]string { | ||
return headersToMap(val) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package metrics | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"go.uber.org/multierr" | ||
"sync" | ||
"time" | ||
|
||
"go.opentelemetry.io/otel/sdk/trace" | ||
) | ||
|
||
// MultiExporter is an interface that allows exporting spans to multiple OTLP trace exporters. | ||
type MultiExporter interface { | ||
trace.SpanExporter | ||
AddExporter(exporter trace.SpanExporter) | ||
} | ||
|
||
type multiExporter struct { | ||
exporters []trace.SpanExporter | ||
} | ||
|
||
// NewMultiExporter creates a new multi exporter that forwards spans to multiple OTLP trace exporters. | ||
// It takes in one or more trace.SpanExporter instances and ensures that spans are sent to all of them. | ||
// This is useful when you need to send trace data to multiple backends or endpoints. | ||
func NewMultiExporter(exporters ...trace.SpanExporter) MultiExporter { | ||
return &multiExporter{ | ||
exporters: exporters, | ||
} | ||
} | ||
|
||
const defaultTimeout = 30 * time.Second | ||
|
||
// ExportSpans exports a batch of spans. | ||
func (m *multiExporter) ExportSpans(parentCtx context.Context, ss []trace.ReadOnlySpan) error { | ||
return m.doParallel(parentCtx, func(ctx context.Context, exporter trace.SpanExporter) error { | ||
return exporter.ExportSpans(ctx, ss) | ||
}) | ||
} | ||
|
||
func (m *multiExporter) doParallel(parentCtx context.Context, fn func(context.Context, trace.SpanExporter) error) error { | ||
ctx, cancel := context.WithTimeout(parentCtx, defaultTimeout) | ||
defer cancel() | ||
|
||
var wg sync.WaitGroup | ||
var errors []error | ||
var mu sync.Mutex | ||
|
||
wg.Add(len(m.exporters)) | ||
for _, exporter := range m.exporters { | ||
go func(exporter trace.SpanExporter) { | ||
defer wg.Done() | ||
err := fn(ctx, exporter) | ||
if err != nil { | ||
mu.Lock() | ||
errors = append(errors, fmt.Errorf("error in doMultiple: %w", err)) | ||
mu.Unlock() | ||
} | ||
}(exporter) | ||
} | ||
|
||
wg.Wait() | ||
if len(errors) > 0 { | ||
// nolint: wrapcheck | ||
return multierr.Combine(errors...) | ||
} | ||
|
||
return nil | ||
} | ||
Comment on lines
+32
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add tests to cover the missing lines in the The implementation of the However, static analysis hints indicate that some lines in the
Please add tests to cover these lines and ensure the behavior is thoroughly tested. Do you want me to generate the missing test cases or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
|
||
// Shutdown notifies the exporter of a pending halt to operations. | ||
func (m *multiExporter) Shutdown(ctx context.Context) error { | ||
return m.doParallel(ctx, func(ctx context.Context, exporter trace.SpanExporter) error { | ||
return exporter.Shutdown(ctx) | ||
}) | ||
} | ||
|
||
// AddExporter adds an exporter to the multi exporter. | ||
func (m *multiExporter) AddExporter(exporter trace.SpanExporter) { | ||
m.exporters = append(m.exporters, exporter) | ||
} | ||
|
||
var _ trace.SpanExporter = &multiExporter{} | ||
Comment on lines
+78
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add tests to cover the The implementation of the However, static analysis hints indicate that the lines in the
Please add tests to cover the Do you want me to generate the missing test cases or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable the
mnd
linter to detect magic numbers.The
mnd
linter is being added to the list of disabled linters, which contradicts the purpose of introducing it. To effectively detect and prevent the use of magic numbers in the codebase, themnd
linter should be enabled.Remove the following lines to enable the
mnd
linter:Committable suggestion