Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(logging): Clean up statsd logging #25847

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sebastianliebscher
Copy link
Contributor

@sebastianliebscher sebastianliebscher commented Nov 2, 2023

SUMMARY

This PR removes the log_to_statsd= functionality from the @event_logger and replaces usage with already existing @statsd_metrics decorator. I basically moved BaseSupersetApiMixin from base_api.py --> base.py so that the flask views can use @statsd_metrics too.

Currently, there are two decorators for basically the same use case:

  • @event_logger.log_this_with_context(log_to_statsd=True)
  • @statsd_metrics

The @event_logger just increments a statsd counter, while @statsd_metrics additionally measures the execution time of a function.

TESTING INSTRUCTIONS

  • run unit + integration tests
  • manually checked for new statsd metrics

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Comment on lines 36 to 39
@expose("/", methods=("GET",))
@statsd_metrics
@event_logger.log_this
@protect()
Copy link
Contributor Author

@sebastianliebscher sebastianliebscher Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most API endpoints already use @statsd_metrics. When this decorator is added to replace implicit log_to_statsd=True like in this example, the statsd metric

  • superset_<Endpoint>

will be replaced by

  • superset_<Class>_<Endpoint>_success|warning|error
  • superset_<Class>_<Endpoint>_time
  • superset_<Class>_<Endpoint>_time_count
  • superset_<Class>_<Endpoint>_time_sum

So it is kind of a breaking change.

@john-bodley
Copy link
Member

Thanks @sebastianliebscher for the refactor/cleanup. Given (as you mentioned) this is a breaking change, i.e., the logged statsD metric name will change it seems like we would have to wait until the breaking window opens for 4.0 (circa Q1 2024) before merging.

In the interim I was wondering whether there is a workaround? One could double log the metric (which does pollute the metric space) and add deprecation logic in 3.1 (slated for late Q4 2023) and then remove the double logging in 4.0.

cc @michael-s-molina

@michael-s-molina
Copy link
Member

One could double log the metric (which does pollute the metric space) and add deprecation logic in 3.1 (slated for late Q4 2023) and then remove the double logging in 4.0.

@john-bodley This seems like too much for something that is not urgent. I think it would be better to just wait for the breaking window.

@sfirke sfirke added the hold! On hold label Jan 19, 2024
@rusackas
Copy link
Member

Putting this one on our 5.0 project board as well. This one looks like it needs a big ol' rebase, though, at some point before October-ish.

@rusackas
Copy link
Member

I'll just convert it to Draft for now, but please feel free to mark it as "Ready for Review" when it's rebased.

@rusackas rusackas marked this pull request as draft August 26, 2024 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Proposals - Not proposed for consensus
Development

Successfully merging this pull request may close these issues.

5 participants