Skip to content

Commit

Permalink
adds gRPC server conn
Browse files Browse the repository at this point in the history
Signed-off-by: Afzal Ansari <[email protected]>
  • Loading branch information
afzal442 committed Jul 13, 2023
1 parent d429861 commit d705dad
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/jtracer/jtracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"log"
"net"
"sync"
"time"

Expand Down Expand Up @@ -95,7 +96,15 @@ func initBoth() (opentracing.Tracer, *sdktrace.TracerProvider) {
func newExporter(ctx context.Context) (sdktrace.SpanExporter, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
conn, err := grpc.DialContext(ctx, "otel_collector:4317",
server := grpc.NewServer()

lis, _ := net.Listen("tcp", ":0")

Check failure on line 101 in pkg/jtracer/jtracer.go

View workflow job for this annotation

GitHub Actions / unit-tests

G102: Binds to all network interfaces (gosec)
go func() {
err := server.Serve(lis)
log.Fatal("failed to create gRPC server connection: %w", err)

}()
conn, err := grpc.DialContext(ctx, lis.Addr().String(),
// Note the use of insecure transport here. TLS is recommended in production.
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
Expand Down

0 comments on commit d705dad

Please sign in to comment.