Skip to content

feat(autopilot): Add trace data detector#107589

Merged
ArthurKnaus merged 3 commits intomasterfrom
arthurknaus/tet-1708-trace-data-detector
Feb 5, 2026
Merged

feat(autopilot): Add trace data detector#107589
ArthurKnaus merged 3 commits intomasterfrom
arthurknaus/tet-1708-trace-data-detector

Conversation

@ArthurKnaus
Copy link
Copy Markdown
Member

First draft of the trace based instrumentation issue detector.
This PR's main focus is on creating the framework (fetching data, handling responses).
The prompt is to be treated as a placeholder and will undergo further optimizations in follow-up PRs.

@ArthurKnaus ArthurKnaus requested a review from a team as a code owner February 4, 2026 13:12
@linear
Copy link
Copy Markdown

linear bot commented Feb 4, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 4, 2026
"""
try:
organization = Organization.objects.get(id=organization_id)
project = Project.objects.get(id=project_id)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably also query for active projects only

Suggested change
project = Project.objects.get(id=project_id)
project = Project.objects.get(id=project_id, status=ObjectStatus.ACTIVE)

"trace_id": trace_id,
},
)
return None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bit of a nit but I think it's useful: since we have so much defensive logic, this has become quite unwieldy and hard to read - can we factor out the logical parts into functions to make it more easily readable?

From what I can tell this task does this with a lot of o11y:

    trace_metadata = sample_trace_for_instrumentation_analysis(project)
    eap_trace = get_trace_waterfall(trace_id=trace_id,organization_id=organization.id)
    client = SeerExplorerClient(
            organization,
            user=None,
            category_key=AutopilotDetectorName.TRACE_INSTRUMENTATION,
            category_value=str(trace_id),
            intelligence_level="medium",
        )
    check_trace_length()
    prompt = _build_instrumentation_prompt(trace_json, project.slug)
    create_instrumentation_issue(
                    project_id=project.id,
                    detector_name=AutopilotDetectorName.TRACE_INSTRUMENTATION,
                    title=issue.title,
                    subtitle=issue.subcategory,
                    description=f"{issue.explanation}\n\n"
                    f"**Impact**: {issue.impact}\n\n"
                    f"**Evidence**: {issue.evidence}\n\n"
                    f"**Missing Telemetry**: {issue.missing_telemetry or 'Not specified'}\n\n"
                    f"**Affected Spans**: {', '.join(issue.offender_span_ids)}",
                )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah agree, that should be solved nicer. I have a follow-up task to split tasks.py into multiple files. Then I would also split this one up and it remains clear to which detector the single util functions belong.

trace_id="abc123",
transaction_name="GET /api/users",
)
mock_get_traces.return_value = [expected_trace]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of mocks, we should be using the test factories made available to actually ingest traces, etc. and then retrieve them from storage

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@ArthurKnaus ArthurKnaus merged commit 130c2ec into master Feb 5, 2026
93 checks passed
@ArthurKnaus ArthurKnaus deleted the arthurknaus/tet-1708-trace-data-detector branch February 5, 2026 09:25
jaydgoss pushed a commit that referenced this pull request Feb 12, 2026
First draft of the trace based instrumentation issue detector.
This PR's main focus is on creating the framework (fetching data,
handling responses).
The prompt is to be treated as a placeholder and will undergo further
optimizations in follow-up PRs.
dcramer pushed a commit that referenced this pull request Feb 17, 2026
First draft of the trace based instrumentation issue detector.
This PR's main focus is on creating the framework (fetching data,
handling responses).
The prompt is to be treated as a placeholder and will undergo further
optimizations in follow-up PRs.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants