diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 00379af6ca..3cc1345fcb 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1683,6 +1683,16 @@ components: example: 1706803070 format: int64 type: integer + TraceIDPathParameter: + description: |- + The trace ID. Accepts either a 32-character hexadecimal string (128-bit trace ID) + or a decimal string of up to 39 digits. + example: "0000000000000000abc1230000000000" + in: path + name: trace_id + required: true + schema: + type: string UserID: description: "The ID of the user." in: path @@ -2076,6 +2086,126 @@ components: required: - apiTrigger type: object + APMSpanErrorFlag: + description: Error flag for a span. `1` when the span is in error, `0` otherwise. + enum: + - 0 + - 1 + example: 0 + format: int32 + type: integer + x-enum-varnames: + - NO_ERROR + - ERROR + APMTraceSpan: + description: A single APM span returned as part of a trace. + properties: + duration: + description: The duration of the span, in nanoseconds. + example: 500000000 + format: int64 + type: integer + endTime: + description: The end time of the span, in Unix nanoseconds. + example: 1716800000500000000 + format: int64 + type: integer + error: + $ref: "#/components/schemas/APMSpanErrorFlag" + meta: + additionalProperties: + type: string + description: |- + String-valued tags attached to the span. Tag keys starting with `_` are + filtered out of the response. + example: + env: production + http.method: GET + type: object + metrics: + additionalProperties: + format: double + type: number + description: |- + Numeric metrics attached to the span. Metric keys starting with `_` are + filtered out of the response. + example: + http.status_code: 200 + type: object + name: + description: The operation name of the span. + example: web.request + type: string + parentID: + description: The ID of the parent span, or `0` when the span is a trace root. + example: 0 + format: int64 + type: integer + resource: + description: The resource that the span describes. + example: GET /products + type: string + resourceHash: + description: A hash of the resource field. + example: 6a4e9b7f + type: string + restricted: + description: Whether access to the span is restricted by the organization's data access policies. + example: false + type: boolean + self_time: + description: The time spent in the span itself, excluding time spent in child spans, in nanoseconds. + example: 250000000 + format: double + type: number + service: + description: The name of the service that emitted the span. + example: web-store + type: string + spanID: + description: The span ID, as an unsigned 64-bit integer. + example: 9876543210987654321 + format: int64 + type: integer + startTime: + description: The start time of the span, in Unix nanoseconds. + example: 1716800000000000000 + format: int64 + type: integer + traceID: + description: The lower 64 bits of the trace ID, as an unsigned 64-bit integer. + example: 12345678901234567890 + format: int64 + type: integer + traceIDFull: + description: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + example: "0000000000000000abc1230000000000" + type: string + type: + description: The type of the span (for example, `web`, `db`, or `rpc`). + example: web + type: string + required: + - service + - name + - resource + - traceID + - spanID + - parentID + - startTime + - endTime + - duration + - error + - type + - meta + - metrics + - traceIDFull + type: object + APMTraceSpans: + description: The list of spans that compose the trace. + items: + $ref: "#/components/schemas/APMTraceSpan" + type: array AWSAccountConfigID: description: |- Unique Datadog ID of the AWS Account Integration Config. @@ -65547,6 +65677,60 @@ components: $ref: "#/components/schemas/Project" type: array type: object + PrunedTraceAttributes: + description: The attributes of a pruned trace returned by the Get pruned trace by ID endpoint. + properties: + is_truncated: + description: |- + Indicates whether the underlying trace was truncated because its size + exceeded the maximum that can be retrieved from storage. + example: false + type: boolean + size_bytes: + description: The size, in bytes, of the original (non-pruned) trace before summarization. + example: 12345 + format: int32 + maximum: 2147483647 + type: integer + summarized_trace: + $ref: "#/components/schemas/SummarizedTrace" + required: + - summarized_trace + - is_truncated + - size_bytes + type: object + PrunedTraceData: + description: A pruned trace resource document. + properties: + attributes: + $ref: "#/components/schemas/PrunedTraceAttributes" + id: + description: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + example: "0000000000000000abc1230000000000" + type: string + type: + $ref: "#/components/schemas/PrunedTraceType" + required: + - id + - type + - attributes + type: object + PrunedTraceResponse: + description: Response containing a single pruned trace. + properties: + data: + $ref: "#/components/schemas/PrunedTraceData" + required: + - data + type: object + PrunedTraceType: + description: The type of the pruned trace resource. The value is always `pruned_trace`. + enum: + - pruned_trace + example: pruned_trace + type: string + x-enum-varnames: + - PRUNED_TRACE PublishAppResponse: description: The response object after an app is successfully published. properties: @@ -83078,6 +83262,110 @@ components: type: string x-enum-varnames: - SUITES_SEARCH + SummarizedSpan: + description: A node in the pruned trace tree. + properties: + children: + description: The child spans of this node in the pruned tree. + example: [] + items: + $ref: "#/components/schemas/SummarizedSpan" + type: array + durationSeconds: + description: The duration of the span, in seconds. + example: 0.5 + format: double + type: number + endTime: + description: The end time of the span, in RFC3339 format. + example: "2026-05-27T12:00:00.5Z" + format: date-time + type: string + error: + $ref: "#/components/schemas/APMSpanErrorFlag" + hidden_child_spans_count: + description: The number of child spans that were pruned from this node when summarizing the trace. + example: 0 + format: int32 + maximum: 2147483647 + type: integer + meta: + additionalProperties: + type: string + description: String-valued tags attached to the span. + example: + env: production + type: object + metrics: + additionalProperties: + format: double + type: number + description: Numeric metrics attached to the span. + example: + http.status_code: 200 + type: object + name: + description: The operation name of the span. + example: web.request + type: string + parentID: + description: The ID of the parent span, or `0` when the span is the trace root. + example: 0 + format: int64 + type: integer + resource: + description: The resource that the span describes. + example: GET /products + type: string + service: + description: The name of the service that emitted the span. + example: web-store + type: string + spanID: + description: The span ID, as an unsigned 64-bit integer. + example: 9876543210987654321 + format: int64 + type: integer + span_kind: + description: |- + The OpenTelemetry span kind, for example `INTERNAL`, `SERVER`, `CLIENT`, + `PRODUCER`, or `CONSUMER`. + example: SERVER + type: string + startTime: + description: The start time of the span, in RFC3339 format. + example: "2026-05-27T12:00:00Z" + format: date-time + type: string + required: + - service + - name + - resource + - parentID + - spanID + - startTime + - endTime + - durationSeconds + - error + - meta + - metrics + - span_kind + - hidden_child_spans_count + - children + type: object + SummarizedTrace: + description: A summarized, hierarchical view of a trace. + properties: + root: + $ref: "#/components/schemas/SummarizedSpan" + traceId: + description: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + example: "0000000000000000abc1230000000000" + type: string + required: + - traceId + - root + type: object SuppressionVersionHistory: description: Response object containing the version history of a suppression. properties: @@ -90258,6 +90546,51 @@ components: type: string x-enum-varnames: - SECRET + TraceAttributes: + description: The attributes of a trace returned by the Get trace by ID endpoint. + properties: + is_truncated: + description: Indicates whether the trace was truncated because its size exceeded the maximum response payload. + example: false + type: boolean + spans: + $ref: "#/components/schemas/APMTraceSpans" + required: + - is_truncated + - spans + type: object + TraceData: + description: A trace resource document. + properties: + attributes: + $ref: "#/components/schemas/TraceAttributes" + id: + description: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + example: "0000000000000000abc1230000000000" + type: string + type: + $ref: "#/components/schemas/TraceType" + required: + - id + - type + - attributes + type: object + TraceResponse: + description: Response containing a single trace. + properties: + data: + $ref: "#/components/schemas/TraceData" + required: + - data + type: object + TraceType: + description: The type of the trace resource. The value is always `trace`. + enum: + - trace + example: trace + type: string + x-enum-varnames: + - TRACE Trigger: description: "One of the triggers that can start the execution of a workflow." oneOf: @@ -140181,6 +140514,159 @@ paths: tags: - Rum Audience Management x-unstable: "**Note**: This endpoint may be subject to changes." + /api/v2/pruned_trace/{trace_id}: + get: + description: |- + Retrieve a pruned, hierarchical view of an APM trace by its trace ID. + The trace is summarized as a tree of spans rooted at the trace root and reduced in size + to keep rendering large traces in the UI practical. + This endpoint is rate limited to `60` requests per minute per organization. + operationId: GetPrunedTraceByID + parameters: + - $ref: "#/components/parameters/TraceIDPathParameter" + - description: |- + Span ID to expand and preserve in the pruned tree even when its branch would + normally be summarized. + example: 9876543210987654321 + in: query + name: expand_span_id + required: false + schema: + format: int64 + type: integer + - description: |- + Optional Unix time hint, in seconds, used to optimize the lookup of the trace + in long-term storage. + example: 1716800000 + in: query + name: time_hint + required: false + schema: + format: int32 + maximum: 2147483647 + type: integer + - description: |- + Force the trace to be loaded from a specific source. When unset, the API picks + the source automatically. + example: driveline + in: query + name: force_source + required: false + schema: + type: string + - description: |- + Restrict the pruned tree to spans matching the given `key:value` pairs. + Values may be passed as repeated query parameters. + example: + - service:web-store + in: query + name: include_path + required: false + schema: + items: + type: string + type: array + - description: |- + Regex patterns of tag keys whose values must be included in the pruned spans. + Values may be passed as repeated query parameters. + example: + - "^http\\." + in: query + name: tag_include + required: false + schema: + items: + type: string + type: array + - description: |- + Regex patterns of tag keys whose values must be excluded from the pruned spans. + Values may be passed as repeated query parameters. + example: + - "^_dd\\." + in: query + name: tag_exclude + required: false + schema: + items: + type: string + type: array + - description: When set to `true`, only service entry spans are included in the pruned tree. + example: false + in: query + name: only_service_entry_spans + required: false + schema: + type: boolean + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + is_truncated: false + size_bytes: 12345 + summarized_trace: + root: + children: [] + durationSeconds: 0.5 + endTime: "2026-05-27T12:00:00.5Z" + error: 0 + hidden_child_spans_count: 0 + meta: + env: production + metrics: + http.status_code: 200 + name: web.request + parentID: 0 + resource: GET /products + service: web-store + spanID: 9876543210987654321 + span_kind: SERVER + startTime: "2026-05-27T12:00:00Z" + traceId: "0000000000000000abc1230000000000" + id: "0000000000000000abc1230000000000" + type: pruned_trace + schema: + $ref: "#/components/schemas/PrunedTraceResponse" + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + "504": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Gateway Timeout + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_read + summary: Get a pruned trace by ID + tags: + - APM Trace + x-permission: + operator: OR + permissions: + - apm_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/query/scalar: post: description: |- @@ -164778,6 +165264,96 @@ paths: operator: OR permissions: - test_optimization_read + /api/v2/trace/{trace_id}: + get: + description: |- + Retrieve a full APM trace by its trace ID, including every span in the trace. + Traces are returned from live storage when available and fall back to longer-term storage. + This endpoint is rate limited to `60` requests per minute per organization. + operationId: GetTraceByID + parameters: + - $ref: "#/components/parameters/TraceIDPathParameter" + - description: |- + List of span fields to include in the response. When omitted, every available field is returned. + Values may be passed as repeated query parameters or as a single comma-separated value. + example: + - service + - resource_name + in: query + name: include_fields + required: false + schema: + items: + type: string + type: array + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + is_truncated: false + spans: + - duration: 500000000 + endTime: 1716800000500000000 + error: 0 + meta: + env: production + http.method: GET + metrics: + http.status_code: 200 + name: web.request + parentID: 0 + resource: GET /products + service: web-store + spanID: 9876543210987654321 + startTime: 1716800000000000000 + traceID: 12345678901234567890 + traceIDFull: 0000000000000000abc1230000000000 + type: web + id: "0000000000000000abc1230000000000" + type: trace + schema: + $ref: "#/components/schemas/TraceResponse" + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "413": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Payload Too Large + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_read + summary: Get a trace by ID + tags: + - APM Trace + x-permission: + operator: OR + permissions: + - apm_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/usage/application_security: get: deprecated: true @@ -167504,6 +168080,8 @@ tags: description: Find out more at url: https://docs.datadoghq.com/tracing/trace_pipeline/trace_retention/ name: APM Retention Filters + - description: Retrieve full or pruned APM traces by trace ID. + name: APM Trace - description: |- Configure your Datadog-AWS integration directly through the Datadog API. For more information, see the [AWS integration page](https://docs.datadoghq.com/integrations/amazon_web_services). diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index b983e4d251..3b3e239d53 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -46,6 +46,13 @@ datadog\_api\_client.v2.api.apm\_retention\_filters\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.apm\_trace\_api module +-------------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.apm_trace_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.app\_builder\_api module ---------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 8c6243db4a..9fa3aa5767 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -1124,6 +1124,20 @@ datadog\_api\_client.v2.model.apm\_retention\_filter\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.apm\_span\_error\_flag module +----------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.apm_span_error_flag + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.apm\_trace\_span module +----------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.apm_trace_span + :members: + :show-inheritance: + datadog\_api\_client.v2.model.app\_builder\_event module -------------------------------------------------------- @@ -28333,6 +28347,34 @@ datadog\_api\_client.v2.model.projects\_response module :members: :show-inheritance: +datadog\_api\_client.v2.model.pruned\_trace\_attributes module +-------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.pruned_trace_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.pruned\_trace\_data module +-------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.pruned_trace_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.pruned\_trace\_response module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.pruned_trace_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.pruned\_trace\_type module +-------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.pruned_trace_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.publish\_app\_response module ----------------------------------------------------------- @@ -36383,6 +36425,20 @@ datadog\_api\_client.v2.model.suite\_search\_response\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.summarized\_span module +----------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.summarized_span + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.summarized\_trace module +------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.summarized_trace + :members: + :show-inheritance: + datadog\_api\_client.v2.model.suppression\_version\_history module ------------------------------------------------------------------ @@ -39295,6 +39351,34 @@ datadog\_api\_client.v2.model.token\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.trace\_attributes module +------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.trace_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.trace\_data module +------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.trace_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.trace\_response module +---------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.trace_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.trace\_type module +------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.trace_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.trigger module -------------------------------------------- diff --git a/examples/v2/apm-trace/GetPrunedTraceByID.py b/examples/v2/apm-trace/GetPrunedTraceByID.py new file mode 100644 index 0000000000..435735c33b --- /dev/null +++ b/examples/v2/apm-trace/GetPrunedTraceByID.py @@ -0,0 +1,16 @@ +""" +Get a pruned trace by ID returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.apm_trace_api import APMTraceApi + +configuration = Configuration() +configuration.unstable_operations["get_pruned_trace_by_id"] = True +with ApiClient(configuration) as api_client: + api_instance = APMTraceApi(api_client) + response = api_instance.get_pruned_trace_by_id( + trace_id="trace_id", + ) + + print(response) diff --git a/examples/v2/apm-trace/GetTraceByID.py b/examples/v2/apm-trace/GetTraceByID.py new file mode 100644 index 0000000000..a0334bb32f --- /dev/null +++ b/examples/v2/apm-trace/GetTraceByID.py @@ -0,0 +1,16 @@ +""" +Get a trace by ID returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.apm_trace_api import APMTraceApi + +configuration = Configuration() +configuration.unstable_operations["get_trace_by_id"] = True +with ApiClient(configuration) as api_client: + api_instance = APMTraceApi(api_client) + response = api_instance.get_trace_by_id( + trace_id="trace_id", + ) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index f58ee9964c..a6abf47e24 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -610,6 +610,8 @@ def __init__( "v2.query_event_filtered_users": False, "v2.query_users": False, "v2.update_connection": False, + "v2.get_pruned_trace_by_id": False, + "v2.get_trace_by_id": False, "v2.create_scorecard_outcomes_batch": False, "v2.list_entity_risk_scores": False, "v2.create_incident_service": False, diff --git a/src/datadog_api_client/v2/api/apm_trace_api.py b/src/datadog_api_client/v2/api/apm_trace_api.py new file mode 100644 index 0000000000..aa1ffc357c --- /dev/null +++ b/src/datadog_api_client/v2/api/apm_trace_api.py @@ -0,0 +1,217 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Any, Dict, List, Union + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.model_utils import ( + UnsetType, + unset, +) +from datadog_api_client.v2.model.pruned_trace_response import PrunedTraceResponse +from datadog_api_client.v2.model.trace_response import TraceResponse + + +class APMTraceApi: + """ + Retrieve full or pruned APM traces by trace ID. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._get_pruned_trace_by_id_endpoint = _Endpoint( + settings={ + "response_type": (PrunedTraceResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/pruned_trace/{trace_id}", + "operation_id": "get_pruned_trace_by_id", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "trace_id": { + "required": True, + "openapi_types": (str,), + "attribute": "trace_id", + "location": "path", + }, + "expand_span_id": { + "openapi_types": (int,), + "attribute": "expand_span_id", + "location": "query", + }, + "time_hint": { + "validation": { + "inclusive_maximum": 2147483647, + }, + "openapi_types": (int,), + "attribute": "time_hint", + "location": "query", + }, + "force_source": { + "openapi_types": (str,), + "attribute": "force_source", + "location": "query", + }, + "include_path": { + "openapi_types": ([str],), + "attribute": "include_path", + "location": "query", + "collection_format": "multi", + }, + "tag_include": { + "openapi_types": ([str],), + "attribute": "tag_include", + "location": "query", + "collection_format": "multi", + }, + "tag_exclude": { + "openapi_types": ([str],), + "attribute": "tag_exclude", + "location": "query", + "collection_format": "multi", + }, + "only_service_entry_spans": { + "openapi_types": (bool,), + "attribute": "only_service_entry_spans", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + self._get_trace_by_id_endpoint = _Endpoint( + settings={ + "response_type": (TraceResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/trace/{trace_id}", + "operation_id": "get_trace_by_id", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "trace_id": { + "required": True, + "openapi_types": (str,), + "attribute": "trace_id", + "location": "path", + }, + "include_fields": { + "openapi_types": ([str],), + "attribute": "include_fields", + "location": "query", + "collection_format": "multi", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + def get_pruned_trace_by_id( + self, + trace_id: str, + *, + expand_span_id: Union[int, UnsetType] = unset, + time_hint: Union[int, UnsetType] = unset, + force_source: Union[str, UnsetType] = unset, + include_path: Union[List[str], UnsetType] = unset, + tag_include: Union[List[str], UnsetType] = unset, + tag_exclude: Union[List[str], UnsetType] = unset, + only_service_entry_spans: Union[bool, UnsetType] = unset, + ) -> PrunedTraceResponse: + """Get a pruned trace by ID. + + Retrieve a pruned, hierarchical view of an APM trace by its trace ID. + The trace is summarized as a tree of spans rooted at the trace root and reduced in size + to keep rendering large traces in the UI practical. + This endpoint is rate limited to ``60`` requests per minute per organization. + + :param trace_id: The trace ID. Accepts either a 32-character hexadecimal string (128-bit trace ID) + or a decimal string of up to 39 digits. + :type trace_id: str + :param expand_span_id: Span ID to expand and preserve in the pruned tree even when its branch would + normally be summarized. + :type expand_span_id: int, optional + :param time_hint: Optional Unix time hint, in seconds, used to optimize the lookup of the trace + in long-term storage. + :type time_hint: int, optional + :param force_source: Force the trace to be loaded from a specific source. When unset, the API picks + the source automatically. + :type force_source: str, optional + :param include_path: Restrict the pruned tree to spans matching the given ``key:value`` pairs. + Values may be passed as repeated query parameters. + :type include_path: [str], optional + :param tag_include: Regex patterns of tag keys whose values must be included in the pruned spans. + Values may be passed as repeated query parameters. + :type tag_include: [str], optional + :param tag_exclude: Regex patterns of tag keys whose values must be excluded from the pruned spans. + Values may be passed as repeated query parameters. + :type tag_exclude: [str], optional + :param only_service_entry_spans: When set to ``true`` , only service entry spans are included in the pruned tree. + :type only_service_entry_spans: bool, optional + :rtype: PrunedTraceResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["trace_id"] = trace_id + + if expand_span_id is not unset: + kwargs["expand_span_id"] = expand_span_id + + if time_hint is not unset: + kwargs["time_hint"] = time_hint + + if force_source is not unset: + kwargs["force_source"] = force_source + + if include_path is not unset: + kwargs["include_path"] = include_path + + if tag_include is not unset: + kwargs["tag_include"] = tag_include + + if tag_exclude is not unset: + kwargs["tag_exclude"] = tag_exclude + + if only_service_entry_spans is not unset: + kwargs["only_service_entry_spans"] = only_service_entry_spans + + return self._get_pruned_trace_by_id_endpoint.call_with_http_info(**kwargs) + + def get_trace_by_id( + self, + trace_id: str, + *, + include_fields: Union[List[str], UnsetType] = unset, + ) -> TraceResponse: + """Get a trace by ID. + + Retrieve a full APM trace by its trace ID, including every span in the trace. + Traces are returned from live storage when available and fall back to longer-term storage. + This endpoint is rate limited to ``60`` requests per minute per organization. + + :param trace_id: The trace ID. Accepts either a 32-character hexadecimal string (128-bit trace ID) + or a decimal string of up to 39 digits. + :type trace_id: str + :param include_fields: List of span fields to include in the response. When omitted, every available field is returned. + Values may be passed as repeated query parameters or as a single comma-separated value. + :type include_fields: [str], optional + :rtype: TraceResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["trace_id"] = trace_id + + if include_fields is not unset: + kwargs["include_fields"] = include_fields + + return self._get_trace_by_id_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index 6f2ebf73d1..e54e9099e9 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -1,6 +1,7 @@ from datadog_api_client.v2.api.api_management_api import APIManagementApi from datadog_api_client.v2.api.apm_api import APMApi from datadog_api_client.v2.api.apm_retention_filters_api import APMRetentionFiltersApi +from datadog_api_client.v2.api.apm_trace_api import APMTraceApi from datadog_api_client.v2.api.aws_integration_api import AWSIntegrationApi from datadog_api_client.v2.api.aws_logs_integration_api import AWSLogsIntegrationApi from datadog_api_client.v2.api.action_connection_api import ActionConnectionApi @@ -117,6 +118,7 @@ "APIManagementApi", "APMApi", "APMRetentionFiltersApi", + "APMTraceApi", "AWSIntegrationApi", "AWSLogsIntegrationApi", "ActionConnectionApi", diff --git a/src/datadog_api_client/v2/model/apm_span_error_flag.py b/src/datadog_api_client/v2/model/apm_span_error_flag.py new file mode 100644 index 0000000000..87be750aba --- /dev/null +++ b/src/datadog_api_client/v2/model/apm_span_error_flag.py @@ -0,0 +1,38 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class APMSpanErrorFlag(ModelSimple): + """ + Error flag for a span. `1` when the span is in error, `0` otherwise. + + :param value: Must be one of [0, 1]. + :type value: int + """ + + allowed_values = { + 0, + 1, + } + NO_ERROR: ClassVar["APMSpanErrorFlag"] + ERROR: ClassVar["APMSpanErrorFlag"] + + @cached_property + def openapi_types(_): + return { + "value": (int,), + } + + +APMSpanErrorFlag.NO_ERROR = APMSpanErrorFlag(0) +APMSpanErrorFlag.ERROR = APMSpanErrorFlag(1) diff --git a/src/datadog_api_client/v2/model/apm_trace_span.py b/src/datadog_api_client/v2/model/apm_trace_span.py new file mode 100644 index 0000000000..4fd5a2f5ce --- /dev/null +++ b/src/datadog_api_client/v2/model/apm_trace_span.py @@ -0,0 +1,163 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Dict, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.apm_span_error_flag import APMSpanErrorFlag + + +class APMTraceSpan(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.apm_span_error_flag import APMSpanErrorFlag + + return { + "duration": (int,), + "end_time": (int,), + "error": (APMSpanErrorFlag,), + "meta": ({str: (str,)},), + "metrics": ({str: (float,)},), + "name": (str,), + "parent_id": (int,), + "resource": (str,), + "resource_hash": (str,), + "restricted": (bool,), + "self_time": (float,), + "service": (str,), + "span_id": (int,), + "start_time": (int,), + "trace_id": (int,), + "trace_id_full": (str,), + "type": (str,), + } + + attribute_map = { + "duration": "duration", + "end_time": "endTime", + "error": "error", + "meta": "meta", + "metrics": "metrics", + "name": "name", + "parent_id": "parentID", + "resource": "resource", + "resource_hash": "resourceHash", + "restricted": "restricted", + "self_time": "self_time", + "service": "service", + "span_id": "spanID", + "start_time": "startTime", + "trace_id": "traceID", + "trace_id_full": "traceIDFull", + "type": "type", + } + + def __init__( + self_, + duration: int, + end_time: int, + error: APMSpanErrorFlag, + meta: Dict[str, str], + metrics: Dict[str, float], + name: str, + parent_id: int, + resource: str, + service: str, + span_id: int, + start_time: int, + trace_id: int, + trace_id_full: str, + type: str, + resource_hash: Union[str, UnsetType] = unset, + restricted: Union[bool, UnsetType] = unset, + self_time: Union[float, UnsetType] = unset, + **kwargs, + ): + """ + A single APM span returned as part of a trace. + + :param duration: The duration of the span, in nanoseconds. + :type duration: int + + :param end_time: The end time of the span, in Unix nanoseconds. + :type end_time: int + + :param error: Error flag for a span. ``1`` when the span is in error, ``0`` otherwise. + :type error: APMSpanErrorFlag + + :param meta: String-valued tags attached to the span. Tag keys starting with ``_`` are + filtered out of the response. + :type meta: {str: (str,)} + + :param metrics: Numeric metrics attached to the span. Metric keys starting with ``_`` are + filtered out of the response. + :type metrics: {str: (float,)} + + :param name: The operation name of the span. + :type name: str + + :param parent_id: The ID of the parent span, or ``0`` when the span is a trace root. + :type parent_id: int + + :param resource: The resource that the span describes. + :type resource: str + + :param resource_hash: A hash of the resource field. + :type resource_hash: str, optional + + :param restricted: Whether access to the span is restricted by the organization's data access policies. + :type restricted: bool, optional + + :param self_time: The time spent in the span itself, excluding time spent in child spans, in nanoseconds. + :type self_time: float, optional + + :param service: The name of the service that emitted the span. + :type service: str + + :param span_id: The span ID, as an unsigned 64-bit integer. + :type span_id: int + + :param start_time: The start time of the span, in Unix nanoseconds. + :type start_time: int + + :param trace_id: The lower 64 bits of the trace ID, as an unsigned 64-bit integer. + :type trace_id: int + + :param trace_id_full: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + :type trace_id_full: str + + :param type: The type of the span (for example, ``web`` , ``db`` , or ``rpc`` ). + :type type: str + """ + if resource_hash is not unset: + kwargs["resource_hash"] = resource_hash + if restricted is not unset: + kwargs["restricted"] = restricted + if self_time is not unset: + kwargs["self_time"] = self_time + super().__init__(kwargs) + + self_.duration = duration + self_.end_time = end_time + self_.error = error + self_.meta = meta + self_.metrics = metrics + self_.name = name + self_.parent_id = parent_id + self_.resource = resource + self_.service = service + self_.span_id = span_id + self_.start_time = start_time + self_.trace_id = trace_id + self_.trace_id_full = trace_id_full + self_.type = type diff --git a/src/datadog_api_client/v2/model/pruned_trace_attributes.py b/src/datadog_api_client/v2/model/pruned_trace_attributes.py new file mode 100644 index 0000000000..0b43767a33 --- /dev/null +++ b/src/datadog_api_client/v2/model/pruned_trace_attributes.py @@ -0,0 +1,59 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.summarized_trace import SummarizedTrace + + +class PrunedTraceAttributes(ModelNormal): + validations = { + "size_bytes": { + "inclusive_maximum": 2147483647, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.summarized_trace import SummarizedTrace + + return { + "is_truncated": (bool,), + "size_bytes": (int,), + "summarized_trace": (SummarizedTrace,), + } + + attribute_map = { + "is_truncated": "is_truncated", + "size_bytes": "size_bytes", + "summarized_trace": "summarized_trace", + } + + def __init__(self_, is_truncated: bool, size_bytes: int, summarized_trace: SummarizedTrace, **kwargs): + """ + The attributes of a pruned trace returned by the Get pruned trace by ID endpoint. + + :param is_truncated: Indicates whether the underlying trace was truncated because its size + exceeded the maximum that can be retrieved from storage. + :type is_truncated: bool + + :param size_bytes: The size, in bytes, of the original (non-pruned) trace before summarization. + :type size_bytes: int + + :param summarized_trace: A summarized, hierarchical view of a trace. + :type summarized_trace: SummarizedTrace + """ + super().__init__(kwargs) + + self_.is_truncated = is_truncated + self_.size_bytes = size_bytes + self_.summarized_trace = summarized_trace diff --git a/src/datadog_api_client/v2/model/pruned_trace_data.py b/src/datadog_api_client/v2/model/pruned_trace_data.py new file mode 100644 index 0000000000..6df23971af --- /dev/null +++ b/src/datadog_api_client/v2/model/pruned_trace_data.py @@ -0,0 +1,54 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.pruned_trace_attributes import PrunedTraceAttributes + from datadog_api_client.v2.model.pruned_trace_type import PrunedTraceType + + +class PrunedTraceData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.pruned_trace_attributes import PrunedTraceAttributes + from datadog_api_client.v2.model.pruned_trace_type import PrunedTraceType + + return { + "attributes": (PrunedTraceAttributes,), + "id": (str,), + "type": (PrunedTraceType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: PrunedTraceAttributes, id: str, type: PrunedTraceType, **kwargs): + """ + A pruned trace resource document. + + :param attributes: The attributes of a pruned trace returned by the Get pruned trace by ID endpoint. + :type attributes: PrunedTraceAttributes + + :param id: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + :type id: str + + :param type: The type of the pruned trace resource. The value is always ``pruned_trace``. + :type type: PrunedTraceType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/pruned_trace_response.py b/src/datadog_api_client/v2/model/pruned_trace_response.py new file mode 100644 index 0000000000..17a72cd85b --- /dev/null +++ b/src/datadog_api_client/v2/model/pruned_trace_response.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.pruned_trace_data import PrunedTraceData + + +class PrunedTraceResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.pruned_trace_data import PrunedTraceData + + return { + "data": (PrunedTraceData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: PrunedTraceData, **kwargs): + """ + Response containing a single pruned trace. + + :param data: A pruned trace resource document. + :type data: PrunedTraceData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/pruned_trace_type.py b/src/datadog_api_client/v2/model/pruned_trace_type.py new file mode 100644 index 0000000000..b37fdc3298 --- /dev/null +++ b/src/datadog_api_client/v2/model/pruned_trace_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class PrunedTraceType(ModelSimple): + """ + The type of the pruned trace resource. The value is always `pruned_trace`. + + :param value: If omitted defaults to "pruned_trace". Must be one of ["pruned_trace"]. + :type value: str + """ + + allowed_values = { + "pruned_trace", + } + PRUNED_TRACE: ClassVar["PrunedTraceType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +PrunedTraceType.PRUNED_TRACE = PrunedTraceType("pruned_trace") diff --git a/src/datadog_api_client/v2/model/summarized_span.py b/src/datadog_api_client/v2/model/summarized_span.py new file mode 100644 index 0000000000..833ff0568a --- /dev/null +++ b/src/datadog_api_client/v2/model/summarized_span.py @@ -0,0 +1,143 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Dict, List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.apm_span_error_flag import APMSpanErrorFlag + + +class SummarizedSpan(ModelNormal): + validations = { + "hidden_child_spans_count": { + "inclusive_maximum": 2147483647, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.apm_span_error_flag import APMSpanErrorFlag + + return { + "children": ([SummarizedSpan],), + "duration_seconds": (float,), + "end_time": (datetime,), + "error": (APMSpanErrorFlag,), + "hidden_child_spans_count": (int,), + "meta": ({str: (str,)},), + "metrics": ({str: (float,)},), + "name": (str,), + "parent_id": (int,), + "resource": (str,), + "service": (str,), + "span_id": (int,), + "span_kind": (str,), + "start_time": (datetime,), + } + + attribute_map = { + "children": "children", + "duration_seconds": "durationSeconds", + "end_time": "endTime", + "error": "error", + "hidden_child_spans_count": "hidden_child_spans_count", + "meta": "meta", + "metrics": "metrics", + "name": "name", + "parent_id": "parentID", + "resource": "resource", + "service": "service", + "span_id": "spanID", + "span_kind": "span_kind", + "start_time": "startTime", + } + + def __init__( + self_, + children: List[SummarizedSpan], + duration_seconds: float, + end_time: datetime, + error: APMSpanErrorFlag, + hidden_child_spans_count: int, + meta: Dict[str, str], + metrics: Dict[str, float], + name: str, + parent_id: int, + resource: str, + service: str, + span_id: int, + span_kind: str, + start_time: datetime, + **kwargs, + ): + """ + A node in the pruned trace tree. + + :param children: The child spans of this node in the pruned tree. + :type children: [SummarizedSpan] + + :param duration_seconds: The duration of the span, in seconds. + :type duration_seconds: float + + :param end_time: The end time of the span, in RFC3339 format. + :type end_time: datetime + + :param error: Error flag for a span. ``1`` when the span is in error, ``0`` otherwise. + :type error: APMSpanErrorFlag + + :param hidden_child_spans_count: The number of child spans that were pruned from this node when summarizing the trace. + :type hidden_child_spans_count: int + + :param meta: String-valued tags attached to the span. + :type meta: {str: (str,)} + + :param metrics: Numeric metrics attached to the span. + :type metrics: {str: (float,)} + + :param name: The operation name of the span. + :type name: str + + :param parent_id: The ID of the parent span, or ``0`` when the span is the trace root. + :type parent_id: int + + :param resource: The resource that the span describes. + :type resource: str + + :param service: The name of the service that emitted the span. + :type service: str + + :param span_id: The span ID, as an unsigned 64-bit integer. + :type span_id: int + + :param span_kind: The OpenTelemetry span kind, for example ``INTERNAL`` , ``SERVER`` , ``CLIENT`` , + ``PRODUCER`` , or ``CONSUMER``. + :type span_kind: str + + :param start_time: The start time of the span, in RFC3339 format. + :type start_time: datetime + """ + super().__init__(kwargs) + + self_.children = children + self_.duration_seconds = duration_seconds + self_.end_time = end_time + self_.error = error + self_.hidden_child_spans_count = hidden_child_spans_count + self_.meta = meta + self_.metrics = metrics + self_.name = name + self_.parent_id = parent_id + self_.resource = resource + self_.service = service + self_.span_id = span_id + self_.span_kind = span_kind + self_.start_time = start_time diff --git a/src/datadog_api_client/v2/model/summarized_trace.py b/src/datadog_api_client/v2/model/summarized_trace.py new file mode 100644 index 0000000000..efa5ef7f5e --- /dev/null +++ b/src/datadog_api_client/v2/model/summarized_trace.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.summarized_span import SummarizedSpan + + +class SummarizedTrace(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.summarized_span import SummarizedSpan + + return { + "root": (SummarizedSpan,), + "trace_id": (str,), + } + + attribute_map = { + "root": "root", + "trace_id": "traceId", + } + + def __init__(self_, root: SummarizedSpan, trace_id: str, **kwargs): + """ + A summarized, hierarchical view of a trace. + + :param root: A node in the pruned trace tree. + :type root: SummarizedSpan + + :param trace_id: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + :type trace_id: str + """ + super().__init__(kwargs) + + self_.root = root + self_.trace_id = trace_id diff --git a/src/datadog_api_client/v2/model/trace_attributes.py b/src/datadog_api_client/v2/model/trace_attributes.py new file mode 100644 index 0000000000..71d06821d6 --- /dev/null +++ b/src/datadog_api_client/v2/model/trace_attributes.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.apm_trace_span import APMTraceSpan + + +class TraceAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.apm_trace_span import APMTraceSpan + + return { + "is_truncated": (bool,), + "spans": ([APMTraceSpan],), + } + + attribute_map = { + "is_truncated": "is_truncated", + "spans": "spans", + } + + def __init__(self_, is_truncated: bool, spans: List[APMTraceSpan], **kwargs): + """ + The attributes of a trace returned by the Get trace by ID endpoint. + + :param is_truncated: Indicates whether the trace was truncated because its size exceeded the maximum response payload. + :type is_truncated: bool + + :param spans: The list of spans that compose the trace. + :type spans: [APMTraceSpan] + """ + super().__init__(kwargs) + + self_.is_truncated = is_truncated + self_.spans = spans diff --git a/src/datadog_api_client/v2/model/trace_data.py b/src/datadog_api_client/v2/model/trace_data.py new file mode 100644 index 0000000000..977580bf83 --- /dev/null +++ b/src/datadog_api_client/v2/model/trace_data.py @@ -0,0 +1,54 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.trace_attributes import TraceAttributes + from datadog_api_client.v2.model.trace_type import TraceType + + +class TraceData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.trace_attributes import TraceAttributes + from datadog_api_client.v2.model.trace_type import TraceType + + return { + "attributes": (TraceAttributes,), + "id": (str,), + "type": (TraceType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: TraceAttributes, id: str, type: TraceType, **kwargs): + """ + A trace resource document. + + :param attributes: The attributes of a trace returned by the Get trace by ID endpoint. + :type attributes: TraceAttributes + + :param id: The full 128-bit trace ID, encoded as a 32-character hexadecimal string. + :type id: str + + :param type: The type of the trace resource. The value is always ``trace``. + :type type: TraceType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/trace_response.py b/src/datadog_api_client/v2/model/trace_response.py new file mode 100644 index 0000000000..b058eaeb88 --- /dev/null +++ b/src/datadog_api_client/v2/model/trace_response.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.trace_data import TraceData + + +class TraceResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.trace_data import TraceData + + return { + "data": (TraceData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: TraceData, **kwargs): + """ + Response containing a single trace. + + :param data: A trace resource document. + :type data: TraceData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/trace_type.py b/src/datadog_api_client/v2/model/trace_type.py new file mode 100644 index 0000000000..591c65b6b6 --- /dev/null +++ b/src/datadog_api_client/v2/model/trace_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class TraceType(ModelSimple): + """ + The type of the trace resource. The value is always `trace`. + + :param value: If omitted defaults to "trace". Must be one of ["trace"]. + :type value: str + """ + + allowed_values = { + "trace", + } + TRACE: ClassVar["TraceType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TraceType.TRACE = TraceType("trace") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 43f1649b2a..0fa436be8f 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -15,6 +15,8 @@ from datadog_api_client.v2.model.api_keys_type import APIKeysType from datadog_api_client.v2.model.api_trigger import APITrigger from datadog_api_client.v2.model.api_trigger_wrapper import APITriggerWrapper +from datadog_api_client.v2.model.apm_span_error_flag import APMSpanErrorFlag +from datadog_api_client.v2.model.apm_trace_span import APMTraceSpan from datadog_api_client.v2.model.aws_account_create_request import AWSAccountCreateRequest from datadog_api_client.v2.model.aws_account_create_request_attributes import AWSAccountCreateRequestAttributes from datadog_api_client.v2.model.aws_account_create_request_data import AWSAccountCreateRequestData @@ -5724,6 +5726,10 @@ from datadog_api_client.v2.model.projected_cost_response import ProjectedCostResponse from datadog_api_client.v2.model.projected_cost_type import ProjectedCostType from datadog_api_client.v2.model.projects_response import ProjectsResponse +from datadog_api_client.v2.model.pruned_trace_attributes import PrunedTraceAttributes +from datadog_api_client.v2.model.pruned_trace_data import PrunedTraceData +from datadog_api_client.v2.model.pruned_trace_response import PrunedTraceResponse +from datadog_api_client.v2.model.pruned_trace_type import PrunedTraceType from datadog_api_client.v2.model.publish_app_response import PublishAppResponse from datadog_api_client.v2.model.publish_request_type import PublishRequestType from datadog_api_client.v2.model.put_apps_datastore_item_response_array import PutAppsDatastoreItemResponseArray @@ -7434,6 +7440,8 @@ from datadog_api_client.v2.model.suite_json_patch_request_data_attributes import SuiteJsonPatchRequestDataAttributes from datadog_api_client.v2.model.suite_json_patch_type import SuiteJsonPatchType from datadog_api_client.v2.model.suite_search_response_type import SuiteSearchResponseType +from datadog_api_client.v2.model.summarized_span import SummarizedSpan +from datadog_api_client.v2.model.summarized_trace import SummarizedTrace from datadog_api_client.v2.model.suppression_version_history import SuppressionVersionHistory from datadog_api_client.v2.model.suppression_versions import SuppressionVersions from datadog_api_client.v2.model.sync_property import SyncProperty @@ -8030,6 +8038,10 @@ from datadog_api_client.v2.model.timeseries_response_values import TimeseriesResponseValues from datadog_api_client.v2.model.timeseries_response_values_list import TimeseriesResponseValuesList from datadog_api_client.v2.model.token_type import TokenType +from datadog_api_client.v2.model.trace_attributes import TraceAttributes +from datadog_api_client.v2.model.trace_data import TraceData +from datadog_api_client.v2.model.trace_response import TraceResponse +from datadog_api_client.v2.model.trace_type import TraceType from datadog_api_client.v2.model.trigger import Trigger from datadog_api_client.v2.model.trigger_attributes import TriggerAttributes from datadog_api_client.v2.model.trigger_investigation_request import TriggerInvestigationRequest @@ -8438,6 +8450,8 @@ "APIKeysType", "APITrigger", "APITriggerWrapper", + "APMSpanErrorFlag", + "APMTraceSpan", "AWSAccountCreateRequest", "AWSAccountCreateRequestAttributes", "AWSAccountCreateRequestData", @@ -12475,6 +12489,10 @@ "ProjectedCostResponse", "ProjectedCostType", "ProjectsResponse", + "PrunedTraceAttributes", + "PrunedTraceData", + "PrunedTraceResponse", + "PrunedTraceType", "PublishAppResponse", "PublishRequestType", "PutAppsDatastoreItemResponseArray", @@ -13631,6 +13649,8 @@ "SuiteJsonPatchRequestDataAttributes", "SuiteJsonPatchType", "SuiteSearchResponseType", + "SummarizedSpan", + "SummarizedTrace", "SuppressionVersionHistory", "SuppressionVersions", "SyncProperty", @@ -14047,6 +14067,10 @@ "TimeseriesResponseValues", "TimeseriesResponseValuesList", "TokenType", + "TraceAttributes", + "TraceData", + "TraceResponse", + "TraceType", "Trigger", "TriggerAttributes", "TriggerInvestigationRequest", diff --git a/tests/v2/features/apm_trace.feature b/tests/v2/features/apm_trace.feature new file mode 100644 index 0000000000..e5b706b191 --- /dev/null +++ b/tests/v2/features/apm_trace.feature @@ -0,0 +1,48 @@ +@endpoint(apm-trace) @endpoint(apm-trace-v2) +Feature: APM Trace + Retrieve full or pruned APM traces by trace ID. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "APMTrace" API + + @generated @skip @team:DataDog/apm-reliability + Scenario: Get a pruned trace by ID returns "Not Found" response + Given operation "GetPrunedTraceByID" enabled + And new "GetPrunedTraceByID" request + And request contains "trace_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/apm-reliability + Scenario: Get a pruned trace by ID returns "OK" response + Given operation "GetPrunedTraceByID" enabled + And new "GetPrunedTraceByID" request + And request contains "trace_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/apm-reliability + Scenario: Get a trace by ID returns "Not Found" response + Given operation "GetTraceByID" enabled + And new "GetTraceByID" request + And request contains "trace_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/apm-reliability + Scenario: Get a trace by ID returns "OK" response + Given operation "GetTraceByID" enabled + And new "GetTraceByID" request + And request contains "trace_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/apm-reliability + Scenario: Get a trace by ID returns "Payload Too Large" response + Given operation "GetTraceByID" enabled + And new "GetTraceByID" request + And request contains "trace_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 413 Payload Too Large diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 0878797ffd..47c0c362f5 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -5296,6 +5296,12 @@ "type": "safe" } }, + "GetPrunedTraceByID": { + "tag": "APM Trace", + "undo": { + "type": "safe" + } + }, "QueryScalarData": { "tag": "Metrics", "undo": { @@ -8091,6 +8097,12 @@ "type": "safe" } }, + "GetTraceByID": { + "tag": "APM Trace", + "undo": { + "type": "safe" + } + }, "GetUsageApplicationSecurityMonitoring": { "tag": "Usage Metering", "undo": {