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

Function determineMethod

stats/opentelemetry/client_metrics.go:106–113  ·  view source on GitHub ↗

determineMethod determines the method to record attributes with. This will be "other" if StaticMethod isn't specified or if method filter is set and specifies, the method name as is otherwise.

(method string, opts ...grpc.CallOption)

Source from the content-addressed store, hash-verified

104// "other" if StaticMethod isn't specified or if method filter is set and
105// specifies, the method name as is otherwise.
106func determineMethod(method string, opts ...grpc.CallOption) string {
107 for _, opt := range opts {
108 if _, ok := opt.(grpc.StaticMethodCallOption); ok {
109 return removeLeadingSlash(method)
110 }
111 }
112 return "other"
113}
114
115func (h *clientMetricsHandler) streamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
116 ctx, ci := getOrCreateCallInfo(ctx, cc, method, opts...)

Callers 1

getOrCreateCallInfoFunction · 0.85

Calls 1

removeLeadingSlashFunction · 0.70

Tested by

no test coverage detected