## SoupMessageMetrics

SoupMessageMetrics — Message metrics

## Functions

SoupMessageMetrics * | soup_message_metrics_copy ()
void | soup_message_metrics_free ()
guint64 | soup_message_metrics_get_fetch_start ()
guint64 | soup_message_metrics_get_dns_start ()
guint64 | soup_message_metrics_get_dns_end ()
guint64 | soup_message_metrics_get_connect_start ()
guint64 | soup_message_metrics_get_connect_end ()
guint64 | soup_message_metrics_get_tls_start ()
guint64 | soup_message_metrics_get_request_start ()
guint64 | soup_message_metrics_get_response_start ()
guint64 | soup_message_metrics_get_response_end ()
guint64 | soup_message_metrics_get_request_header_bytes_sent ()
guint64 | soup_message_metrics_get_request_body_size ()
guint64 | soup_message_metrics_get_request_body_bytes_sent ()
guint64 | soup_message_metrics_get_response_header_bytes_received ()
guint64 | soup_message_metrics_get_response_body_size ()
guint64 | soup_message_metrics_get_response_body_bytes_received ()

## Types and Values

| SoupMessageMetrics

## Object Hierarchy

        GBoxed
        ╰── SoupMessageMetrics

## Includes

    #include <libsoup/soup.h>

## Description

Metrics collected while loading a SoupMessage.

Metrics are not collected by default for a SoupMessage, you need to add the flag `SOUP_MESSAGE_COLLECT_METRICS` to enable the feature.

## Functions

### soup_message_metrics_copy ()

    SoupMessageMetrics *
    soup_message_metrics_copy (SoupMessageMetrics *metrics);

Copies `metrics` .

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

a copy of `metrics`

### soup_message_metrics_free ()

    void
    soup_message_metrics_free (SoupMessageMetrics *metrics);

Frees `metrics`

#### Parameters

metrics | a SoupMessageMetrics |

### soup_message_metrics_get_fetch_start ()

    guint64
    soup_message_metrics_get_fetch_start (SoupMessageMetrics *metrics);

Get the time immediately before the SoupMessage started to fetch a resource either from a remote server or local disk cache.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the fetch start time

### soup_message_metrics_get_dns_start ()

    guint64
    soup_message_metrics_get_dns_start (SoupMessageMetrics *metrics);

Get the time immediately before the SoupMessage started the domain lookup name for the resource. It will be 0 if no domain lookup was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the domain lookup start time

### soup_message_metrics_get_dns_end ()

    guint64
    soup_message_metrics_get_dns_end (SoupMessageMetrics *metrics);

Get the time immediately after the SoupMessage completed the domain lookup name for the resource. It will be 0 if no domain lookup was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the domain lookup end time

### soup_message_metrics_get_connect_start ()

    guint64
    soup_message_metrics_get_connect_start
                                   (SoupMessageMetrics *metrics);

Get the time immediately before the SoupMessage started to establish the connection to the server. It will be 0 if no network connection was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the connection start time

### soup_message_metrics_get_connect_end ()

    guint64
    soup_message_metrics_get_connect_end (SoupMessageMetrics *metrics);

Get the time immediately after the SoupMessage completed the connection to the server. This includes the time for the proxy negotiation and TLS handshake. It will be 0 if no network connection was required to fetch the resource (a persistent connection was used or resource was loaded from the local disk cache).

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the connection end time

### soup_message_metrics_get_tls_start ()

    guint64
    soup_message_metrics_get_tls_start (SoupMessageMetrics *metrics);

Get the time immediately before the SoupMessage started the TLS handshake. It will be 0 if no TLS handshake was required to fetch the resource (connection was not secure, a persistent connection was used or resource was loaded from the local disk cache).

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the tls start time

### soup_message_metrics_get_request_start ()

    guint64
    soup_message_metrics_get_request_start
                                   (SoupMessageMetrics *metrics);

Get the time immediately before the SoupMessage started the request of the resource from the server or the local disk cache.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the request start time

### soup_message_metrics_get_response_start ()

    guint64
    soup_message_metrics_get_response_start
                                   (SoupMessageMetrics *metrics);

Get the time immediately after the SoupMessage received the first bytes of the response from the server or the local disk cache.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the response start time

### soup_message_metrics_get_response_end ()

    guint64
    soup_message_metrics_get_response_end (SoupMessageMetrics *metrics);

Get the time immediately after the SoupMessage received the last bytes of the response from the server or the local disk cache. In case of load failure, this returns the time immediately before the fetch is aborted.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the response end time

### soup_message_metrics_get_request_header_bytes_sent ()

    guint64
    soup_message_metrics_get_request_header_bytes_sent
                                   (SoupMessageMetrics *metrics);

Get the number of bytes sent to the network for the request headers. This value is available right before “wrote-headers” signal is emitted, but you might get an intermediate value if called before.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the request headers bytes sent

### soup_message_metrics_get_request_body_size ()

    guint64
    soup_message_metrics_get_request_body_size
                                   (SoupMessageMetrics *metrics);

Get the request body size in bytes. This is the size of the original body given to the request before any encoding is applied. This value is available right before “wrote-body” signal is emitted, but you might get an intermediate value if called before.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the request body size

### soup_message_metrics_get_request_body_bytes_sent ()

    guint64
    soup_message_metrics_get_request_body_bytes_sent
                                   (SoupMessageMetrics *metrics);

Get the number of bytes sent to the network for the request body. This is the size of the body sent, after encodings are applied, so it might be greater than the value returned by `soup_message_metrics_get_request_body_size()`. This value is available right before “wrote-body” signal is emitted, but you might get an intermediate value if called before.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the request body bytes sent

### soup_message_metrics_get_response_header_bytes_received ()

    guint64
    soup_message_metrics_get_response_header_bytes_received
                                   (SoupMessageMetrics *metrics);

Get the number of bytes received from the network for the response headers. This value is available right before “got-headers” signal is emitted, but you might get an intermediate value if called before. For resources loaded from the disk cache this value is always 0.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the response headers bytes received

### soup_message_metrics_get_response_body_size ()

    guint64
    soup_message_metrics_get_response_body_size
                                   (SoupMessageMetrics *metrics);

Get the response body size in bytes. This is the size of the body as given to the user after all encodings are applied, so it might be greater than the value returned by `soup_message_metrics_get_response_body_bytes_received()`. This value is available right before “got-body” signal is emitted, but you might get an intermediate value if called before.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the response body size

### soup_message_metrics_get_response_body_bytes_received ()

    guint64
    soup_message_metrics_get_response_body_bytes_received
                                   (SoupMessageMetrics *metrics);

Get the number of bytes received from the network for the response body. This value is available right before “got-body” signal is emitted, but you might get an intermediate value if called before. For resources loaded from the disk cache this value is always 0.

#### Parameters

metrics | a SoupMessageMetrics |

#### Returns

the response body bytes received

## Types and Values

### SoupMessageMetrics

    typedef struct _SoupMessageMetrics SoupMessageMetrics;

SoupMessageMetrics contains metrics collected while loading a SoupMessage either from the network or the disk cache.

Temporal metrics are expressed as a monotonic time and always start with a fetch start event and finish with response end. All other events are optional. An event can be 0 because it hasn't happened yet, because it's optional or because the load failed before the event reached.

Size metrics are expressed in bytes and aree updated while the SoupMessage is being loaded. You can connect to different SoupMessage signals to get the final result of every value.

## See Also

SoupMessage