basic integratation of open telemetry #161
Open
+2,622
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add OpenTelemetry Integration
This PR adds comprehensive OpenTelemetry support for distributed tracing across the codebase. The implementation uses automatic instrumentation for both third-party libraries and custom application functions, requiring zero code changes.
What's Added
src/telemetry/) with configuration, setup, and auto-instrumentationHow It Works
The implementation uses OpenTelemetry's standard auto-instrumentation pattern, which is the same approach used by production applications in large open-source projects.
Two Ways to Use It
1. Using
opentelemetry-instrument(Recommended)The easiest way is to use the
opentelemetry-instrumentcommand, which automatically instruments all supported libraries:This automatically instruments all supported libraries (NumPy, Pandas, Requests, SQLAlchemy, etc.) plus your custom functions.
2. Using Programmatic Setup
Alternatively, initialize telemetry in your code:
Custom Function Instrumentation
All custom functions are automatically traced using
auto_instrument_package(), which wraps functions in specified modules without requiring decorators. This includes:numerical/optimization.py- gradient descentalgorithms/dynamic_programming.py- fibonacci, matrix operations, knapsackalgorithms/graph.py- graph traversal, clustering, path findingdata_processing/dataframe.py- filtering, grouping, mergingstatistics/descriptive.py- statistical operationsTesting with Jaeger
For local testing and visualization, use Jaeger (no API keys required):
Start Jaeger:
Run your script with OTLP exporter:
View traces in Jaeger UI:
Open http://localhost:16686 in your browser to see the trace visualization.
Configuration
Configuration is managed through environment variables with sensible defaults:
OTEL_SERVICE_NAME=optimize-me- Service name for tracesOTEL_TRACES_EXPORTER=console- Exporter type (console, otlp)OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317- OTLP endpoint (for Jaeger)Documentation
For detailed information, see:
opentelemetry-instrumentvs programmatic setupExample Usage
Run the example script to see telemetry in action:
This will output trace spans showing execution of all instrumented functions including gradient descent, graph traversal, statistical operations, and more.