| 566 | } |
| 567 | |
| 568 | func (ed *expectedData) newServerTrailerEntry(client bool, rpcID, inRPCID uint64, stErr error) *binlogpb.GrpcLogEntry { |
| 569 | logger := binlogpb.GrpcLogEntry_LOGGER_SERVER |
| 570 | var peer *binlogpb.Address |
| 571 | if client { |
| 572 | logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT |
| 573 | peer = &binlogpb.Address{ |
| 574 | Address: ed.te.srvIP.String(), |
| 575 | IpPort: uint32(ed.te.srvPort), |
| 576 | } |
| 577 | if ed.te.srvIP.Is4() { |
| 578 | peer.Type = binlogpb.Address_TYPE_IPV4 |
| 579 | } else { |
| 580 | peer.Type = binlogpb.Address_TYPE_IPV6 |
| 581 | } |
| 582 | } |
| 583 | st, ok := status.FromError(stErr) |
| 584 | if !ok { |
| 585 | grpclogLogger.Info("binarylogging: error in trailer is not a status error") |
| 586 | } |
| 587 | stProto := st.Proto() |
| 588 | var ( |
| 589 | detailsBytes []byte |
| 590 | err error |
| 591 | ) |
| 592 | if stProto != nil && len(stProto.Details) != 0 { |
| 593 | detailsBytes, err = proto.Marshal(stProto) |
| 594 | if err != nil { |
| 595 | grpclogLogger.Infof("binarylogging: failed to marshal status proto: %v", err) |
| 596 | } |
| 597 | } |
| 598 | return &binlogpb.GrpcLogEntry{ |
| 599 | Timestamp: nil, |
| 600 | CallId: rpcID, |
| 601 | SequenceIdWithinCall: inRPCID, |
| 602 | Type: binlogpb.GrpcLogEntry_EVENT_TYPE_SERVER_TRAILER, |
| 603 | Logger: logger, |
| 604 | Payload: &binlogpb.GrpcLogEntry_Trailer{ |
| 605 | Trailer: &binlogpb.Trailer{ |
| 606 | Metadata: iblog.MdToMetadataProto(testTrailerMetadata), |
| 607 | // st will be nil if err was not a status error, but nil is ok. |
| 608 | StatusCode: uint32(st.Code()), |
| 609 | StatusMessage: st.Message(), |
| 610 | StatusDetails: detailsBytes, |
| 611 | }, |
| 612 | }, |
| 613 | Peer: peer, |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | func (ed *expectedData) newCancelEntry(rpcID, inRPCID uint64) *binlogpb.GrpcLogEntry { |
| 618 | return &binlogpb.GrpcLogEntry{ |