-
Notifications
You must be signed in to change notification settings - Fork 412
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 romain.komorn/SDTEST-225/use_bytearrays_for_…
…coverage
- Loading branch information
Showing
6 changed files
with
121 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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__) | ||
|
||
|
||
class ENDPOINT(str, Enum): | ||
TEST_CYCLE = "test_cycle" | ||
CODE_COVERAGE = "code_coverage" | ||
|
||
|
||
class ENDPOINT_PAYLOAD_TELEMETRY(str, Enum): | ||
BYTES = "endpoint_payload.bytes" | ||
REQUESTS_COUNT = "endpoint_payload.requests" | ||
REQUESTS_MS = "endpoint_payload.requests_ms" | ||
REQUESTS_ERRORS = "endpoint_payload.requests_errors" | ||
EVENTS_COUNT = "endpoint_payload.events_count" | ||
EVENTS_SERIALIZATION_MS = "endpoint_payload.events_serialization_ms" | ||
|
||
|
||
class REQUEST_ERROR_TYPE(str, Enum): | ||
TIMEOUT = "timeout" | ||
NETWORK = "network" | ||
STATUS_CODE = "status_code" | ||
|
||
|
||
def record_endpoint_payload_bytes(endpoint: ENDPOINT, nbytes: int) -> None: | ||
log.debug("Recording endpoint payload bytes: %s, %s", endpoint, nbytes) | ||
tags = (("endpoint", endpoint.value),) | ||
telemetry_writer.add_distribution_metric(_NAMESPACE, ENDPOINT_PAYLOAD_TELEMETRY.BYTES.value, nbytes, tags) | ||
|
||
|
||
def record_endpoint_payload_request(endpoint: ENDPOINT) -> None: | ||
log.debug("Recording endpoint payload request: %s", endpoint) | ||
tags = (("endpoint", endpoint.value),) | ||
telemetry_writer.add_count_metric(_NAMESPACE, ENDPOINT_PAYLOAD_TELEMETRY.REQUESTS_COUNT.value, 1, tags) | ||
|
||
|
||
def record_endpoint_payload_request_time(endpoint: ENDPOINT, seconds: float) -> None: | ||
log.debug("Recording endpoint payload request time: %s, %s seconds", endpoint, seconds) | ||
tags = (("endpoint", endpoint.value),) | ||
telemetry_writer.add_distribution_metric( | ||
_NAMESPACE, ENDPOINT_PAYLOAD_TELEMETRY.REQUESTS_MS.value, seconds * 1000, tags | ||
) | ||
|
||
|
||
def record_endpoint_payload_request_error(endpoint: ENDPOINT, error_type: REQUEST_ERROR_TYPE) -> None: | ||
log.debug("Recording endpoint payload request error: %s, %s", endpoint, error_type) | ||
tags = (("endpoint", endpoint.value), ("error_type", error_type)) | ||
telemetry_writer.add_count_metric(_NAMESPACE, ENDPOINT_PAYLOAD_TELEMETRY.REQUESTS_ERRORS.value, 1, tags) | ||
|
||
|
||
def record_endpoint_payload_events_count(endpoint: ENDPOINT, count: int) -> None: | ||
log.debug("Recording endpoint payload events count: %s, %s", endpoint, count) | ||
tags = (("endpoint", endpoint.value),) | ||
telemetry_writer.add_distribution_metric(_NAMESPACE, ENDPOINT_PAYLOAD_TELEMETRY.EVENTS_COUNT.value, count, tags) | ||
|
||
|
||
def record_endpoint_payload_events_serialization_time(endpoint: ENDPOINT, seconds: float) -> None: | ||
log.debug("Recording endpoint payload serialization time: %s, %s seconds", endpoint, seconds) | ||
tags = (("endpoint", endpoint.value),) | ||
telemetry_writer.add_distribution_metric( | ||
_NAMESPACE, ENDPOINT_PAYLOAD_TELEMETRY.EVENTS_SERIALIZATION_MS.value, seconds * 1000, tags | ||
) |
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