code: protected final <T> void addMetadata(MetadataKey<T> key, T value) {
      if (metadata == null) {
        metadata = new MutableMetadata();
      }
      metadata.addValue(key, value);
    }
docs: Adds the given key/value pair to this logging context. If the key cannot be repeated, and
  there is already a value for the key in the metadata, then the existing value is replaced,
  otherwise the value is added at the end of the metadata.
  
  @param key the metadata key (see {@link LogData}).
  @param value the metadata value.