Skip to content

Commit

Permalink
improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dhontecillas committed May 15, 2024
1 parent cf6b5d0 commit f01fb8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions exporter/otelcollector/otelcollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ func httpExporterWithOptions(ctx context.Context, cfg config.OTLPExporter,
tOpts = append(tOpts, otlptracehttp.WithEndpoint(endpoint))
exporter, err := otlptracehttp.New(ctx, tOpts...)
if err != nil {
return nil, errors.New("cannot create http trace exporter")
return nil, errors.New("cannot create http trace exporter:" + err.Error())
}

mOpts = append(mOpts, otlpmetrichttp.WithEndpoint(endpoint))
metricExporter, err := otlpmetrichttp.New(ctx, mOpts...)
if err != nil {
return nil, errors.New("cannot create http metric exporter")
return nil, errors.New("cannot create http metric exporter:" + err.Error())
}

return &OtelCollector{
Expand Down
12 changes: 12 additions & 0 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,23 @@ func (s *OTELState) Tracer() trace.Tracer {

// Meter returns a meter to create metric instruments.
func (s *OTELState) Meter() metric.Meter {
if s == nil {
return nil
}
return s.meter
}

func (s *OTELState) MeterProvider() metric.MeterProvider {
if s == nil {
return nil
}
return s.meterProvider
}

func (s *OTELState) TracerProvider() trace.TracerProvider {
if s == nil {
return nil
}
return s.tracerProvider
}

Expand All @@ -153,6 +162,9 @@ func (s *OTELState) Propagator() propagation.TextMapPropagator {
// Shutdown performs the clean shutdown to be able to
// flush pending traces and / or metrics.
func (s *OTELState) Shutdown(ctx context.Context) {
if s == nil {
return
}
if s.sdkTracerProvider != nil {
s.sdkTracerProvider.Shutdown(ctx)
}
Expand Down

0 comments on commit f01fb8f

Please sign in to comment.