ersalil commented on issue #68282:
URL: https://github.com/apache/airflow/issues/68282#issuecomment-4659456560

   ## Additional findings worth noting
   
   ### 1. The OTel SDK error message is misleading
   
   The crash shows `"Expected ASCII string of maximum length 63 characters"` 
which makes it look like a length problem. It is not.
   
   I verified that the installed OTel Python SDK (`opentelemetry-sdk 1.42.1`) 
actually validates instrument names against the regex 
`[a-zA-Z][-_./a-zA-Z0-9]{0,254}`, which allows **up to 255 characters** — 
matching Airflow's own `OTEL_NAME_MAX_LENGTH = 255`. The `"63 characters"` in 
the error message is a [stale string left 
over](https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py#L48C1-L50C2)
 from an older version of the OTel spec. The actual validation was updated to 
255 chars in 
[open-telemetry/opentelemetry-python#3442](https://github.com/open-telemetry/opentelemetry-python/pull/3442)
 (released in v1.21.0, September 2023), but the error message string was never 
updated alongside it.
   
   The real reason the name is rejected is the **space character** in 
`PBI_SKU_Performance copy`, which is not in the allowed character set. Length 
is not the issue here.
   
   ### 2. `gauge()` was missing the `name_is_otel_safe()` guard
   
   `incr()`, `decr()`, and `timing()` all gate metric emission behind two 
checks:
   
   ```python
   if self.metrics_validator.test(stat) and name_is_otel_safe(self.prefix, 
stat):
   ...
   
   gauge() only had the first check:
   if self.metrics_validator.test(stat):   # no name_is_otel_safe()
   ...
   ```
   The metrics_validator only filters by allow/block list patterns — it knows 
nothing about OTel naming rules. So the space in PBI_SKU_Performance copy 
passed straight through it and reached meter.create_gauge() inside the OTel 
SDK, which raised the (misleading) exception uncaught, crashing the 
DagProcessor.


-- 
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