aws_xray_sdk.ext.util

Module Contents

first_cap_re
all_cap_re
inject_trace_header(headers, entity)

Extract trace id, entity id and sampling decision from the input entity and inject these information to headers.

Parameters:
  • headers (dict) – http headers to inject
  • entity (Entity) – trace entity that the trace header value generated from.
calculate_sampling_decision(trace_header, recorder, sampling_req)

Return 1 or the matched rule name if should sample and 0 if should not. The sampling decision coming from trace_header always has the highest precedence. If the trace_header doesn’t contain sampling decision then it checks if sampling is enabled or not in the recorder. If not enbaled it returns 1. Otherwise it uses user defined sampling rules to decide.

construct_xray_header(headers)

Construct a TraceHeader object from dictionary headers of the incoming request. This method should always return a TraceHeader object regardless of tracing header’s presence in the incoming request.

calculate_segment_name(host_name, recorder)

Returns the segment name based on recorder configuration and input host name. This is a helper generally used in web framework middleware where a host name is available from incoming request’s headers.

prepare_response_header(origin_header, segment)

Prepare a trace header to be inserted into response based on original header and the request segment.

to_snake_case(name)

Convert the input string to snake-cased string.

strip_url(url)

Will generate a valid url string for use as a segment name :param url: url to strip :return: validated url string

unwrap(obj, attr)

Will unwrap a wrapt attribute :param obj: base object :param attr: attribute on obj to unwrap