-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into quinna/update-pymongo-test
- Loading branch information
Showing
12 changed files
with
593 additions
and
229 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,49 @@ | ||
import dataclasses | ||
from typing import Optional | ||
|
||
from ddtrace.internal.ci_visibility.telemetry.constants import CIVISIBILITY_TELEMETRY_NAMESPACE as _NAMESPACE | ||
from ddtrace.internal.ci_visibility.telemetry.constants import ERROR_TYPES | ||
from ddtrace.internal.logger import get_logger | ||
from ddtrace.internal.telemetry import telemetry_writer | ||
|
||
|
||
log = get_logger(__name__) | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class APIRequestMetricNames: | ||
count: str | ||
duration: str | ||
response_bytes: Optional[str] | ||
error: str | ||
|
||
|
||
def record_api_request( | ||
metric_names: APIRequestMetricNames, | ||
duration: float, | ||
response_bytes: Optional[int] = None, | ||
error: Optional[ERROR_TYPES] = None, | ||
): | ||
log.debug( | ||
"Recording early flake detection telemetry for %s: %s, %s, %s", | ||
metric_names.count, | ||
duration, | ||
response_bytes, | ||
error, | ||
) | ||
|
||
telemetry_writer.add_count_metric(_NAMESPACE, f"{metric_names.count}", 1) | ||
telemetry_writer.add_distribution_metric(_NAMESPACE, f"{metric_names.duration}", duration) | ||
if response_bytes is not None: | ||
if metric_names.response_bytes is not None: | ||
# We don't always want to record response bytes (for settings requests), so assume that no metric name | ||
# means we don't want to record it. | ||
telemetry_writer.add_distribution_metric(_NAMESPACE, f"{metric_names.response_bytes}", response_bytes) | ||
|
||
if error is not None: | ||
record_api_request_error(metric_names.error, error) | ||
|
||
|
||
def record_api_request_error(error_metric_name: str, error: ERROR_TYPES): | ||
log.debug("Recording early flake detection request error telemetry: %s", error) | ||
telemetry_writer.add_count_metric(_NAMESPACE, error_metric_name, 1, (("error_type", error),)) |
24 changes: 24 additions & 0 deletions
24
ddtrace/internal/ci_visibility/telemetry/early_flake_detection.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,24 @@ | ||
from enum import Enum | ||
|
||
from ddtrace.internal.ci_visibility.telemetry.constants import CIVISIBILITY_TELEMETRY_NAMESPACE as _NAMESPACE | ||
from ddtrace.internal.logger import get_logger | ||
from ddtrace.internal.telemetry import telemetry_writer | ||
|
||
|
||
log = get_logger(__name__) | ||
|
||
EARLY_FLAKE_DETECTION_TELEMETRY_PREFIX = "early_flake_detection." | ||
RESPONSE_TESTS = f"{EARLY_FLAKE_DETECTION_TELEMETRY_PREFIX}response_tests" | ||
|
||
|
||
class EARLY_FLAKE_DETECTION_TELEMETRY(str, Enum): | ||
REQUEST = "early_flake_detection.request" | ||
REQUEST_MS = "early_flake_detection.request_ms" | ||
REQUEST_ERRORS = "early_flake_detection.request_errors" | ||
RESPONSE_BYTES = "early_flake_detection.response_bytes" | ||
RESPONSE_TESTS = "early_flake_detection.response_tests" | ||
|
||
|
||
def record_early_flake_detection_tests_count(early_flake_detection_count: int): | ||
log.debug("Recording early flake detection tests count telemetry: %s", early_flake_detection_count) | ||
telemetry_writer.add_count_metric(_NAMESPACE, RESPONSE_TESTS, early_flake_detection_count) |
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
Oops, something went wrong.