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

Function setupObservabilitySystemWithConfig

gcp/observability/logging_test.go:105–123  ·  view source on GitHub ↗

setupObservabilitySystemWithConfig sets up the observability system with the specified config, and returns a function which cleans up the observability system.

(cfg *config)

Source from the content-addressed store, hash-verified

103// specified config, and returns a function which cleans up the observability
104// system.
105func setupObservabilitySystemWithConfig(cfg *config) (func(), error) {
106 validConfigJSON, err := json.Marshal(cfg)
107 if err != nil {
108 return nil, fmt.Errorf("failed to convert config to JSON: %v", err)
109 }
110 oldObservabilityConfig := envconfig.ObservabilityConfig
111 envconfig.ObservabilityConfig = string(validConfigJSON)
112 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
113 defer cancel()
114 err = Start(ctx)
115 cleanup := func() {
116 End()
117 envconfig.ObservabilityConfig = oldObservabilityConfig
118 }
119 if err != nil {
120 return cleanup, fmt.Errorf("error in Start: %v", err)
121 }
122 return cleanup, nil
123}
124
125// TestClientRPCEventsLogAll tests the observability system configured with a
126// client RPC event that logs every call. It performs a Unary and Bidirectional

Calls 4

StartFunction · 0.85
EndFunction · 0.70
MarshalMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected