Skip to content

feat(mcp-insights): project flag #95218

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

Merged
merged 4 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ preprod: 0010_actual_drop_preprod_artifact_analysis_file_id_col

replays: 0006_add_bulk_delete_job

sentry: 0945_move_discover_models
sentry: 0946_add_has_mcp_insights_flag

social_auth: 0003_social_auth_json_field

Expand Down
3 changes: 3 additions & 0 deletions src/sentry/api/serializers/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class ProjectSerializerBaseResponse(_ProjectSerializerOptionalBaseResponse):
hasInsightsQueues: bool
hasInsightsLlmMonitoring: bool
hasInsightsAgentMonitoring: bool
hasInsightsMCP: bool


class ProjectSerializerResponse(ProjectSerializerBaseResponse):
Expand Down Expand Up @@ -552,6 +553,7 @@ def serialize(
"hasInsightsQueues": bool(obj.flags.has_insights_queues),
"hasInsightsLlmMonitoring": bool(obj.flags.has_insights_llm_monitoring),
"hasInsightsAgentMonitoring": bool(obj.flags.has_insights_agent_monitoring),
"hasInsightsMCP": bool(obj.flags.has_insights_mcp),
"isInternal": obj.is_internal_project(),
"isPublic": obj.public,
# Projects don't have avatar uploads, but we need to maintain the payload shape for
Expand Down Expand Up @@ -800,6 +802,7 @@ def serialize( # type: ignore[override] # intentionally different data shape
hasInsightsQueues=bool(obj.flags.has_insights_queues),
hasInsightsLlmMonitoring=bool(obj.flags.has_insights_llm_monitoring),
hasInsightsAgentMonitoring=bool(obj.flags.has_insights_agent_monitoring),
hasInsightsMCP=bool(obj.flags.has_insights_mcp),
platform=obj.platform,
platforms=attrs["platforms"],
latestRelease=attrs["latest_release"],
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/apidocs/examples/organization_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ class OrganizationExamples:
"hasInsightsQueues": False,
"hasInsightsLlmMonitoring": False,
"hasInsightsAgentMonitoring": False,
"hasInsightsMCP": False,
"platform": "node",
"platforms": [],
"latestRelease": None,
Expand Down Expand Up @@ -452,6 +453,7 @@ class OrganizationExamples:
"hasInsightsQueues": False,
"hasInsightsLlmMonitoring": False,
"hasInsightsAgentMonitoring": False,
"hasInsightsMCP": False,
"latestRelease": None,
}
],
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/apidocs/examples/project_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"hasInsightsQueues": False,
"hasInsightsLlmMonitoring": False,
"hasInsightsAgentMonitoring": False,
"hasInsightsMCP": False,
"isInternal": False,
"isPublic": False,
"avatar": {"avatarType": "letter_avatar", "avatarUuid": None},
Expand Down Expand Up @@ -341,6 +342,7 @@
"hasInsightsQueues": True,
"hasInsightsLlmMonitoring": False,
"hasInsightsAgentMonitoring": False,
"hasInsightsMCP": False,
"platform": "node-express",
"platforms": [],
"latestRelease": None,
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/apidocs/examples/team_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class TeamExamples:
"hasInsightsQueues": False,
"hasInsightsLlmMonitoring": False,
"hasInsightsAgentMonitoring": False,
"hasInsightsMCP": False,
"isInternal": False,
"isPublic": False,
"avatar": {"avatarType": "letter_avatar", "avatarUuid": None},
Expand Down Expand Up @@ -307,6 +308,7 @@ class TeamExamples:
"hasInsightsQueues": False,
"hasInsightsLlmMonitoring": False,
"hasInsightsAgentMonitoring": False,
"hasInsightsMCP": False,
"isInternal": False,
"isPublic": False,
"avatar": {"avatarType": "letter_avatar", "avatarUuid": None},
Expand Down
68 changes: 68 additions & 0 deletions src/sentry/migrations/0946_add_has_mcp_insights_flag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 5.2.1 on 2025-07-10 09:55

from django.db import migrations

import bitfield.models
from sentry.new_migrations.migrations import CheckedMigration


class Migration(CheckedMigration):
# This flag is used to mark that a migration shouldn't be automatically run in production.
# This should only be used for operations where it's safe to run the migration after your
# code has deployed. So this should not be used for most operations that alter the schema
# of a table.
# Here are some things that make sense to mark as post deployment:
# - Large data migrations. Typically we want these to be run manually so that they can be
# monitored and not block the deploy for a long period of time while they run.
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
# run this outside deployments so that we don't block them. Note that while adding an index
# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = False

dependencies = [
("sentry", "0945_move_discover_models"),
]

operations = [
migrations.AlterField(
model_name="project",
name="flags",
field=bitfield.models.BitField(
[
"has_releases",
"has_issue_alerts_targeting",
"has_transactions",
"has_alert_filters",
"has_sessions",
"has_profiles",
"has_replays",
"has_feedbacks",
"has_new_feedbacks",
"spike_protection_error_currently_active",
"spike_protection_transaction_currently_active",
"spike_protection_attachment_currently_active",
"has_minified_stack_trace",
"has_cron_monitors",
"has_cron_checkins",
"has_sourcemaps",
"has_custom_metrics",
"has_high_priority_alerts",
"has_insights_http",
"has_insights_db",
"has_insights_assets",
"has_insights_app_start",
"has_insights_screen_load",
"has_insights_vitals",
"has_insights_caches",
"has_insights_queues",
"has_insights_llm_monitoring",
"has_flags",
"has_insights_agent_monitoring",
"has_insights_mcp",
],
default=10,
),
),
]
3 changes: 3 additions & 0 deletions src/sentry/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ class flags(TypedClassBitField):
# This Project has sent insight agent monitoring spans
has_insights_agent_monitoring: bool

# This Project has sent insight MCP spans
has_insights_mcp: bool

bitfield_default = 10

objects: ClassVar[ProjectManager] = ProjectManager(cache_fields=["pk"])
Expand Down
1 change: 1 addition & 0 deletions src/sentry/projects/services/project/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class RpcProjectFlags(RpcModel):
has_insights_llm_monitoring: bool
has_flags: bool
has_insights_agent_monitoring: bool
has_insights_mcp: bool


class RpcProject(RpcModel):
Expand Down
3 changes: 3 additions & 0 deletions tests/sentry/api/serializers/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ def test_has_insight_module_flags(self):
assert result["hasInsightsQueues"] is False
assert result["hasInsightsLlmMonitoring"] is False
assert result["hasInsightsAgentMonitoring"] is False
assert result["hasInsightsMCP"] is False

self.project.first_event = timezone.now()
self.project.update(flags=F("flags").bitor(Project.flags.has_insights_http))
Expand All @@ -468,6 +469,7 @@ def test_has_insight_module_flags(self):
self.project.update(flags=F("flags").bitor(Project.flags.has_insights_queues))
self.project.update(flags=F("flags").bitor(Project.flags.has_insights_llm_monitoring))
self.project.update(flags=F("flags").bitor(Project.flags.has_insights_agent_monitoring))
self.project.update(flags=F("flags").bitor(Project.flags.has_insights_mcp))

result = serialize(self.project, self.user, ProjectSummarySerializer())
assert result["hasInsightsHttp"] is True
Expand All @@ -480,6 +482,7 @@ def test_has_insight_module_flags(self):
assert result["hasInsightsQueues"] is True
assert result["hasInsightsLlmMonitoring"] is True
assert result["hasInsightsAgentMonitoring"] is True
assert result["hasInsightsMCP"] is True

def test_has_flags_flag(self):
result = serialize(self.project, self.user, ProjectSummarySerializer())
Expand Down
Loading