Skip to content

GitHub Issue #1130: Metrics to track R & Python package usage#7881

Open
cnathe wants to merge 6 commits into
developfrom
fb_pacakgeUsage1130
Open

GitHub Issue #1130: Metrics to track R & Python package usage#7881
cnathe wants to merge 6 commits into
developfrom
fb_pacakgeUsage1130

Conversation

@cnathe

@cnathe cnathe commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Rationale

https://github.com/LabKey/internal-issues/issues/1130

The change instruments ExternalScriptEngine to record which R packages / Python modules scripts load, so the counts get reported to mothership via SimpleMetricsService. It does this by: (1) appending a language-specific "capture epilog" to the end of the user script that writes loaded packages to a sidecar file; (2) reading that sidecar back after the run and incrementing a per-package counter; and (3) adding a PythonScriptEngine subclass plus manager wiring to detect .py engines. All metric work is wrapped so it can never break script execution.

Related Pull Requests

Changes

  • ExternalScriptEngine refactor to allow for getPackageCaptureEpilog, recordPackageUsage, and recordSuccessfulRun overrides
  • RScriptEngine implementations for tracking package usages and recording via ScriptPackageUsageTracker.record()
  • PythonScriptEngine implementations for tracking package usages and recording via ScriptPackageUsageTracker.record()
  • ScriptPackageUsageTracker to use SimpleMetricsService to increment count of number of times a package was used

@cnathe cnathe self-assigned this Jul 24, 2026
@cnathe

cnathe commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@labkey-jeckels @labkey-matthewb note that this approach doesn't track anything for Jupyter reports or those that run via Rserve. Thoughts?

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