Dynatrace OneAgent SDK for C/C++  1.7.1.1
Macros | Functions
Outgoing Web Request Tracers

Trace the client side of web requests. More...

Macros

#define ONESDK_DYNATRACE_HTTP_HEADER_NAME   "X-dynaTrace"
 HTTP header name for the Dynatrace string tag. More...
 

Functions

onesdk_tracer_handle_t onesdk_outgoingwebrequesttracer_create (onesdk_string_t url, onesdk_string_t method)
 Creates a tracer for tracing an outgoing web request. More...
 
void onesdk_outgoingwebrequesttracer_add_request_header (onesdk_tracer_handle_t tracer_handle, onesdk_string_t name, onesdk_string_t value)
 Adds an HTTP request header of an outgoing web request. More...
 
void onesdk_outgoingwebrequesttracer_add_response_header (onesdk_tracer_handle_t tracer_handle, onesdk_string_t name, onesdk_string_t value)
 Adds an HTTP response header for an outgoing web request. More...
 
void onesdk_outgoingwebrequesttracer_set_status_code (onesdk_tracer_handle_t tracer_handle, onesdk_int32_t status_code)
 Sets the HTTP status code for an outgoing web request. More...
 

Detailed Description

Trace the client side of web requests.

Outgoing web request tracers are used to capture information about HTTP requests that the application sends.

To create an outgoing web request tracer, an application can simply call onesdk_outgoingwebrequesttracer_create. To enable continuing the trace on the server/service side, the application must then retrieve the string tag from the tracer and send it along with the request in the HTTP request header "X-dynaTrace".

See also
onesdk_tracer_get_outgoing_dynatrace_string_tag
ONESDK_DYNATRACE_HTTP_HEADER_NAME
Incoming Web Request Tracers

For further information, see the high level SDK documentation at https://github.com/Dynatrace/OneAgent-SDK/#webrequests

Since
Outgoing web request tracers were added in version 1.2.0.

Macro Definition Documentation

◆ ONESDK_DYNATRACE_HTTP_HEADER_NAME

#define ONESDK_DYNATRACE_HTTP_HEADER_NAME   "X-dynaTrace"

HTTP header name for the Dynatrace string tag.

Sending an "X-dynaTrace" request header with a Dynatrace string tag along with an HTTP request enables any Dynatrace OneAgent on the server side to continue tracing (connect the server side trace to the traced operation from which the tag was obtained).

Function Documentation

◆ onesdk_outgoingwebrequesttracer_add_request_header()

void onesdk_outgoingwebrequesttracer_add_request_header ( onesdk_tracer_handle_t  tracer_handle,
onesdk_string_t  name,
onesdk_string_t  value 
)
inline

Adds an HTTP request header of an outgoing web request.

Parameters
tracer_handleA valid outgoing web request tracer handle.
nameThe name of the HTTP request header.
value[optional] The value of the HTTP request header.

To allow the agent to determine various bits of useful information, an application should add all HTTP request headers.

Note
The native SDK agent will currently capture all provided headers.
If an HTTP request contains multiple header lines with the same header name, an application should call this function once per line. Alternatively, depending on the header, the application can call this function once per header name, with an appropriately concatenated header value.
This function can not be used after the tracer was started.
Since
This function was added in version 1.2.0.

◆ onesdk_outgoingwebrequesttracer_add_response_header()

void onesdk_outgoingwebrequesttracer_add_response_header ( onesdk_tracer_handle_t  tracer_handle,
onesdk_string_t  name,
onesdk_string_t  value 
)
inline

Adds an HTTP response header for an outgoing web request.

Parameters
tracer_handleA valid outgoing web request tracer handle.
nameThe name of the HTTP response header.
value[optional] The value of the HTTP response header.
Note
The native SDK agent will currently capture all provided headers.
If the HTTP response contains multiple header lines with the same header name, an application should call this function once per line. Alternatively, depending on the header, the application can call this function once per header name, with an appropriately concatenated header value.
Since
This function was added in version 1.2.0.

◆ onesdk_outgoingwebrequesttracer_create()

onesdk_tracer_handle_t onesdk_outgoingwebrequesttracer_create ( onesdk_string_t  url,
onesdk_string_t  method 
)
inline

Creates a tracer for tracing an outgoing web request.

Parameters
urlThe requested URL. Will be parsed into scheme, host/port, path and query.
methodThe HTTP method of the request.
Returns
A handle for the newly created outgoing web request tracer or ONESDK_INVALID_HANDLE.
Note
url should be a full, absolute URL, i.e. containing the scheme, host, port (unless default), path and query. Any fragment part, if present, will be ignored (fragments are only processed locally and not part of the request URL).
If url contains a host name it will be resolved by the agent (asynchronously) after onesdk_tracer_start was called.
Since
This function was added in version 1.2.0.

◆ onesdk_outgoingwebrequesttracer_set_status_code()

void onesdk_outgoingwebrequesttracer_set_status_code ( onesdk_tracer_handle_t  tracer_handle,
onesdk_int32_t  status_code 
)

Sets the HTTP status code for an outgoing web request.

Parameters
tracer_handleA valid outgoing web request tracer handle.
status_codeThe HTTP status code of the response that was received.
Note
If an application fails to receive or decode the reply, it should not call this function. Instead the application can use onesdk_tracer_error to signal that the request was not completed successfully.
Since
This function was added in version 1.2.0.