-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
include_percentiles
field in Logs Custom Metrics (#1224)
Co-authored-by: ci.datadog-api-spec <[email protected]>
- Loading branch information
1 parent
7d7b1e1
commit 607a713
Showing
17 changed files
with
235 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Update a log-based metric with include_percentiles field returns "OK" response | ||
""" | ||
|
||
from os import environ | ||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v2.api.logs_metrics_api import LogsMetricsApi | ||
from datadog_api_client.v2.model.logs_metric_type import LogsMetricType | ||
from datadog_api_client.v2.model.logs_metric_update_attributes import LogsMetricUpdateAttributes | ||
from datadog_api_client.v2.model.logs_metric_update_compute import LogsMetricUpdateCompute | ||
from datadog_api_client.v2.model.logs_metric_update_data import LogsMetricUpdateData | ||
from datadog_api_client.v2.model.logs_metric_update_request import LogsMetricUpdateRequest | ||
|
||
# there is a valid "logs_metric_percentile" in the system | ||
LOGS_METRIC_PERCENTILE_DATA_ID = environ["LOGS_METRIC_PERCENTILE_DATA_ID"] | ||
|
||
body = LogsMetricUpdateRequest( | ||
data=LogsMetricUpdateData( | ||
type=LogsMetricType.LOGS_METRICS, | ||
attributes=LogsMetricUpdateAttributes( | ||
compute=LogsMetricUpdateCompute( | ||
include_percentiles=False, | ||
), | ||
), | ||
), | ||
) | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = LogsMetricsApi(api_client) | ||
response = api_instance.update_logs_metric(metric_id=LOGS_METRIC_PERCENTILE_DATA_ID, body=body) | ||
|
||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/datadog_api_client/v2/model/logs_metric_update_compute.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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 Union | ||
|
||
from datadog_api_client.model_utils import ( | ||
ModelNormal, | ||
cached_property, | ||
unset, | ||
UnsetType, | ||
) | ||
|
||
|
||
class LogsMetricUpdateCompute(ModelNormal): | ||
@cached_property | ||
def openapi_types(_): | ||
return { | ||
"include_percentiles": (bool,), | ||
} | ||
|
||
attribute_map = { | ||
"include_percentiles": "include_percentiles", | ||
} | ||
|
||
def __init__(self_, include_percentiles: Union[bool, UnsetType] = unset, **kwargs): | ||
""" | ||
The compute rule to compute the log-based metric. | ||
:param include_percentiles: Toggle to include or exclude percentile aggregations for distribution metrics. | ||
Only present when the ``aggregation_type`` is ``distribution``. | ||
:type include_percentiles: bool, optional | ||
""" | ||
if include_percentiles is not unset: | ||
kwargs["include_percentiles"] = include_percentiles | ||
super().__init__(kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/v2/cassettes/test_scenarios/test_create_a_logbased_metric_returns_ok_response.frozen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2022-05-12T09:52:22.599Z | ||
2022-11-21T15:36:05.545Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...s/test_update_a_logbased_metric_with_include_percentiles_field_returns_ok_response.frozen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2022-11-21T19:49:25.214Z |
Oops, something went wrong.