fix: widen telemetry fields and require complete batch acknowledgement (#2652)

This commit is contained in:
RockChinQ
2026-10-12 09:39:21 +08:00
committed by GitHub
parent 4bcf6e6894
commit 8ae182dbd7
5 changed files with 48 additions and 5 deletions
+2 -2
View File
@@ -255,7 +255,7 @@ class ExecutionCounters:
if family not in FAMILIES or mode not in MODES or outcome not in OUTCOMES:
return
# Only code-defined identifiers are accepted; never pass user values.
if any(not isinstance(v, str) or len(v) > 160 for v in (operation, adapter, runner, node)):
if any(not isinstance(v, str) or len(v.encode('utf-8')) > 512 for v in (operation, adapter, runner, node)):
return
state = trace_mod.current()
if state is None:
@@ -602,7 +602,7 @@ def ingress(
ap,
context,
family='platform_event',
operation=str(synthetic_event)[:160],
operation=str(synthetic_event)[:512],
outcome='success',
synthetic=True,
node=node,
+2 -2
View File
@@ -29,8 +29,8 @@ import json
import typing
MAX_ITEMS_PER_LIST = 64
MAX_NAME_CHARS = 160
MAX_RESOURCES_BYTES = 8 * 1024
MAX_NAME_CHARS = 512
MAX_RESOURCES_BYTES = 32 * 1024
_resources: contextvars.ContextVar[dict[str, typing.Any] | None] = contextvars.ContextVar(
'telemetry_resources', default=None
+14
View File
@@ -159,6 +159,7 @@ class TelemetryManager:
else:
# Detect application-level errors inside HTTP 200 responses
app_err = False
j = None
try:
j = await httpclient.parse_json_response(resp)
app_code = j.get('code') if isinstance(j, dict) else None
@@ -181,6 +182,19 @@ class TelemetryManager:
f'Telemetry posted to {url}, status {resp.status_code} - response: {body}'
)
if not app_err:
if isinstance(sanitized.get('records'), list):
ack = j.get('data') if isinstance(j, dict) else None
if (
not isinstance(ack, dict)
or type(ack.get('stored')) is not int
or type(ack.get('rejected')) is not int
or ack['rejected'] != 0
or ack['stored'] != len(sanitized['records'])
):
self.ap.logger.warning(
'Telemetry batch was not fully acknowledged; retaining records'
)
return False
return True
except asyncio.TimeoutError:
self.ap.logger.debug(f'Telemetry post to {url} timed out')