vatsrahul1001 opened a new pull request, #67528:
URL: https://github.com/apache/airflow/pull/67528

   Manual backport of #67527 to \`v3-2-test\` for 3.2.3.
   
   The auto-backport bot can't cherry-pick this one — \`main\` and 
\`v3-2-test\` diverged in the imports block of 
\`airflow-core/src/airflow/models/callback.py\` (\`main\` has \`from 
dataclasses import dataclass\`, \`v3-2-test\` still has \`import inspect; from 
collections.abc import Callable\`), so the cherry-pick conflicts. Conflict 
resolved by keeping the v3-2-test imports and adding the new \`import json\` 
the fix needs. The \`Stats.incr\` call site (v3-2-test) vs \`stats.incr\` 
(main) needed no change — \`handle_event\` carries the v3-2-test form 
unmodified.
   
   ## Why this needs backporting
   
   \`Callback.handle_event\` crashes the triggerer when OpenTelemetry metrics 
are enabled and a deadline async callback completes with a dict-typed 
\`result\` (or dict-typed \`kwargs\`). OTel builds its aggregation key as 
\`frozenset(attributes.items())\`, which raises \`TypeError: unhashable type: 
'dict'\`. Statsd accepts non-primitive tag values silently, so OSS deployments 
on default metrics don't see it — Astronomer Astro and any deployment with 
\`[metrics] otel_*\` configured hit it consistently. Reported by the Astro 
Runtime team while exercising 3.2.2rc2-based images.
   
   ## What's in the cherry-pick
   
   - \`Callback.get_metric_info\` coerces non-primitive tag values 
(dict/list/set) to JSON strings before returning. Primitives (\`str | int | 
float | bool | None\`) pass through unchanged. \`json.dumps(..., default=str, 
sort_keys=True)\` so \`datetime\` values fall back cleanly and equivalent dicts 
in different insertion order don't split metric cardinality.
   - New regression test \`test_get_metric_info_dict_values_are_stringified\` 
asserts every tag value is a primitive and that \`frozenset(tags.items())\` 
does not raise.
   - Updates the existing \`test_get_metric_info\` to expect the 
JSON-stringified \`kwargs\` shape.
   
   ## Review feedback already addressed in #67527
   
   - \`sort_keys=True\` per @uranusjr's suggestion
   - Cross-ref comment removed from the existing test per @amoghrajesh's 
suggestion


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to