Skip to content

Instantly share code, notes, and snippets.

@TonPC64
Created February 24, 2022 14:46

Revisions

  1. TonPC64 created this gist Feb 24, 2022.
    11 changes: 11 additions & 0 deletions grpc-function-sayhello.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    func (s *server) SayHello(ctx context.Context, in *api.HelloRequest) (*api.HelloResponse, error) {
    tracer := otel.GetTracerProvider().Tracer("webserver-grpc")
    _, span := tracer.Start(ctx, "SayHello-span")
    defer span.End()

    fmt.Println(ctx)
    log.Printf("Received: %v\n", in.GetGreeting())
    time.Sleep(50 * time.Millisecond)

    return &api.HelloResponse{Reply: "Hello " + in.Greeting}, nil
    }