posit-dev / posit-dev/shiny-vscode

Add opt-in OpenTelemetry auto-instrumentation when running Python apps

Open
#111 0 comments 0 reactions 0 assignees View on GitHub

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-instrument entry-point script must be resolved next to the selected interpreter (dirname(python)/opentelemetry-instrument, or Scripts\opentelemetry-instrument.exe on Windows). python -m opentelemetry.instrumentation.auto_instrumentation does not work — the package has no __main__.
  • Wrapping <python> -m shiny run this way works: Shiny's session_start/reactive_update/session_end spans export correctly, and --reload is 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.startDebugging with module: 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.