with changes suggested in PR
MODIFY
tracing/go.mod
tracing/go.mod
@@ -6,7 +6,6 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0
go.opentelemetry.io/otel v1.10.0
- go.opentelemetry.io/otel/exporters/jaeger v1.10.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0
go.opentelemetry.io/otel/sdk v1.10.0

MODIFY
tracing/go.sum
tracing/go.sum
@@ -202,7 +202,6 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
@@ -228,8 +227,6 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0/go.mod h1:
go.opentelemetry.io/otel v1.8.0/go.mod h1:2pkj+iMj0o03Y+cW6/m8Y4WkRdYN3AvCXCnzRMp9yvM=
go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4=
go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ=
-go.opentelemetry.io/otel/exporters/jaeger v1.10.0 h1:7W3aVVjEYayu/GOqOVF4mbTvnCuxF1wWu3eRxFGQXvw=
-go.opentelemetry.io/otel/exporters/jaeger v1.10.0/go.mod h1:n9IGyx0fgyXXZ/i0foLHNxtET9CzXHzZeKCucvRBFgA=
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 h1:TaB+1rQhddO1sF71MpZOZAuSPW1klK2M8XxfrBMfK7Y=
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0/go.mod h1:78XhIg8Ht9vR4tbLNUhXsiOnE2HOuSeKAiAcoVQEpOY=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0 h1:pDDYmo0QadUPal5fwXoY1pmMpFcdyhXOmL5drCrI3vU=

MODIFY
tracing/tracing.go
tracing/tracing.go
@@ -3,13 +3,11 @@ package tracing
import (
"context"
"fmt"
- "log"
"net/http"
"time"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel"
- "go.opentelemetry.io/otel/exporters/jaeger"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/propagation"
@@ -40,10 +38,10 @@ func (o addrOption) apply(opts *options) {
}
// OtlpGrpcExporter uses the otlptracegrpc modules and the otlptrace module to produce a new exporter at our default addr
-func OtlpGrpcExporter(ctx context.Context, opts ...Option) sdktrace.SpanExporter {
+func OtlpGrpcExporter(ctx context.Context, opts ...Option) (sdktrace.SpanExporter, error) {
- DefaultCollectorHost := "localhost"
- var defaultCollectorPort uint16 = 4317
+ const DefaultCollectorHost = "localhost"
+ const defaultCollectorPort uint16 = 4317
addr := fmt.Sprintf("%s:%d", DefaultCollectorHost, defaultCollectorPort)
options := options{
@@ -62,24 +60,12 @@ func OtlpGrpcExporter(ctx context.Context, opts ...Option) sdktrace.SpanExporter
spanExporter, err := otlptrace.New(ctx, otlpClient)
if err != nil {
- log.Fatal(err)
- //Is doing a fatal error here too risky? No easy way to bubble up errors from here to the app using this.
- //without making each of the WithXOption() takes an error as an arg as well.
- return nil
+ return nil, err
}
- return spanExporter
+ return spanExporter, nil
}
-func JaegerExporter() (spanExporter sdktrace.SpanExporter) {
- fmt.Println("Creating Jaeger Exporter")
- spanExporter, err := jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint("http://localhost:14268/api/traces")))
- if err != nil {
- log.Fatal("Error creating Jaeger Exporter")
- }
- return
-}
-
// InstrumentedTransport returns the transport to use in client requests.
// It takes in a transport to wrap, e.g. http.DefaultTransport, and the request
// context value to pull the span name out from.

with changes suggested in PR