syun64 opened a new issue, #30716:
URL: https://github.com/apache/airflow/issues/30716

   ### Apache Airflow version
   
   2.6.0b1
   
   ### What happened
   
   The recently added **dag_processing.processes** _file_path_ metric tag 
always fails to publish the metric tag because file path delimiter '/' is not a 
valid character according to the stat_name_default_handler
   
   ```
   airflow.exceptions.InvalidStatsNameException: The stat name 
(dag_processing.processes,file_path=/mnt/c/Users/user/Documents/GitHub/airflow-dir/test_dag.py,action=finish)
 has to be composed of ASCII alphabets, numbers, or the underscore, dot, or 
dash characters.
   [2023-04-18T12:21:39.738-0400] {stats.py:245} ERROR - Invalid stat name: 
dag_processing.processes,file_path=/mnt/c/Users/user/Documents/GitHub/airflow-dir/test_dag.py,action=start.
   Traceback (most recent call last):
   File 
"/mnt/c/Users/user/Documents/GitHub/airflow-dir/venv/lib/python3.9/site-packages/airflow/stats.py",
 line 242, in wrapper
   stat = handler_stat_name_func(stat)
   File 
"/mnt/c/Users/user/Documents/GitHub/airflow-dir/venv/lib/python3.9/site-packages/airflow/stats.py",
 line 210, in stat_name_default_handler
   raise InvalidStatsNameException(
   airflow.exceptions.InvalidStatsNameException: The stat name 
(dag_processing.processes,file_path=/mnt/c/Users/user/Documents/GitHub/airflow-dir/test_dag.py,action=start)
 has to be composed of ASCII alphabets, numbers, or the underscore, dot, or 
dash characters.
   [2023-04-18T12:21:51.375-0400] {stats.py:245} ERROR - Invalid stat name: 
dag_processing.processes,file_path=/mnt/c/Users/user/Documents/GitHub/airflow-dir/test_dag.py,action=finish.
   ```
   
   ### What you think should happen instead
   
   Although it is not a fatal error it feels erroneous that the default stats 
name handler is not able to support the metric tag out of the box.
   
   We do have the following parameters that allows a user to get around this 
issue:
   
   1. stat_name_handler
   2. statsd_disabled_tags
   
   But, I would like to advocate that we include '/' as a supported character 
to stat_name_default_handler, or sanitize the file_path value to use a 
supported character instead. It would feel more intuitive for a new user using 
the feature to have metric tags work correctly with the default configurations, 
rather than needing to implement their own stat_name_handler to work around the 
issue.
   
   
   Examples Metrics:
   
https://github.com/apache/airflow/blob/main/airflow/dag_processing/manager.py#L998
   
https://github.com/apache/airflow/blob/main/airflow/dag_processing/processor.py#L767
   
   ### How to reproduce
   
   Enable stats with:
   ```
   [metrics]
   statsd_on = True
   statsd_host = localhost
   statsd_port = 8125
   statsd_prefix = 
   statsd_influxdb_enabled = True
   ```
   
   ### Operating System
   
   Red Hat Enterprise Linux Server 7.6 (Maipo)
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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: commits-unsubscr...@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to