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

Method toProto

internal/binarylog/method_logger.go:338–374  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

336}
337
338func (c *ServerTrailer) toProto() *binlogpb.GrpcLogEntry {
339 st, ok := status.FromError(c.Err)
340 if !ok {
341 grpclogLogger.Info("binarylogging: error in trailer is not a status error")
342 }
343 var (
344 detailsBytes []byte
345 err error
346 )
347 stProto := st.Proto()
348 if stProto != nil && len(stProto.Details) != 0 {
349 detailsBytes, err = proto.Marshal(stProto)
350 if err != nil {
351 grpclogLogger.Infof("binarylogging: failed to marshal status proto: %v", err)
352 }
353 }
354 ret := &binlogpb.GrpcLogEntry{
355 Type: binlogpb.GrpcLogEntry_EVENT_TYPE_SERVER_TRAILER,
356 Payload: &binlogpb.GrpcLogEntry_Trailer{
357 Trailer: &binlogpb.Trailer{
358 Metadata: mdToMetadataProto(c.Trailer),
359 StatusCode: uint32(st.Code()),
360 StatusMessage: st.Message(),
361 StatusDetails: detailsBytes,
362 },
363 },
364 }
365 if c.OnClientSide {
366 ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT
367 } else {
368 ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER
369 }
370 if c.PeerAddr != nil {
371 ret.Peer = addrToProto(c.PeerAddr)
372 }
373 return ret
374}
375
376// Cancel configs the binary log entry to be a Cancel entry.
377type Cancel struct {

Callers

nothing calls this directly

Calls 9

FromErrorFunction · 0.92
mdToMetadataProtoFunction · 0.85
ProtoMethod · 0.80
CodeMethod · 0.80
MessageMethod · 0.80
addrToProtoFunction · 0.70
InfoMethod · 0.65
MarshalMethod · 0.65
InfofMethod · 0.65

Tested by

no test coverage detected