-
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
[SLT-141] feat(metrics): multiple exports #3099
Changes from 21 commits
7ba8a43
9632578
c762c4c
3c15801
829812b
e831fe9
68def3c
51284b9
6bcd3ab
38e924b
f8a2048
c163704
89e996b
780b4c5
1d82704
08fa2a4
1c63c19
d08315e
1d670a0
d6ee535
48f2afc
4db816f
3923d42
bad4071
f8e240d
a19300c
bfd1d7b
d5e69f7
ceeddbc
4c6825a
732f5fa
8a04f9e
0e3a5ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
package metrics | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||||||||||
"context" | ||||||||||||||||||||||||||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
"go.opentelemetry.io/otel/sdk/trace" | ||||||||||||||||||||||||||||||||||||||||||||||
tracesdk "go.opentelemetry.io/otel/sdk/trace" | ||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// MultiExporter is an interface that allows exporting spans to multiple OTLP trace exporters. | ||||||||||||||||||||||||||||||||||||||||||||||
type MultiExporter interface { | ||||||||||||||||||||||||||||||||||||||||||||||
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. should have a test |
||||||||||||||||||||||||||||||||||||||||||||||
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, | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// ExportSpans exports a batch of spans. | ||||||||||||||||||||||||||||||||||||||||||||||
func (m *multiExporter) ExportSpans(ctx context.Context, ss []trace.ReadOnlySpan) error { | ||||||||||||||||||||||||||||||||||||||||||||||
for _, exporter := range m.exporters { | ||||||||||||||||||||||||||||||||||||||||||||||
err := exporter.ExportSpans(ctx, ss) | ||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||
return fmt.Errorf("could not export spans: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||
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. Consider collecting errors from all exporters before returning. The current implementation of It would be better to collect errors from all exporters and return a combined error. This way, all exporters will have a chance to receive the spans, and the caller will be informed of all the errors that occurred. Apply this diff to collect errors from all exporters: func (m *multiExporter) ExportSpans(ctx context.Context, ss []tracesdk.ReadOnlySpan) error {
+ var errs []error
for _, exporter := range m.exporters {
err := exporter.ExportSpans(ctx, ss)
if err != nil {
- return fmt.Errorf("could not export spans: %w", err)
+ errs = append(errs, err)
}
}
+ if len(errs) > 0 {
+ return fmt.Errorf("could not export spans to some exporters: %v", errs)
+ }
return nil
} Committable suggestion
Suggested change
ToolsGitHub Check: codecov/patch
|
||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// Shutdown notifies the exporter of a pending halt to operations. | ||||||||||||||||||||||||||||||||||||||||||||||
func (m *multiExporter) Shutdown(ctx context.Context) error { | ||||||||||||||||||||||||||||||||||||||||||||||
for _, exporter := range m.exporters { | ||||||||||||||||||||||||||||||||||||||||||||||
err := exporter.Shutdown(ctx) | ||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||
return fmt.Errorf("could not stop exporter: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
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. Method Implementation Review: Shutdown Similar to Consider implementing a similar error aggregation strategy as suggested for - if err != nil {
- return fmt.Errorf("could not stop exporter: %w", err)
- }
+ if err != nil {
+ // Collect errors from all exporters
+ allErrors = append(allErrors, err)
+ }
+ }
+ if len(allErrors) > 0 {
+ return fmt.Errorf("could not stop some exporters: %v", allErrors)
+ }
ToolsGitHub Check: codecov/patch
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. Consider collecting errors from all exporters before returning. Similar to the As suggested in the existing review comments, it would be better to collect errors from all exporters and return a combined error. This way, all exporters will be attempted to be shut down, and the caller will be informed of all the errors that occurred. Apply this diff to collect errors from all exporters: func (m *multiExporter) Shutdown(ctx context.Context) error {
+ var errs []error
for _, exporter := range m.exporters {
err := exporter.Shutdown(ctx)
if err != nil {
- return fmt.Errorf("could not stop exporter: %w", err)
+ errs = append(errs, err)
}
}
+ if len(errs) > 0 {
+ return fmt.Errorf("could not stop some exporters: %v", errs)
+ }
return nil
} Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// AddExporter adds an exporter to the multi exporter. | ||||||||||||||||||||||||||||||||||||||||||||||
func (m *multiExporter) AddExporter(exporter trace.SpanExporter) { | ||||||||||||||||||||||||||||||||||||||||||||||
m.exporters = append(m.exporters, exporter) | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
var _ tracesdk.SpanExporter = &multiExporter{} | ||||||||||||||||||||||||||||||||||||||||||||||
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. Ensure test coverage for multi-exporter logic. The introduction of the multi-exporter logic is a significant enhancement. However, static analysis indicates that several lines in the It's crucial to ensure that the multi-exporter functionality is covered by unit tests to verify its behavior under various scenarios, especially error handling. Consider adding unit tests to cover these scenarios to ensure robust functionality verification. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package metrics_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/synapsecns/sanguine/core/metrics" | ||
sdktrace "go.opentelemetry.io/otel/sdk/trace" | ||
"go.opentelemetry.io/otel/sdk/trace/tracetest" | ||
) | ||
|
||
func TestMultiExporter(t *testing.T) { | ||
// Create in-memory exporters | ||
exporter1 := tracetest.NewInMemoryExporter() | ||
exporter2 := tracetest.NewInMemoryExporter() | ||
|
||
// Create multi-exporter | ||
multiExporter := metrics.NewMultiExporter(exporter1, exporter2) | ||
|
||
// Create test spans | ||
spans := []sdktrace.ReadOnlySpan{ | ||
tracetest.SpanStub{}.Snapshot(), | ||
tracetest.SpanStub{}.Snapshot(), | ||
} | ||
|
||
// Test ExportSpans | ||
err := multiExporter.ExportSpans(context.Background(), spans) | ||
require.NoError(t, err) | ||
|
||
// Verify that spans were exported to both exporters | ||
assert.Equal(t, 2, len(exporter1.GetSpans())) | ||
assert.Equal(t, 2, len(exporter2.GetSpans())) | ||
|
||
// Test Shutdown | ||
err = multiExporter.Shutdown(context.Background()) | ||
require.NoError(t, err) | ||
|
||
// Verify that both exporters were shut down | ||
// Note: InMemoryExporter doesn't have a Stopped() method, so we can't check this directly | ||
// Instead, we can try to export spans again and check for an error | ||
err = multiExporter.ExportSpans(context.Background(), spans) | ||
assert.NoError(t, err, "Expected no error after shutdown") | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,15 +3,16 @@ | |||||
import ( | ||||||
"context" | ||||||
"fmt" | ||||||
"google.golang.org/grpc/credentials" | ||||||
"strings" | ||||||
"time" | ||||||
|
||||||
"github.com/synapsecns/sanguine/core" | ||||||
"github.com/synapsecns/sanguine/core/config" | ||||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace" | ||||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" | ||||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" | ||||||
tracesdk "go.opentelemetry.io/otel/sdk/trace" | ||||||
"os" | ||||||
"strings" | ||||||
"time" | ||||||
) | ||||||
|
||||||
type otlpHandler struct { | ||||||
|
@@ -28,23 +29,45 @@ | |||||
} | ||||||
|
||||||
func (n *otlpHandler) Start(ctx context.Context) (err error) { | ||||||
var client otlptrace.Client | ||||||
transport := transportFromString(core.GetEnv(otlpTransportEnv, otlpTransportGRPC.String())) | ||||||
switch transport { | ||||||
case otlpTransportHTTP: | ||||||
client = otlptracehttp.NewClient() | ||||||
case otlpTransportGRPC: | ||||||
client = otlptracegrpc.NewClient() | ||||||
default: | ||||||
return fmt.Errorf("unknown transport type: %s", os.Getenv(otlpTransportEnv)) | ||||||
} | ||||||
var exporters []tracesdk.SpanExporter | ||||||
|
||||||
exporter, err := otlptrace.New(ctx, client) | ||||||
primaryExporter, err := makeOTLPExporter(ctx, "") | ||||||
if err != nil { | ||||||
return fmt.Errorf("failed to create otlp exporter: %w", err) | ||||||
return fmt.Errorf("could not create default client: %w", err) | ||||||
} | ||||||
exporters = append(exporters, primaryExporter) | ||||||
|
||||||
// Loop to create additional exporters | ||||||
for i := 1; ; i++ { | ||||||
envSuffix := fmt.Sprintf("_%d", i) | ||||||
// if this is empty we can assume no config exists at all. | ||||||
endpointEnv := otelEndpointEnv + envSuffix | ||||||
|
||||||
// no more transports to add. | ||||||
if !core.HasEnv(endpointEnv) { | ||||||
break | ||||||
} | ||||||
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. Tip Codebase Verification Add Tests for Error Handling in Multi-Exporter Logic The current test
Analysis chainEnsure test coverage for the multi-exporter logic and error handling scenarios. Static analysis tools have reported that some lines in the
It's important to add unit tests to cover these scenarios and ensure the robustness of the multi-exporter logic and error handling. Also applies to: 55-55, 58-58 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify test coverage for the multi-exporter logic and error handling scenarios.
# Test: Search for tests covering the multi-exporter logic. Expect: At least one test.
rg --type go $'func Test.*MultiExporter'
# Test: Search for tests covering the error handling scenarios. Expect: At least one test.
rg --type go $'func Test.*ExporterCreationError'
Length of output: 165 Script: #!/bin/bash
# Search for the implementation of the TestMultiExporter function to check its coverage.
rg --type go -A 20 'func TestMultiExporter' core/metrics/multiexporter_test.go
# Search for other test functions in the same file to see if they cover error handling.
rg --type go 'func Test' core/metrics/multiexporter_test.go
Length of output: 825 ToolsGitHub Check: codecov/patch
|
||||||
|
||||||
exporter, err := makeOTLPExporter(ctx, envSuffix) | ||||||
if err != nil { | ||||||
return fmt.Errorf("could not create exporter %d: %v", i, err) | ||||||
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. Address the non-wrapping format verb for Static analysis tools have reported the following issue:
Please use -return fmt.Errorf("could not create exporter %d: %v", i, err)
+return fmt.Errorf("could not create exporter %d: %w", i, err) Committable suggestion
Suggested change
ToolsGitHub Check: Lint (core)
|
||||||
} | ||||||
|
||||||
exporters = append(exporters, exporter) | ||||||
} | ||||||
|
||||||
n.baseHandler = newBaseHandler(n.buildInfo, tracesdk.WithBatcher(exporter, tracesdk.WithMaxQueueSize(1000000), tracesdk.WithMaxExportBatchSize(2000)), tracesdk.WithSampler(tracesdk.AlwaysSample())) | ||||||
// create the multi-exporter with all the exporters | ||||||
multiExporter := NewMultiExporter(exporters...) | ||||||
|
||||||
n.baseHandler = newBaseHandler( | ||||||
n.buildInfo, | ||||||
tracesdk.WithBatcher( | ||||||
multiExporter, | ||||||
tracesdk.WithMaxQueueSize(defaultMaxQueueSize), | ||||||
tracesdk.WithMaxExportBatchSize(defaultMaxExportBatch), | ||||||
), | ||||||
tracesdk.WithSampler(tracesdk.AlwaysSample()), | ||||||
) | ||||||
|
||||||
// start the new parent | ||||||
err = n.baseHandler.Start(ctx) | ||||||
|
@@ -90,7 +113,9 @@ | |||||
} | ||||||
|
||||||
const ( | ||||||
otlpTransportEnv = "OTEL_EXPORTER_OTLP_TRANSPORT" | ||||||
otelEndpointEnv = "OTEL_EXPORTER_OTLP_ENDPOINT" | ||||||
otelTransportEnv = "OTEL_EXPORTER_OTLP_TRANSPORT" | ||||||
otelInsecureEvn = "INSECURE_MODE" | ||||||
) | ||||||
|
||||||
//go:generate go run golang.org/x/tools/cmd/stringer -type=otlpTransportType -linecomment | ||||||
|
@@ -101,6 +126,94 @@ | |||||
otlpTransportGRPC // grpc | ||||||
) | ||||||
|
||||||
// getEnvSuffix returns the value of an environment variable with a suffix. | ||||||
func getEnvSuffix(env, suffix, defaultRet string) string { | ||||||
newEnv := env + suffix | ||||||
return core.GetEnv(newEnv, defaultRet) | ||||||
} | ||||||
|
||||||
// makeOTLPTrace creates a new OTLP client based on the transport type and url. | ||||||
func makeOTLPExporter(ctx context.Context, envSuffix string) (*otlptrace.Exporter, error) { | ||||||
transport := transportFromString(getEnvSuffix(otelTransportEnv, envSuffix, otlpTransportHTTP.String())) | ||||||
url := getEnvSuffix(otelEndpointEnv, envSuffix, "") | ||||||
insecure := getEnvSuffix(otelInsecureEvn, envSuffix, "false") | ||||||
|
||||||
if url == "" { | ||||||
return nil, fmt.Errorf("could not create exporter: url is empty") | ||||||
} | ||||||
|
||||||
oteltraceClient, err := buildClientFromTransport( | ||||||
transport, | ||||||
WithURL(url), | ||||||
WithInsecure(insecure == "true"), | ||||||
) | ||||||
if err != nil { | ||||||
return nil, fmt.Errorf("could not create client from transport: %w", err) | ||||||
} | ||||||
|
||||||
exporter, err := otlptrace.New(ctx, oteltraceClient) | ||||||
if err != nil { | ||||||
return nil, fmt.Errorf("ocould not create client: %w", err) | ||||||
} | ||||||
return exporter, nil | ||||||
} | ||||||
|
||||||
// buildClientFromTransport creates a new OTLP client based on the transport type and url. | ||||||
func buildClientFromTransport(transport otlpTransportType, options ...Option) (otlptrace.Client, error) { | ||||||
to := transportOptions{} | ||||||
for _, option := range options { | ||||||
if err := option(&to); err != nil { | ||||||
return nil, fmt.Errorf("could not apply option: %w", err) | ||||||
} | ||||||
} | ||||||
|
||||||
// TODO: make sure url is validated | ||||||
|
||||||
switch transport { | ||||||
case otlpTransportHTTP: | ||||||
return otlptracehttp.NewClient(to.httpOptions...), nil | ||||||
case otlpTransportGRPC: | ||||||
return otlptracegrpc.NewClient(to.grpcOptions...), nil | ||||||
default: | ||||||
return nil, fmt.Errorf("unknown transport type: %s", transport.String()) | ||||||
Comment on lines
+194
to
+195
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. Tip Codebase Verification Add unit tests for error handling in The error handling for unknown transport types in the
Analysis chainImprove error handling in the Static analysis tools have reported that the error handling for unknown transport types (lines 198-199) is not covered by tests. It's important to add unit tests to cover this scenario and ensure the robustness of the function. Consider adding a test case that provides an invalid transport type and verifies that an error is returned. Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify test coverage for the error handling of unknown transport types.
# Test: Search for tests covering the error handling of unknown transport types. Expect: At least one test.
rg --type go $'func Test.*UnknownTransportType'
Length of output: 48 Script: #!/bin/bash
# Description: Search for test cases involving the buildClientFromTransport function to check error handling coverage.
# Find the definition of the buildClientFromTransport function to understand its location and context.
ast-grep --lang go --pattern 'func buildClientFromTransport($_) $_ { $$$ }'
# Search for test functions that call buildClientFromTransport.
rg --type go 'buildClientFromTransport'
Length of output: 428 Script: #!/bin/bash
# Description: Search for Go test files that might indirectly test the buildClientFromTransport function.
# List all Go test files in the repository.
fd --type f --extension go --exec basename {} \; | grep '_test.go'
# Search for any references to the buildClientFromTransport function in these test files.
rg --type go 'buildClientFromTransport' --glob '*_test.go'
Length of output: 5242 ToolsGitHub Check: codecov/patch
|
||||||
} | ||||||
} | ||||||
Comment on lines
+178
to
+197
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. The new Separating the client creation logic based on the transport type makes the code modular and extensible. The use of a switch statement makes it easy to add support for new transport types in the future, and applying the provided options allows for flexible configuration of the transport client. However, static analysis tools have reported a lack of test coverage for certain lines in this function. Please add unit tests to cover the following scenarios:
This will ensure that all code paths in the function are properly tested. ToolsGitHub Check: codecov/patch
|
||||||
|
||||||
type transportOptions struct { | ||||||
// httpOptions are the options for the http transport. | ||||||
httpOptions []otlptracehttp.Option | ||||||
// grpcOptions are the options for the grpc transport. | ||||||
grpcOptions []otlptracegrpc.Option | ||||||
} | ||||||
|
||||||
// Option Each option appends the correspond option for both http and grpc options. | ||||||
// only one will be used in creating the actual client. | ||||||
type Option func(*transportOptions) error | ||||||
|
||||||
func WithURL(url string) Option { | ||||||
return func(o *transportOptions) error { | ||||||
o.httpOptions = append(o.httpOptions, otlptracehttp.WithEndpointURL(url)) | ||||||
o.grpcOptions = append(o.grpcOptions, otlptracegrpc.WithEndpointURL(url)) | ||||||
|
||||||
return nil | ||||||
} | ||||||
} | ||||||
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. The new option functions Providing these option functions allows for clean and extensible configuration of the OTLP exporter. Exporting them enables flexibility in configuring the exporter from other packages. The functions modify the However, static analysis tools have reported that these functions should have comments or be unexported. Please add comments for the exported functions to improve code documentation and maintainability. For example: // WithURL sets the endpoint URL for the OTLP exporter.
func WithURL(url string) Option {
// ...
}
// WithInsecure enables or disables secure connection for the OTLP exporter.
func WithInsecure(isInsecure bool) Option {
// ...
}
// WithHeaders sets the headers for the OTLP exporter.
func WithHeaders(headers string) Option {
// ...
} Also applies to: 223-241, 243-250 ToolsGitHub Check: Lint (core)
|
||||||
|
||||||
func WithInsecure(isInsecure bool) Option { | ||||||
return func(o *transportOptions) error { | ||||||
if isInsecure { | ||||||
o.httpOptions = append(o.httpOptions, otlptracehttp.WithInsecure()) | ||||||
o.grpcOptions = append(o.grpcOptions, otlptracegrpc.WithInsecure()) | ||||||
} else { | ||||||
tlsCreds := credentials.NewClientTLSFromCert(nil, "") | ||||||
// note: you do not need to specify the tls creds for http, this happens automatically when https:// is used as the protocol scheme. | ||||||
o.grpcOptions = append(o.grpcOptions, otlptracegrpc.WithTLSCredentials(tlsCreds)) | ||||||
} | ||||||
|
||||||
return nil | ||||||
} | ||||||
} | ||||||
|
||||||
// transportFromString converts a string to a transport type. | ||||||
// Defaults to http if the string is not recognized. | ||||||
func transportFromString(transport string) otlpTransportType { | ||||||
|
@@ -114,3 +227,8 @@ | |||||
// (see uber's go stye guide for details) | ||||||
return otlpTransportType(0) | ||||||
} | ||||||
|
||||||
const ( | ||||||
defaultMaxQueueSize = 1000000 | ||||||
defaultMaxExportBatch = 2000 | ||||||
) |
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.
Remove the duplicate import of
go.opentelemetry.io/otel/sdk/trace
.The
go.opentelemetry.io/otel/sdk/trace
package is being imported twice, once astrace
and once astracesdk
. This is unnecessary and can cause confusion.Apply this diff to remove the duplicate import:
import ( "context" "fmt" - "go.opentelemetry.io/otel/sdk/trace" tracesdk "go.opentelemetry.io/otel/sdk/trace" )
Committable suggestion
Tools
GitHub Check: Lint (core)