The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

OpenTelemetry::Integration::HTTP::Tiny - OpenTelemetry integration for HTTP::Tiny

SYNOPSIS

    use OpenTelemetry::Integration 'HTTP::Tiny';

    # Or pass options to the integration
    use OpenTelemetry::Integration 'HTTP::Tiny' => {
        request_headers  => [ ... ],
        response_headers => [ ... ],
    };

    HTTP::Tiny->new->get('https://metacpan.org');

DESCRIPTION

This module can be used to instrument code using HTTP::Tiny to generate trace data using the OpenTelemetry API. See OpenTelemetry::Integration for more details.

This is one of the core integrations shipped with the base OpenTelemetry distribution.

The instrumentation provided by this module wraps around "request" in HTTP::Tiny to automatically generate telemetry data for every request that goes through that code path.

Attributes

Spans generated by this instrumentation will record the following attributes:

http.request.body.size

If the "content" parameter is set in the request, and it is not set to a code reference, then this attribute will be set to the size of its value as returned by length.

http.request.header

The instrumentation can be configured to store the value of specific request headers under this key (see "request_headers" for more details). When configured to do so, requested headers will be read from the default headers configured with this client, and from the headers set for this specific request.

Headers will be stored as they are found, with their names normalised to lowercase and any hyphens (-) converted to underscores (_). The stored values will be coerced to arrayrefs, as per the semantic convention documentation.

http.resend_count

Set to the number of redirects that were performed when executing this request. Note that although the OpenTelemetry specification requires this to be sent with an incremental value with every retry, this attribute is currently once and only includes the number of redirects.

http.response.body.size

Set to the value of the Content-Length header received in the response. If this header was not set, this attribute will not be recorded.

http.response.header

The instrumentation can be configured to store the value of specific response headers under this key (see "response_headers" for more details). When configured to do so, requested headers will be read from the headers received in the response.

Headers will be stored as they are found, with their names normalised to lowercase and any hyphens (-) converted to underscores (_). The stored values will be coerced to arrayrefs, as per the semantic convention documentation.

http.response.status_code

Set to the status code of the response, as stored in the status key of the response hash.

http.request.method

Set to the HTTP method of the request, in uppercase.

network.protocol.name

Unconditionally set to "http".

network.protocol.version

Unconditionally set to "1.1".

network.transport

Unconditionally set to "tcp".

server.address

Set to the host of the URL, as reported by "host" in URI.

server.port

Set to the port of the URL, as reported by "port" in URI.

url.full

Set to the full URL, with the userinfo portion redacted (if it exists) in order to minimise the risk of leaking sensitive information. If present, the userinfo will be rendered as REDACTED:REDACTED.

user_agent.original

Set to the value returned by "agent" in HTTP::Tiny.

CONFIGURATION

request_headers

This integration can be configured to store specific request headers with every generated span (see "http.request.header"). In order to do so, set this key to an array reference with the name of the request headers you want as strings.

The strings will be matched case-insensitively to the header names, and hyphens and underscores will be treated indistinctly. Otherwise, names will be matched literally.

response_headers

This integration can be configured to store specific response headers with every generated span (see "http.response.header"). In order to do so, set this key to an array reference with the name of the response headers you want as strings.

The strings will be matched case-insensitively to the header names, and hyphens and underscores will be treated indistinctly. Otherwise, names will be matched literally.

SEE ALSO

HTTP::Tiny
OpenTelemetry
OpenTelemetry::Integration
OpenTelemetry::Integration::LWP::UserAgent
URI

COPYRIGHT

This software is copyright (c) 2023 by José Joaquín Atria.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.