You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/20 19:56:51 UTC

[GitHub] [airflow] joshowen opened a new pull request #9452: JSON serialize logged extras

joshowen opened a new pull request #9452:
URL: https://github.com/apache/airflow/pull/9452


   It would be very useful to be able to query the the logged extras, to determine if a trigger has a configuration, or a clear operation is confirmed.
   
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [ ] Description above provides context of the change
   - [ ] Unit tests coverage for changes (not needed for documentation changes)
   - [ ] Target Github ISSUE in description if exists
   - [ ] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [ ] Relevant documentation is updated including usage instructions.
   - [ ] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


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

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



[GitHub] [airflow] joshowen commented on a change in pull request #9452: JSON serialize logged extras

Posted by GitBox <gi...@apache.org>.
joshowen commented on a change in pull request #9452:
URL: https://github.com/apache/airflow/pull/9452#discussion_r443156183



##########
File path: airflow/www/decorators.py
##########
@@ -44,7 +45,7 @@ def wrapper(*args, **kwargs):
                 event=f.__name__,
                 task_instance=None,
                 owner=user,
-                extra=str(list(request.values.items())),
+                extra=json.dumps(request.values),

Review comment:
       The current setup doesn't produce valid json, because it is a list of tuples.  It would also be very helpful to be able to query this information in the database, since important context lives in the `extra`, eg whether or not a clear was confirmed, or a trigger had a `conf`.




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

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



[GitHub] [airflow] kaxil commented on a change in pull request #9452: JSON serialize Log extras

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #9452:
URL: https://github.com/apache/airflow/pull/9452#discussion_r451195371



##########
File path: airflow/www/decorators.py
##########
@@ -44,7 +45,7 @@ def wrapper(*args, **kwargs):
                 event=f.__name__,
                 task_instance=None,
                 owner=user,
-                extra=str(list(request.values.items())),
+                extra=json.dumps(request.values),

Review comment:
       Thanks for the explanation, can you add a test, please




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

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



[GitHub] [airflow] joshowen commented on a change in pull request #9452: JSON serialize Log extras

Posted by GitBox <gi...@apache.org>.
joshowen commented on a change in pull request #9452:
URL: https://github.com/apache/airflow/pull/9452#discussion_r450764948



##########
File path: airflow/www/decorators.py
##########
@@ -44,7 +45,7 @@ def wrapper(*args, **kwargs):
                 event=f.__name__,
                 task_instance=None,
                 owner=user,
-                extra=str(list(request.values.items())),
+                extra=json.dumps(request.values),

Review comment:
       @kaxil to give more color, we've built an "Airflow Snitch" which alerts based on some user actions (eg user cleared a production DAG).  This relies on parsing the `extra` field to determine if the job was actually cleared since there are two trigger events, and only the `confirmed` event causes an action.
   
   We've hacked together some `extra` field parsing, but it isn't very elegant, and this could be done a lot more efficiently in the database if the column was valid json.




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

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



[GitHub] [airflow] joshowen commented on a change in pull request #9452: JSON serialize logged extras

Posted by GitBox <gi...@apache.org>.
joshowen commented on a change in pull request #9452:
URL: https://github.com/apache/airflow/pull/9452#discussion_r443156183



##########
File path: airflow/www/decorators.py
##########
@@ -44,7 +45,7 @@ def wrapper(*args, **kwargs):
                 event=f.__name__,
                 task_instance=None,
                 owner=user,
-                extra=str(list(request.values.items())),
+                extra=json.dumps(request.values),

Review comment:
       The current setup doesn't produce valid json, because it is a list of tuples.  It would also be very helpful to be able to do queries in the database, since important context lives in the `extra`, eg whether or not a clear was confirmed, or a trigger had a `conf`.




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

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



[GitHub] [airflow] kaxil commented on a change in pull request #9452: JSON serialize logged extras

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #9452:
URL: https://github.com/apache/airflow/pull/9452#discussion_r443156040



##########
File path: airflow/www/decorators.py
##########
@@ -44,7 +45,7 @@ def wrapper(*args, **kwargs):
                 event=f.__name__,
                 task_instance=None,
                 owner=user,
-                extra=str(list(request.values.items())),
+                extra=json.dumps(request.values),

Review comment:
       Why not fetch str and handle serialization on the client-side?




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

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



[GitHub] [airflow] stale[bot] commented on pull request #9452: JSON serialize Log extras

Posted by GitBox <gi...@apache.org>.
stale[bot] commented on pull request #9452:
URL: https://github.com/apache/airflow/pull/9452#issuecomment-678690384


   This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
   


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

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



[GitHub] [airflow] stale[bot] closed pull request #9452: JSON serialize Log extras

Posted by GitBox <gi...@apache.org>.
stale[bot] closed pull request #9452:
URL: https://github.com/apache/airflow/pull/9452


   


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

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



[GitHub] [airflow] boring-cyborg[bot] commented on pull request #9452: JSON serialize logged extras

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on pull request #9452:
URL: https://github.com/apache/airflow/pull/9452#issuecomment-647039140


   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, pylint and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/master/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/master/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/master/BREEZE.rst) for testing locally, itโ€™s a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better ๐Ÿš€.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://apache-airflow-slack.herokuapp.com/
   


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

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