Skip to content

Conversation

@BupycHuk
Copy link
Member

@BupycHuk BupycHuk commented Dec 4, 2025

Summary

Implements PMM-14567: Create Database Schema for Feature Configuration using Option 3 - Create Record in Agents Table.

This PR adds a new agent type mongodb-realtime-agent that uses the existing agents table infrastructure to store real-time analytics enable/disable status per service.

Key Changes

  • New Agent Type: Added MongoDBRealtimeAgentType constant
  • Credential Retrieval: Implemented CreateMongoDBRealtimeAgent() helper that retrieves credentials from existing MongoDB agents (QAN/exporter) for the service
  • Agent Infrastructure: Leverages existing agent lifecycle management (agent status represents enabled/disabled state)
  • Proto Definitions: Added agent type enum and message definitions
  • DSN Support: Updated DSN and Files helpers to handle the new agent type

Implementation Details

  • No database migration needed - existing agents table supports the new type
  • Credentials are automatically retrieved from existing MongoDB agents during creation
  • Agent status (running/stopped) represents enabled/disabled state
  • Follows existing PMM agent patterns and conventions

Files Changed

  • api/inventory/v1/agents.proto: Added AGENT_TYPE_MONGODB_REALTIME_AGENT enum and messages
  • managed/models/agent_model.go: Added MongoDBRealtimeAgentType constant and DSN support
  • managed/models/agent_helpers.go: Added CreateMongoDBRealtimeAgent() helper function
  • managed/models/dsn_helpers.go: Updated to include new agent type in service lookups

Test Plan

  • Verify agent type constant is added correctly
  • Verify DSN helpers handle new agent type
  • Verify Files() method includes new agent type for certificate handling
  • Verify CreateMongoDBRealtimeAgent() helper retrieves credentials from existing agents
  • Code follows existing patterns and conventions
  • Manual testing: Create MongoDB realtime agent with existing service
  • Manual testing: Verify credentials are retrieved correctly
  • Manual testing: Verify agent status lifecycle

Implement database schema for feature configuration using Option 3:
- Create new agent record type for real-time analytics
- Add MongoDBRealtimeAgentType constant to agent types
- Use existing agents table infrastructure
- Associate agent with service
- Agent status (running/stopped) represents enabled/disabled
- Retrieve credentials from existing MongoDB agents during creation

Changes:
- Add MongoDBRealtimeAgentType constant to models
- Update DSN helpers to handle MongoDB realtime agent
- Add CreateMongoDBRealtimeAgent helper function
- Update proto file with new agent type and messages
- Add agent to Files() method for certificate handling

No database migration needed as existing agents table supports new type.
@BupycHuk BupycHuk requested a review from a team as a code owner December 4, 2025 19:11
@BupycHuk BupycHuk requested review from JiriCtvrtka and idoqo and removed request for a team December 4, 2025 19:11
@BupycHuk BupycHuk marked this pull request as draft December 4, 2025 19:12
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 12.82051% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.87%. Comparing base (84cf696) to head (45e0e79).

Files with missing lines Patch % Lines
managed/models/agent_helpers.go 2.85% 34 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           PMM-14550-rt-qan-mongo    #4805      +/-   ##
==========================================================
+ Coverage                   45.28%   45.87%   +0.59%     
==========================================================
  Files                         364      364              
  Lines                       37777    37813      +36     
==========================================================
+ Hits                        17106    17347     +241     
+ Misses                      19028    18793     -235     
- Partials                     1643     1673      +30     
Flag Coverage Δ
admin 17.92% <ø> (ø)
vmproxy 72.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Introduced RTAOptions type for future Real-Time Analytics configuration.
- Implemented database/sql/driver.Valuer and Scanner interfaces for RTAOptions.
- Updated Agent and CreateAgentParams to include RTAOptions.
- Modified database schema to add rta_options column to agents table.
- Deleted MongoDBRealtimeAgent message and its associated parameters from the proto file.
- Removed AGENT_TYPE_MONGODB_REALTIME_AGENT from AgentType enum.
- Cleaned up related comments and documentation for clarity.
@BupycHuk
Copy link
Member Author

BupycHuk commented Dec 5, 2025

@copilot run make init gen and commit changes

Copy link
Contributor

Copilot AI commented Dec 5, 2025

@BupycHuk I've opened a new pull request, #4810, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants