posit-dev / posit-dev/shiny-vscode
Add opt-in OpenTelemetry auto-instrumentation when running Python apps
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 37
- Forks
- 12
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 4
Description
Motivation
posit-dev/py-shiny#2274 is making OpenTelemetry zero-code auto-instrumentation a first-class path: shiny[otel] will include opentelemetry-distro[otlp], so opentelemetry-instrument shiny run app.py works out of the box (py-shiny resolves the global tracer provider lazily, so no app-code changes are needed).
The extension could make this a one-setting experience: run the app under auto-instrumentation so users see traces (e.g. console or OTLP to a local collector) while developing, without editing their app.
Proposal
Add an opt-in setting (e.g. shiny.python.otelInstrument) that, when enabled, wraps the Run Shiny App launch:
<env>/opentelemetry-instrument <python> -m shiny run --port ... --reload ... app.py
Implementation notes (verified experimentally):
- The
opentelemetry-instrumententry-point script must be resolved next to the selected interpreter (dirname(python)/opentelemetry-instrument, orScripts\opentelemetry-instrument.exeon Windows).python -m opentelemetry.instrumentation.auto_instrumentationdoes not work — the package has no__main__. - Wrapping
<python> -m shiny runthis way works: Shiny'ssession_start/reactive_update/session_endspans export correctly, and--reloadis compatible (the reloaded process inherits instrumentation). - Exporter/config selection can be left to standard
OTEL_*env vars / flags; a companion setting for extra args (e.g.--traces_exporter console) may be handy for a batteries-included default. - If the script isn't found in the environment, show a friendly message suggesting
pip install 'shiny[otel]'. - Scope: Run only for a first pass. The Debug launch uses
vscode.debug.startDebuggingwithmodule: shiny, which doesn't compose trivially with the wrapper — can be a follow-up.
References
- Issue that motivated this: posit-dev/py-shiny#2274
- Docs PR: posit-dev/py-shiny-site#380
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Run Shiny App launch path and inspect how it selects the Python interpreter and builds the python -m shiny run command. Verify the wrapper using opentelemetry-instrument shiny run app.py, including the interpreter-adjacent script path and the missing-script case. Done means an opt-in setting wraps Run launches, preserves reload behavior, and gives a friendly install hint; Debug is out of scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- devtools, observability-sre, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100