Thanks for the response. I tried MetadataMap<>::Log(), but it didn't iterate over the peer string either (and I verified that the peer string is present by calling batch.get_pointer(grpc_core::PeerString()). I then thought perhaps MetadataMap<>::ForEach would do the trick, since its comment says "Like Encode, but also visit the non-encodable fields". But, then I noticed that Log uses ForEach, so the comment for ForEach must be stale.
Any other suggestions? -John- On Thursday, October 12, 2023 at 4:22:34 PM UTC-7 Craig Tiller wrote: > (take a look at MetdataMap<>::Log() for an API to get a textual > representation out of *all* the things) > > On Thu, Oct 12, 2023 at 4:21 PM Craig Tiller <cti...@google.com> wrote: > >> `PeerString` (and some others) are Non-encodable metadata: they're >> getting carried around there because they make sense at the same times as >> metadata, but they don't go out on the wire. >> So... being non-encodable Encode() skips them. >> >> There's some logging helpers that will catch them, so they show up as >> debug text, but they're not directly iterable right now. >> >> On Thu, Oct 12, 2023 at 3:53 PM John Ousterhout <john.ou...@gmail.com> >> wrote: >> >>> In the Homa module for gRPC there are a few places where the code needs >>> to iterate over all of the values in a grpc_metadata_batch, but there are >>> currently cases where my code isn't seeing all of the values. Here is an >>> example from my code that attempts to log all of the values in a batch. The >>> code invokes the Encode method, passing it a MetataLogger object: >>> >>> grpc_metadata_batch *batch; >>> MetadataLogger logger(separator); >>> batch->Encode(&logger); >>> >>> Here is the definition of the logger object: >>> >>> class MetadataLogger { >>> public: >>> MetadataLogger(const char *separator) : separator(separator) {} >>> >>> void Encode(const grpc_core::Slice &key, const grpc_core::Slice >>> &value) >>> { >>> uint32_t keyLength = key.length(); >>> uint32_t valueLength = value.length(); >>> Mock::logPrintf(separator, "metadata %.*s: %.*s", keyLength, >>> key.data(), valueLength, value.data()); >>> } >>> >>> template <typename MetadataTrait> >>> void Encode(MetadataTrait, const grpc_core::Slice &value) >>> { >>> absl::string_view key = MetadataTrait::key(); >>> uint32_t keyLength = key.length(); >>> uint32_t valueLength = value.length(); >>> Mock::logPrintf(separator, "metadata %.*s: %.*s", keyLength, >>> key.data(), valueLength, value.data()); >>> } >>> >>> template <typename MetadataTrait> >>> void Encode(MetadataTrait, const typename MetadataTrait::ValueType& >>> value) >>> { >>> absl::string_view key = MetadataTrait::key(); >>> uint32_t keyLength = key.length(); >>> const grpc_core::Slice& slice = >>> grpc_core::MetadataValueAsSlice<MetadataTrait>(value); >>> uint32_t valueLength = slice.length(); >>> Mock::logPrintf(separator, "metadata %.*s: %.*s", keyLength, >>> key.data(), valueLength, slice.data()); >>> } >>> >>> const char *separator; >>> }; >>> >>> The class has 3 different Encode methods, intended to catch all of the >>> different variants of metadata. However, it doesn't seem to be catching >>> absolutely all of them. In particular, if I set the PeerString value, where >>> the key is grpc_core::PeerString(), none of these methods gets invoked. Are >>> there other variants of Encode that I need to define to catch this key? >>> What do I need to do to be sure I'm catching absolutely all of the metadata >>> entries? Is there a better way I should be doing this? >>> >>> Thanks in advance for any help you can provide. >>> >>> -John- >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "grpc.io" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to grpc-io+u...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/grpc-io/f14fe33f-5f76-4f6a-9066-b9c920ed9835n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/grpc-io/f14fe33f-5f76-4f6a-9066-b9c920ed9835n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/68277d44-9d1f-48df-b973-fff314e4feaen%40googlegroups.com.