MCPcopy
hub / github.com/grpc/grpc-go / main

Function main

examples/features/observability/client/main.go:44–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42)
43
44func main() {
45 // Turn on global telemetry for the whole binary. If a configuration is
46 // specified, any created gRPC Client Conn's or Servers will emit telemetry
47 // data according the configuration.
48 ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
49 defer cancel()
50 err := observability.Start(ctx)
51 if err != nil {
52 log.Fatalf("observability.Start() failed: %v", err)
53 }
54 defer observability.End()
55
56 flag.Parse()
57 // Set up a connection to the server.
58 conn, err := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
59 if err != nil {
60 log.Fatalf("did not connect: %v", err)
61 }
62 defer conn.Close()
63 c := pb.NewGreeterClient(conn)
64
65 // Contact the server and print out its response.
66 r, err := c.SayHello(ctx, &pb.HelloRequest{Name: *name})
67 if err != nil {
68 log.Fatalf("could not greet: %v", err)
69 }
70 log.Printf("Greeting: %s", r.GetMessage())
71}

Callers

nothing calls this directly

Calls 11

SayHelloMethod · 0.95
StartFunction · 0.92
EndFunction · 0.92
NewClientFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
FatalfMethod · 0.65
ParseMethod · 0.65
CloseMethod · 0.65
PrintfMethod · 0.65
GetMessageMethod · 0.45

Tested by

no test coverage detected