Table of Contents
XRay.Client¶A low-level client representing AWS X-Ray:
client = session.create_client('xray')
These are the available methods:
batch_get_traces()can_paginate()generate_presigned_url()get_paginator()get_service_graph()get_trace_graph()get_trace_summaries()get_waiter()put_telemetry_records()put_trace_segments()batch_get_traces(**kwargs)¶Retrieves a list of traces specified by ID. Each trace is a collection of segment documents that originates from a single request. Use GetTraceSummaries to get a list of trace IDs.
See also: AWS API Documentation
Request Syntax
response = client.batch_get_traces(
TraceIds=[
'string',
],
NextToken='string'
)
| Parameters: |
|
|---|---|
| Return type: | dict |
| Returns: | Response Syntax {
'Traces': [
{
'Id': 'string',
'Duration': 123.0,
'Segments': [
{
'Id': 'string',
'Document': 'string'
},
]
},
],
'UnprocessedTraceIds': [
'string',
],
'NextToken': 'string'
}
Response Structure
|
can_paginate(operation_name)¶Check if an operation can be paginated.
| Parameters: | operation_name (string) – The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo, and you’d normally invoke the
operation as client.create_foo(**kwargs), if the
create_foo operation can be paginated, you can use the
call client.get_paginator("create_foo"). |
|---|---|
| Returns: | True if the operation can be paginated,
False otherwise. |
generate_presigned_url(ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None)¶Generate a presigned url given a client, its method, and arguments
| Parameters: |
|
|---|---|
| Returns: | The presigned url |
get_paginator(operation_name)¶Create a paginator for an operation.
| Parameters: | operation_name (string) – The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo, and you’d normally invoke the
operation as client.create_foo(**kwargs), if the
create_foo operation can be paginated, you can use the
call client.get_paginator("create_foo"). |
|---|---|
| Raises: | OperationNotPageableError – Raised if the operation is not
pageable. You can use the client.can_paginate method to
check if an operation is pageable. |
| Return type: | L{botocore.paginate.Paginator} |
| Returns: | A paginator object. |
get_service_graph(**kwargs)¶Retrieves a document that describes services that process incoming requests, and downstream services that they call as a result. Root services process incoming requests and make calls to downstream services. Root services are applications that use the AWS X-Ray SDK. Downstream services can be other applications, AWS resources, HTTP web APIs, or SQL databases.
See also: AWS API Documentation
Request Syntax
response = client.get_service_graph(
StartTime=datetime(2015, 1, 1),
EndTime=datetime(2015, 1, 1),
NextToken='string'
)
| Parameters: |
|
|---|---|
| Return type: | dict |
| Returns: | Response Syntax {
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1),
'Services': [
{
'ReferenceId': 123,
'Name': 'string',
'Names': [
'string',
],
'Root': True|False,
'AccountId': 'string',
'Type': 'string',
'State': 'string',
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1),
'Edges': [
{
'ReferenceId': 123,
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1),
'SummaryStatistics': {
'OkCount': 123,
'ErrorStatistics': {
'ThrottleCount': 123,
'OtherCount': 123,
'TotalCount': 123
},
'FaultStatistics': {
'OtherCount': 123,
'TotalCount': 123
},
'TotalCount': 123,
'TotalResponseTime': 123.0
},
'ResponseTimeHistogram': [
{
'Value': 123.0,
'Count': 123
},
],
'Aliases': [
{
'Name': 'string',
'Names': [
'string',
],
'Type': 'string'
},
]
},
],
'SummaryStatistics': {
'OkCount': 123,
'ErrorStatistics': {
'ThrottleCount': 123,
'OtherCount': 123,
'TotalCount': 123
},
'FaultStatistics': {
'OtherCount': 123,
'TotalCount': 123
},
'TotalCount': 123,
'TotalResponseTime': 123.0
},
'DurationHistogram': [
{
'Value': 123.0,
'Count': 123
},
],
'ResponseTimeHistogram': [
{
'Value': 123.0,
'Count': 123
},
]
},
],
'NextToken': 'string'
}
Response Structure
|
get_trace_graph(**kwargs)¶Retrieves a service graph for one or more specific trace IDs.
See also: AWS API Documentation
Request Syntax
response = client.get_trace_graph(
TraceIds=[
'string',
],
NextToken='string'
)
| Parameters: |
|
|---|---|
| Return type: | dict |
| Returns: | Response Syntax {
'Services': [
{
'ReferenceId': 123,
'Name': 'string',
'Names': [
'string',
],
'Root': True|False,
'AccountId': 'string',
'Type': 'string',
'State': 'string',
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1),
'Edges': [
{
'ReferenceId': 123,
'StartTime': datetime(2015, 1, 1),
'EndTime': datetime(2015, 1, 1),
'SummaryStatistics': {
'OkCount': 123,
'ErrorStatistics': {
'ThrottleCount': 123,
'OtherCount': 123,
'TotalCount': 123
},
'FaultStatistics': {
'OtherCount': 123,
'TotalCount': 123
},
'TotalCount': 123,
'TotalResponseTime': 123.0
},
'ResponseTimeHistogram': [
{
'Value': 123.0,
'Count': 123
},
],
'Aliases': [
{
'Name': 'string',
'Names': [
'string',
],
'Type': 'string'
},
]
},
],
'SummaryStatistics': {
'OkCount': 123,
'ErrorStatistics': {
'ThrottleCount': 123,
'OtherCount': 123,
'TotalCount': 123
},
'FaultStatistics': {
'OtherCount': 123,
'TotalCount': 123
},
'TotalCount': 123,
'TotalResponseTime': 123.0
},
'DurationHistogram': [
{
'Value': 123.0,
'Count': 123
},
],
'ResponseTimeHistogram': [
{
'Value': 123.0,
'Count': 123
},
]
},
],
'NextToken': 'string'
}
Response Structure
|
get_trace_summaries(**kwargs)¶Retrieves IDs and metadata for traces available for a specified time frame using an optional filter. To get the full traces, pass the trace IDs to BatchGetTraces .
A filter expression can target traced requests that hit specific service nodes or edges, have errors, or come from a known user. For example, the following filter expression targets traces that pass through api.example.com :
service("api.example.com")
This filter expression finds traces that have an annotation named account with the value 12345 :
annotation.account = "12345"
For a full list of indexed fields and keywords that you can use in filter expressions, see Using Filter Expressions in the AWS X-Ray Developer Guide .
See also: AWS API Documentation
Request Syntax
response = client.get_trace_summaries(
StartTime=datetime(2015, 1, 1),
EndTime=datetime(2015, 1, 1),
Sampling=True|False,
FilterExpression='string',
NextToken='string'
)
| Parameters: |
|
|---|---|
| Return type: | dict |
| Returns: | Response Syntax {
'TraceSummaries': [
{
'Id': 'string',
'Duration': 123.0,
'ResponseTime': 123.0,
'HasFault': True|False,
'HasError': True|False,
'HasThrottle': True|False,
'IsPartial': True|False,
'Http': {
'HttpURL': 'string',
'HttpStatus': 123,
'HttpMethod': 'string',
'UserAgent': 'string',
'ClientIp': 'string'
},
'Annotations': {
'string': [
{
'AnnotationValue': {
'NumberValue': 123.0,
'BooleanValue': True|False,
'StringValue': 'string'
},
'ServiceIds': [
{
'Name': 'string',
'Names': [
'string',
],
'AccountId': 'string',
'Type': 'string'
},
]
},
]
},
'Users': [
{
'UserName': 'string',
'ServiceIds': [
{
'Name': 'string',
'Names': [
'string',
],
'AccountId': 'string',
'Type': 'string'
},
]
},
],
'ServiceIds': [
{
'Name': 'string',
'Names': [
'string',
],
'AccountId': 'string',
'Type': 'string'
},
]
},
],
'ApproximateTime': datetime(2015, 1, 1),
'TracesProcessedCount': 123,
'NextToken': 'string'
}
Response Structure
|
get_waiter(waiter_name)¶put_telemetry_records(**kwargs)¶Used by the AWS X-Ray daemon to upload telemetry.
See also: AWS API Documentation
Request Syntax
response = client.put_telemetry_records(
TelemetryRecords=[
{
'Timestamp': datetime(2015, 1, 1),
'SegmentsReceivedCount': 123,
'SegmentsSentCount': 123,
'SegmentsSpilloverCount': 123,
'SegmentsRejectedCount': 123,
'BackendConnectionErrors': {
'TimeoutCount': 123,
'ConnectionRefusedCount': 123,
'HTTPCode4XXCount': 123,
'HTTPCode5XXCount': 123,
'UnknownHostCount': 123,
'OtherCount': 123
}
},
],
EC2InstanceId='string',
Hostname='string',
ResourceARN='string'
)
| Parameters: |
|
|---|---|
| Return type: | dict |
| Returns: | Response Syntax {}
Response Structure
|
put_trace_segments(**kwargs)¶Uploads segment documents to AWS X-Ray. The X-Ray SDK generates segment documents and sends them to the X-Ray daemon, which uploads them in batches. A segment document can be a completed segment, an in-progress segment, or an array of subsegments.
Segments must include the following fields. For the full segment document schema, see AWS X-Ray Segment Documents in the AWS X-Ray Developer Guide .
Required Segment Document Fields
name - The name of the service that handled the request.id - A 64-bit identifier for the segment, unique among segments in the same trace, in 16 hexadecimal digits.trace_id - A unique identifier that connects all segments and subsegments originating from a single client request.start_time - Time the segment or subsegment was created, in floating point seconds in epoch time, accurate to milliseconds. For example, 1480615200.010 or 1.480615200010E9 .end_time - Time the segment or subsegment was closed. For example, 1480615200.090 or 1.480615200090E9 . Specify either an end_time or in_progress .in_progress - Set to true instead of specifying an end_time to record that a segment has been started, but is not complete. Send an in progress segment when your application receives a request that will take a long time to serve, to trace the fact that the request was received. When the response is sent, send the complete segment to overwrite the in-progress segment.A trace_id consists of three numbers separated by hyphens. For example, 1-58406520-a006649127e371903a2de979. This includes:
Trace ID Format
1 .1480615200 seconds, or 58406520 in hexadecimal.See also: AWS API Documentation
Request Syntax
response = client.put_trace_segments(
TraceSegmentDocuments=[
'string',
]
)
| Parameters: | TraceSegmentDocuments (list) – [REQUIRED] A string containing a JSON document defining one or more segments or subsegments.
|
|---|---|
| Return type: | dict |
| Returns: | Response Syntax{
'UnprocessedTraceSegments': [
{
'Id': 'string',
'ErrorCode': 'string',
'Message': 'string'
},
]
}
Response Structure
|
The available paginators are: