otel: fix initialization / error-handling (#10717)
* If there's no `otel` key (or the value is `null`) in the config, don't return an error * Propagate error from the exporter instead of panicking Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
parent
2efea2e9f5
commit
ff3984e609
@ -94,6 +94,10 @@ func ConfigFromDockerContext(st store.Store, name string) (OTLPConfig, error) {
|
|||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
otelCfg = m[otelConfigFieldName]
|
otelCfg = m[otelConfigFieldName]
|
||||||
}
|
}
|
||||||
|
if otelCfg == nil {
|
||||||
|
return OTLPConfig{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
otelMap, ok := otelCfg.(map[string]interface{})
|
otelMap, ok := otelCfg.(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return OTLPConfig{}, fmt.Errorf(
|
return OTLPConfig{}, fmt.Errorf(
|
||||||
|
@ -18,7 +18,6 @@ package tracing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||||
@ -36,10 +35,7 @@ func (m MuxExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlyS
|
|||||||
return exporter.ExportSpans(ctx, spans)
|
return exporter.ExportSpans(ctx, spans)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := eg.Wait(); err != nil {
|
return eg.Wait()
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m MuxExporter) Shutdown(ctx context.Context) error {
|
func (m MuxExporter) Shutdown(ctx context.Context) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user