Search query following log syntax used to filter flaky tests, same as on Flaky Tests Management UI. The supported search keys are:
flaky_test_state
flaky_test_category
@test.name
@test.suite
@test.module
@test.service
@git.repository.id_v2
@git.branch
@test.codeowners
env
default: *
include_history
boolean
Whether to include the status change history for each flaky test in the response.
When set to true, each test will include a history array with chronological status changes.
Defaults to false.
page
object
Pagination attributes for listing flaky tests.
cursor
string
List following results with a cursor provided in the previous request.
limit
int64
Maximum number of flaky tests in the response.
default: 10
sort
enum
Parameter for sorting flaky test results. The default sort is by ascending Fully Qualified Name (FQN). The FQN is the concatenation of the test module, suite, and name.
Allowed enum values: fqn,-fqn,first_flaked,-first_flaked,last_flaked,-last_flaked,failure_rate,-failure_rate,pipelines_failed,-pipelines_failedShow 2 more,pipelines_duration_lost,-pipelines_duration_lost
type
enum
The definition of FlakyTestsSearchRequestDataType object.
Allowed enum values: search_flaky_tests_request
Response object with flaky tests matching the search request.
Expand All
Campo
Tipo
Descripción
data
[object]
Array of flaky tests matching the request.
attributes
object
Attributes of a flaky test.
attempt_to_fix_id
string
Unique identifier for the attempt to fix this flaky test. Use this ID in the Git commit message in order to trigger the attempt to fix workflow.
When the workflow is triggered the test is automatically retried by the tracer a certain number of configurable times. When all retries pass, the test is automatically marked as fixed in Flaky Test Management.
Test runs are tagged with @test.test_management.attempt_to_fix_passed and @test.test_management.is_attempt_to_fix when the attempt to fix workflow is triggered.
codeowners
[string]
The name of the test's code owners as inferred from the repository configuration.
envs
[string]
List of environments where this test has been flaky.
first_flaked_branch
string
The branch name where the test exhibited flakiness for the first time.
first_flaked_sha
string
The commit SHA where the test exhibited flakiness for the first time.
first_flaked_ts
int64
Unix timestamp when the test exhibited flakiness for the first time.
flaky_category
string
The category of a flaky test.
flaky_state
enum
The current state of the flaky test.
Allowed enum values: active,fixed,quarantined,disabled
history
[object]
Chronological history of status changes for this flaky test, ordered from most recent to oldest.
Includes state transitions like new -> quarantined -> fixed, along with the associated commit SHA when available.
commit_sha [required]
string
The commit SHA associated with this status change. Will be an empty string if the commit SHA is not available.
status [required]
string
The test status at this point in history.
timestamp [required]
int64
Unix timestamp in milliseconds when this status change occurred.
last_flaked_branch
string
The branch name where the test exhibited flakiness for the last time.
last_flaked_sha
string
The commit SHA where the test exhibited flakiness for the last time.
last_flaked_ts
int64
Unix timestamp when the test exhibited flakiness for the last time.
module
string
The name of the test module. The definition of module changes slightly per language:
In .NET, a test module groups every test that is run under the same unit test project.
In Swift, a test module groups every test that is run for a given bundle.
In JavaScript, the test modules map one-to-one to test sessions.
In Java, a test module groups every test that is run by the same Maven Surefire/Failsafe or Gradle Test task execution.
In Python, a test module groups every test that is run under the same .py file as part of a test suite, which is typically managed by a framework like unittest or pytest.
In Ruby, a test module groups every test that is run within the same test file, which is typically managed by a framework like RSpec or Minitest.
name
string
The test name. A concise name for a test case. Defined in the test itself.
pipeline_stats
object
CI pipeline related statistics for the flaky test. This information is only available if test runs are associated with CI pipeline events from CI Visibility.
failed_pipelines
int64
The number of pipelines that failed due to this test for the past 7 days. This is computed as the sum of failed CI pipeline events associated with test runs where the flaky test failed.
total_lost_time_ms
int64
The total time lost by CI pipelines due to this flaky test in milliseconds. This is computed as the sum of the duration of failed CI pipeline events associated with test runs where the flaky test failed.
services
[string]
List of test service names where this test has been flaky.
A test service is a group of tests associated with a project or repository. It contains all the individual tests for your code, optionally organized into test suites, which are like folders for your tests.
suite
string
The name of the test suite. A group of tests exercising the same unit of code depending on your language and testing framework.
test_run_metadata
object
Metadata about the latest failed test run of the flaky test.
duration_ms
int64
The duration of the test run in milliseconds.
error_message
string
The error message from the test failure.
error_stack
string
The stack trace from the test failure.
source_end
int64
The line number where the test ends in the source file.
source_file
string
The source file where the test is defined.
source_start
int64
The line number where the test starts in the source file.
test_stats
object
Test statistics for the flaky test.
failure_rate_pct
double
The failure rate percentage of the test for the past 7 days. This is the number of failed test runs divided by the total number of test runs (excluding skipped test runs).
id
string
Test's ID. This ID is the hash of the test's Fully Qualified Name and Git repository ID. On the Test Runs UI it is the same as the test_fingerprint_fqn tag.
type
enum
The type of the flaky test from Flaky Test Management.
Allowed enum values: flaky_test
meta
object
Metadata for the flaky tests search response.
pagination
object
Pagination metadata for flaky tests.
next_page
string
Cursor for the next page of results.
{"data":[{"attributes":{"attempt_to_fix_id":"I42TEO","codeowners":["@foo","@bar"],"envs":"prod","first_flaked_branch":"main","first_flaked_sha":"0c6be03165b7f7ffe96e076ffb29afb2825616c3","first_flaked_ts":1757688149,"flaky_category":"Timeout","flaky_state":"active","history":[{"commit_sha":"abc123def456","status":"quarantined","timestamp":1704067200000}],"last_flaked_branch":"main","last_flaked_sha":"0c6be03165b7f7ffe96e076ffb29afb2825616c3","last_flaked_ts":1757688149,"module":"TestModule","name":"TestName","pipeline_stats":{"failed_pipelines":319,"total_lost_time_ms":1527550000},"services":["foo","bar"],"suite":"TestSuite","test_run_metadata":{"duration_ms":27398,"error_message":"Expecting actual not to be empty","error_stack":"Traceback (most recent call last):\n File \"test_foo.py\", line 10, in test_foo\n assert actual == expected\nAssertionError: Expecting actual not to be empty","source_end":20,"source_file":"test_foo.py","source_start":10},"test_stats":{"failure_rate_pct":0.1}},"id":"string","type":"string"}],"meta":{"pagination":{"next_page":"string"}}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Search flaky tests returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.searchFlakyTests"]=true;constapiInstance=newv2.TestOptimizationApi(configuration);constparams: v2.TestOptimizationApiSearchFlakyTestsRequest={body:{data:{attributes:{filter:{query:`flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"`,},includeHistory: true,page:{cursor:"eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",limit: 25,},sort:"failure_rate",},type:"search_flaky_tests_request",},},};apiInstance.searchFlakyTests(params).then((data: v2.FlakyTestsSearchResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
The ID of the flaky test. This is the same ID returned by the Search flaky tests endpoint and corresponds to the test_fingerprint_fqn field in test run events.
new_state [required]
enum
The new state to set for the flaky test.
Allowed enum values: active,quarantined,disabled,fixed
type [required]
enum
The definition of UpdateFlakyTestsRequestDataType object.
Allowed enum values: update_flaky_test_state_request
Summary of the update operations. Tells whether a test succeeded or failed to be updated.
attributes
object
Attributes for the update flaky test state response.
has_errors [required]
boolean
True if any errors occurred during the update operations. False if all tests succeeded to be updated.
results [required]
[object]
Results of the update operation for each test.
error
string
Error message if the update failed.
id [required]
string
The ID of the flaky test from the request. This is the same ID returned by the Search flaky tests endpoint and corresponds to the test_fingerprint_fqn field in test run events.
success [required]
boolean
True if the update was successful, False if there were any errors.
id
string
The ID of the response.
type
enum
The definition of UpdateFlakyTestsResponseDataType object.
Allowed enum values: update_flaky_test_state_response
"""
Update flaky test states returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.test_optimization_apiimportTestOptimizationApifromdatadog_api_client.v2.model.update_flaky_tests_requestimportUpdateFlakyTestsRequestfromdatadog_api_client.v2.model.update_flaky_tests_request_attributesimportUpdateFlakyTestsRequestAttributesfromdatadog_api_client.v2.model.update_flaky_tests_request_dataimportUpdateFlakyTestsRequestDatafromdatadog_api_client.v2.model.update_flaky_tests_request_data_typeimportUpdateFlakyTestsRequestDataTypefromdatadog_api_client.v2.model.update_flaky_tests_request_testimportUpdateFlakyTestsRequestTestfromdatadog_api_client.v2.model.update_flaky_tests_request_test_new_stateimportUpdateFlakyTestsRequestTestNewStatebody=UpdateFlakyTestsRequest(data=UpdateFlakyTestsRequestData(attributes=UpdateFlakyTestsRequestAttributes(tests=[UpdateFlakyTestsRequestTest(id="4eb1887a8adb1847",new_state=UpdateFlakyTestsRequestTestNewState.ACTIVE,),],),type=UpdateFlakyTestsRequestDataType.UPDATE_FLAKY_TEST_STATE_REQUEST,),)configuration=Configuration()configuration.unstable_operations["update_flaky_tests"]=TruewithApiClient(configuration)asapi_client:api_instance=TestOptimizationApi(api_client)response=api_instance.update_flaky_tests(body=body)print(response)
# Update flaky test states returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.update_flaky_tests".to_sym]=trueendapi_instance=DatadogAPIClient::V2::TestOptimizationAPI.newbody=DatadogAPIClient::V2::UpdateFlakyTestsRequest.new({data:DatadogAPIClient::V2::UpdateFlakyTestsRequestData.new({attributes:DatadogAPIClient::V2::UpdateFlakyTestsRequestAttributes.new({tests:[DatadogAPIClient::V2::UpdateFlakyTestsRequestTest.new({id:"4eb1887a8adb1847",new_state:DatadogAPIClient::V2::UpdateFlakyTestsRequestTestNewState::ACTIVE,}),],}),type:DatadogAPIClient::V2::UpdateFlakyTestsRequestDataType::UPDATE_FLAKY_TEST_STATE_REQUEST,}),})papi_instance.update_flaky_tests(body)
// Update flaky test states returns "OK" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){body:=datadogV2.UpdateFlakyTestsRequest{Data:datadogV2.UpdateFlakyTestsRequestData{Attributes:datadogV2.UpdateFlakyTestsRequestAttributes{Tests:[]datadogV2.UpdateFlakyTestsRequestTest{{Id:"4eb1887a8adb1847",NewState:datadogV2.UPDATEFLAKYTESTSREQUESTTESTNEWSTATE_ACTIVE,},},},Type:datadogV2.UPDATEFLAKYTESTSREQUESTDATATYPE_UPDATE_FLAKY_TEST_STATE_REQUEST,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.UpdateFlakyTests",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewTestOptimizationApi(apiClient)resp,r,err:=api.UpdateFlakyTests(ctx,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `TestOptimizationApi.UpdateFlakyTests`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `TestOptimizationApi.UpdateFlakyTests`:\n%s\n",responseContent)}
// Update flaky test states returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_test_optimization::TestOptimizationAPI;usedatadog_api_client::datadogV2::model::UpdateFlakyTestsRequest;usedatadog_api_client::datadogV2::model::UpdateFlakyTestsRequestAttributes;usedatadog_api_client::datadogV2::model::UpdateFlakyTestsRequestData;usedatadog_api_client::datadogV2::model::UpdateFlakyTestsRequestDataType;usedatadog_api_client::datadogV2::model::UpdateFlakyTestsRequestTest;usedatadog_api_client::datadogV2::model::UpdateFlakyTestsRequestTestNewState;#[tokio::main]asyncfnmain(){letbody=UpdateFlakyTestsRequest::new(UpdateFlakyTestsRequestData::new(UpdateFlakyTestsRequestAttributes::new(vec![UpdateFlakyTestsRequestTest::new("4eb1887a8adb1847".to_string(),UpdateFlakyTestsRequestTestNewState::ACTIVE,)]),UpdateFlakyTestsRequestDataType::UPDATE_FLAKY_TEST_STATE_REQUEST,));letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.UpdateFlakyTests",true);letapi=TestOptimizationAPI::with_config(configuration);letresp=api.update_flaky_tests(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Update flaky test states returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.updateFlakyTests"]=true;constapiInstance=newv2.TestOptimizationApi(configuration);constparams: v2.TestOptimizationApiUpdateFlakyTestsRequest={body:{data:{attributes:{tests:[{id:"4eb1887a8adb1847",newState:"active",},],},type:"update_flaky_test_state_request",},},};apiInstance.updateFlakyTests(params).then((data: v2.UpdateFlakyTestsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Retrieve Test Optimization settings for a specific service identified by repository, service name, and environment.
This endpoint requires the test_optimization_read permission.
OAuth apps require the test_optimization_read authorization scope to access this endpoint.
Attributes for requesting Test Optimization service settings.
env
string
The environment name. If omitted, defaults to none.
repository_id [required]
string
The repository identifier.
service_name [required]
string
The service name.
type [required]
enum
JSON:API type for get service settings request.
The value must always be test_optimization_get_service_settings_request.
Allowed enum values: test_optimization_get_service_settings_request
Response object containing Test Optimization service settings.
Expand All
Campo
Tipo
Descripción
data
object
Data object for Test Optimization service settings response.
attributes
object
Attributes for Test Optimization service settings.
auto_test_retries_enabled
boolean
Whether Auto Test Retries are enabled for this service.
code_coverage_enabled
boolean
Whether Code Coverage is enabled for this service.
early_flake_detection_enabled
boolean
Whether Early Flake Detection is enabled for this service.
env
string
The environment name.
failed_test_replay_enabled
boolean
Whether Failed Test Replay is enabled for this service.
pr_comments_enabled
boolean
Whether PR Comments are enabled for this service.
repository_id
string
The repository identifier.
service_name
string
The service name.
test_impact_analysis_enabled
boolean
Whether Test Impact Analysis is enabled for this service.
id
string
Unique identifier for the service settings.
type
enum
JSON:API type for service settings response.
The value must always be test_optimization_service_settings.
Allowed enum values: test_optimization_service_settings
Partially update Test Optimization settings for a specific service identified by repository, service name, and environment.
Only provided fields are updated; null or omitted fields are left unchanged.
This endpoint requires the test_optimization_settings_write permission.
OAuth apps require the test_optimization_settings_write authorization scope to access this endpoint.
Attributes for updating Test Optimization service settings.
All non-required fields are optional; only provided fields will be updated.
auto_test_retries_enabled
boolean
Whether Auto Test Retries are enabled for this service.
code_coverage_enabled
boolean
Whether Code Coverage is enabled for this service.
early_flake_detection_enabled
boolean
Whether Early Flake Detection is enabled for this service.
env
string
The environment name. If omitted, defaults to none.
failed_test_replay_enabled
boolean
Whether Failed Test Replay is enabled for this service.
pr_comments_enabled
boolean
Whether PR Comments are enabled for this service.
repository_id [required]
string
The repository identifier.
service_name [required]
string
The service name.
test_impact_analysis_enabled
boolean
Whether Test Impact Analysis is enabled for this service.
type [required]
enum
JSON:API type for update service settings request.
The value must always be test_optimization_update_service_settings_request.
Allowed enum values: test_optimization_update_service_settings_request
Response object containing Test Optimization service settings.
Expand All
Campo
Tipo
Descripción
data
object
Data object for Test Optimization service settings response.
attributes
object
Attributes for Test Optimization service settings.
auto_test_retries_enabled
boolean
Whether Auto Test Retries are enabled for this service.
code_coverage_enabled
boolean
Whether Code Coverage is enabled for this service.
early_flake_detection_enabled
boolean
Whether Early Flake Detection is enabled for this service.
env
string
The environment name.
failed_test_replay_enabled
boolean
Whether Failed Test Replay is enabled for this service.
pr_comments_enabled
boolean
Whether PR Comments are enabled for this service.
repository_id
string
The repository identifier.
service_name
string
The service name.
test_impact_analysis_enabled
boolean
Whether Test Impact Analysis is enabled for this service.
id
string
Unique identifier for the service settings.
type
enum
JSON:API type for service settings response.
The value must always be test_optimization_service_settings.
Allowed enum values: test_optimization_service_settings
Delete Test Optimization settings for a specific service identified by repository, service name, and environment.
This endpoint requires the test_optimization_settings_write permission.
OAuth apps require the test_optimization_settings_write authorization scope to access this endpoint.
Attributes for deleting Test Optimization service settings.
env
string
The environment name. If omitted, defaults to none.
repository_id [required]
string
The repository identifier.
service_name [required]
string
The service name.
type [required]
enum
JSON:API type for delete service settings request.
The value must always be test_optimization_delete_service_settings_request.
Allowed enum values: test_optimization_delete_service_settings_request