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

feat(metrics): add full config update to audit log for span attribute extraction rules #74831

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/sentry/api/endpoints/project_metrics_extraction_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def has_feature(self, organization, request):
"organizations:custom-metrics-extraction-rule", organization, actor=request.user
)

def _create_audit_entry(self, event: str, project: Project, span_attribute: str):
def _create_audit_entry(
self, event: str, project: Project, span_attribute: str, config_update: str
):
self.create_audit_entry(
request=self.request,
organization=project.organization,
Expand All @@ -71,6 +73,7 @@ def _create_audit_entry(self, event: str, project: Project, span_attribute: str)
data={
"span_attribute": span_attribute,
"project_slug": project.slug,
"config_update": config_update,
},
)

Expand All @@ -91,7 +94,10 @@ def delete(self, request: Request, project: Project) -> Response:
)
for config in config_update:
self._create_audit_entry(
"SPAN_BASED_METRIC_DELETE", project, config["spanAttribute"]
"SPAN_BASED_METRIC_DELETE",
project,
config["spanAttribute"],
str(config_update),
)

return Response(status=204)
Expand Down Expand Up @@ -142,7 +148,10 @@ def post(self, request: Request, project: Project) -> Response:
)
for config in configs:
self._create_audit_entry(
"SPAN_BASED_METRIC_CREATE", project, config.span_attribute
"SPAN_BASED_METRIC_CREATE",
project,
config.span_attribute,
str(config_update),
)

persisted_config = serialize(
Expand All @@ -167,7 +176,9 @@ def put(self, request: Request, project: Project) -> Response:
project_id=project.id, trigger="span_attribute_extraction_configs"
)
for config in configs:
self._create_audit_entry("SPAN_BASED_METRIC_UPDATE", project, config.span_attribute)
self._create_audit_entry(
"SPAN_BASED_METRIC_UPDATE", project, config.span_attribute, str(config_update)
)

persisted_config = serialize(
configs,
Expand Down
Loading