mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore: add statsd support to base API and refactor (#22887)
This commit is contained in:
committed by
GitHub
parent
bed10a0e2b
commit
d00ba15c78
@@ -17,10 +17,10 @@
|
||||
import logging
|
||||
|
||||
from flask import request, Response
|
||||
from flask_appbuilder.api import BaseApi, expose, protect, safe
|
||||
from flask_appbuilder.api import expose, protect, safe
|
||||
from marshmallow import ValidationError
|
||||
|
||||
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
|
||||
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP
|
||||
from superset.explore.form_data.commands.create import CreateFormDataCommand
|
||||
from superset.explore.form_data.commands.delete import DeleteFormDataCommand
|
||||
from superset.explore.form_data.commands.get import GetFormDataCommand
|
||||
@@ -32,21 +32,15 @@ from superset.temporary_cache.commands.exceptions import (
|
||||
TemporaryCacheAccessDeniedError,
|
||||
TemporaryCacheResourceNotFoundError,
|
||||
)
|
||||
from superset.views.base_api import requires_json
|
||||
from superset.views.base_api import BaseSupersetApi, requires_json, statsd_metrics
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ExploreFormDataRestApi(BaseApi):
|
||||
class ExploreFormDataRestApi(BaseSupersetApi):
|
||||
add_model_schema = FormDataPostSchema()
|
||||
edit_model_schema = FormDataPutSchema()
|
||||
method_permission_name = MODEL_API_RW_METHOD_PERMISSION_MAP
|
||||
include_route_methods = {
|
||||
RouteMethod.POST,
|
||||
RouteMethod.PUT,
|
||||
RouteMethod.GET,
|
||||
RouteMethod.DELETE,
|
||||
}
|
||||
allow_browser_login = True
|
||||
class_permission_name = "ExploreFormDataRestApi"
|
||||
resource_name = "explore"
|
||||
@@ -56,6 +50,7 @@ class ExploreFormDataRestApi(BaseApi):
|
||||
@expose("/form_data", methods=["POST"])
|
||||
@protect()
|
||||
@safe
|
||||
@statsd_metrics
|
||||
@event_logger.log_this_with_context(
|
||||
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.post",
|
||||
log_to_statsd=False,
|
||||
@@ -120,6 +115,7 @@ class ExploreFormDataRestApi(BaseApi):
|
||||
@expose("/form_data/<string:key>", methods=["PUT"])
|
||||
@protect()
|
||||
@safe
|
||||
@statsd_metrics
|
||||
@event_logger.log_this_with_context(
|
||||
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put",
|
||||
log_to_statsd=True,
|
||||
@@ -193,6 +189,7 @@ class ExploreFormDataRestApi(BaseApi):
|
||||
@expose("/form_data/<string:key>", methods=["GET"])
|
||||
@protect()
|
||||
@safe
|
||||
@statsd_metrics
|
||||
@event_logger.log_this_with_context(
|
||||
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get",
|
||||
log_to_statsd=True,
|
||||
@@ -244,6 +241,7 @@ class ExploreFormDataRestApi(BaseApi):
|
||||
@expose("/form_data/<string:key>", methods=["DELETE"])
|
||||
@protect()
|
||||
@safe
|
||||
@statsd_metrics
|
||||
@event_logger.log_this_with_context(
|
||||
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.delete",
|
||||
log_to_statsd=True,
|
||||
|
||||
Reference in New Issue
Block a user