Skip to content

feat: add control plane event tracking#149

Merged
datasciencemonkey merged 2 commits intomainfrom
feat/telemetry-tracking
Apr 29, 2026
Merged

feat: add control plane event tracking#149
datasciencemonkey merged 2 commits intomainfrom
feat/telemetry-tracking

Conversation

@datasciencemonkey
Copy link
Copy Markdown
Owner

@datasciencemonkey datasciencemonkey commented Apr 28, 2026

Summary

  • Adds SDK User-Agent based control plane event tracking so CoDA usage appears on the shared Labs usage dashboard
  • Follows the DQX pattern: piggybacks on the Databricks SDK's User-Agent header, transmits via clusters.select_spark_version()
  • All events fire in background daemon threads — never blocks Flask request handling or terminal I/O
  • Fire-and-forget: errors are caught and logged, never raised

Control Plane Events

Active Events (explicit log_telemetry() calls)

Event Key Value Location When it fires
App startup event app_startup app.py:initialize_app() Once per app start/restart
Session creation agent claude|codex|gemini|opencode|hermes|shell app.py:create_session() Every new terminal pane
File upload event file_upload app.py:upload_file() Every clipboard paste / file upload
PAT rotation event pat_rotation pat_rotator.py:_rotate_once() Every 10 minutes (while sessions exist)
Workspace sync event workspace_sync sync_to_workspace.py:sync_project() Every git commit inside ~/projects/

Passive Events (product_info on existing SDK calls)

All existing WorkspaceClient instances now carry _product_info = ('coda', version), so regular SDK calls (identity lookups, Apps API, workspace sync) also identify CoDA in the User-Agent header:

  • app.py:_setup_git_config() — git identity lookup
  • app.py:get_token_owner() — owner resolution (Apps API + PAT fallback)
  • sync_to_workspace.py:get_user_email() — workspace sync user lookup

Files Changed

File Change
telemetry.py Newlog_telemetry(), @telemetry_logger(), set_product_info()
tests/test_telemetry.py New — 17 tests covering all telemetry functions
app.py Import + 3 integration points + set_product_info on 3 WS clients
pat_rotator.py log_telemetry call after successful rotation
sync_to_workspace.py log_telemetry call after successful sync + set_product_info

Design Decisions

  • Background threads instead of synchronous (DQX pattern is sync) — CoDA is a long-running web server, not a batch Spark job
  • No env vars for WS client — reads from ~/.databrickscfg which pat_rotator.py keeps updated
  • No DataFrame-level tracking — CoDA is a terminal app, not a data quality engine
  • Decorator adapted — DQX's @telemetry_logger expects self.ws on class methods; CoDA's version works on standalone functions by creating its own WS client

Test plan

  • 17 new tests in tests/test_telemetry.py — all passing
  • Full test suite: 215 passed, 1 failed (pre-existing test isolation issue in test_session_detach.py, unrelated)

Adds SDK User-Agent based event tracking so CoDA usage appears on the
shared Labs usage dashboard. Events fire in background daemon threads
and never block Flask request handling or terminal I/O.

Active events tracked:
- app_startup (initialize_app)
- agent session creation with agent type (create_session)
- file_upload (upload_file)
- pat_rotation (_rotate_once)
- workspace_sync (sync_project)

Passive: all existing WorkspaceClient instances now carry product_info
('coda', version) so regular SDK calls also identify CoDA.

Reference: https://github.com/databrickslabs/dqx/blob/main/src/databricks/labs/dqx/telemetry.py
@datasciencemonkey datasciencemonkey self-assigned this Apr 28, 2026
@datasciencemonkey datasciencemonkey merged commit e66df70 into main Apr 29, 2026
1 check passed
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.

1 participant