NAME
OpenTelemetry::Instrumentation::LWP::UserAgent - OpenTelemetry instrumentation for LWP::UserAgent
SYNOPSIS
use OpenTelemetry::Instrumentation 'LWP::UserAgent';
# Or pass options to the instrumentation
use OpenTelemetry::Instrumentation 'LWP::UserAgent' => {
request_headers => [ ... ],
response_headers => [ ... ],
};
LWP::UserAgent->new->get('https://metacpan.org');
DESCRIPTION
This module can be used to instrument code using LWP::UserAgent to generate trace data using the OpenTelemetry API. See OpenTelemetry::Instrumentation for more details.
This is one of the core instrumentations shipped with the base OpenTelemetry distribution.
The instrumentation provided by this module wraps around "simple_request" in LWP::UserAgent 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
-
Set to the size of the return value of "content" in HTTP::Request, as reported by length. If this does not return a truthy value, then this attribute will not be set.
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 include retries, this currently 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 reported by "code" in HTTP::Response.
http.request.method
-
Set to the HTTP method of the request, as reported by "method" in HTTP::Response.
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 LWP::UserAgent.
CONFIGURATION
request_headers
This instrumentation can be configured to store specific request headers with every generated span. 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.
Matching headers will be stored as span attributes under the http.request.header
namespace, as described in the semantic convention documentation.
response_headers
This instrumentation can be configured to store specific response headers with every generated span. 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.
Matching headers will be stored as span attributes under the http.response.header
namespace, as described in the semantic convention documentation.
SEE ALSO
- HTTP::Request
- HTTP::Response
- LWP::UserAgent
- OpenTelemetry
- OpenTelemetry::Instrumentation
- OpenTelemetry::Instrumentation::HTTP::Tiny
- 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.