Class MetricsCollectingMarshaller<T>

  • All Implemented Interfaces:
    Marshaller<T>

    public class MetricsCollectingMarshaller<T>
    extends Object
    implements Marshaller<T>
    A Marshaller which delegates to another marshaller, whilst collecting metrics about the execution and streaming of that delegate.

    Metrics will onlty be collected if the executiuon and streaming do not throw exceptions. Exception conditions are likely to skew the metrics, and so will not be recorded.

    Since:
    5.8
    • Method Detail

      • forMarshaller

        public static <T> @NonNull Marshaller<T> forMarshaller​(MarshallerMetricsCollector metricsCollector,
                                                               Marshaller<T> marshaller)
        Creates an instrumented wrapper around another Marshaller which will gather execution metrics
        Type Parameters:
        T - The type of the values being marshalled
        Parameters:
        metricsCollector - The collector to use
        marshaller - The marshaller to be instrumented
        Returns:
        The instrumented Marshaller
      • marshal

        public Streamable marshal​(T object,
                                  @Nullable ConversionContext conversionContext)
                           throws XhtmlException
        Description copied from interface: Marshaller
        Marshals an object to XML.
        Specified by:
        marshal in interface Marshaller<T>
        Parameters:
        object - object to marshal
        conversionContext - the conversion context
        Returns:
        the XML representation of the object
        Throws:
        XhtmlException - if an error occurs during marshalling