How instana/python-sensor works
Instana is a Python application sensor for collecting metrics and distributed traces. Applications activate it by importing the package or through automatic bootstrap; framework and library instrumentation creates spans and propagates trace context, while the selected runtime agent and collector report telemetry to the Instana host agent. The package also includes runtime-specific agents, cloud/container collectors, and automatic profiling. Relationships are limited to README statements, excerpts, and SOURCE INDEX references; unsampled modules are represented only where the tree or index supports their role.
Main entry points: tracer.py Tracer · singletons.py Runtime selection · instrumentation Framework hooks · host.py Host agent client
Components 17
Instrumentation
- Framework hooks
src/instana/instrumentation - Library hooks
src/instana/instrumentation - Trace utilities
src/instana/util/traceutils.py
Tracing Core
- Tracer
src/instana/tracer.py - Span model
src/instana/span/span.py - Context propagation
src/instana/propagators - Span recorder
src/instana/recorder.py
Collection and Reporting
- Runtime selection
src/instana/singletons.py - Runtime agent
src/instana/agent - Host agent client
src/instana/agent/host.py - Telemetry collector
src/instana/collector/base.py - Cloud collectors
src/instana/collector - Agent base
src/instana/agent/base.py
Profiling
- Automatic profiler
src/instana/autoprofile/profiler.py - Profile sampling
src/instana/autoprofile/sampler_scheduler.py
Other components
- Python application
- Instana host agent
Connections 19
- Python application → Framework hooks: activates instrumentation
- Python application → Library hooks: activates instrumentation
- Framework hooks → Tracer: starts spans
src/instana/instrumentation/aiohttp/server.py - Library hooks → Trace utilities: uses tracing helpers
src/instana/instrumentation/aiohttp/client.py - Framework hooks → Context propagation: extracts context
src/instana/instrumentation/aiohttp/server.py - Library hooks → Context propagation: injects context
src/instana/instrumentation/aiohttp/client.py - Trace utilities → Tracer: gets tracer
src/instana/util/traceutils.py - Tracer → Span model: creates spans
- Span model → Span recorder: records spans
src/instana/span/span.py - Runtime selection → Tracer: initializes tracer
src/instana/singletons.py - Runtime selection → Runtime agent: selects agent
src/instana/singletons.py - Runtime selection → Automatic profiler: initializes profiler
src/instana/singletons.py - Runtime agent → Agent base: uses base agent
src/instana/agent/host.py - Agent base → Telemetry collector: starts collector
src/instana/collector/base.py - Telemetry collector → Host agent client: delegates reporting
- Host agent client → Instana host agent: reports telemetry
src/instana/agent/host.py - Cloud collectors → Telemetry collector: extends collection
src/instana/collector/aws_fargate.py - Automatic profiler → Profile sampling: schedules sampling
- Host agent client → Instana host agent: reports metrics
src/instana/agent/host.py