basic integratation of open telemetry #161
Open
+2,289
−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 OpenTelemetry support for distributed tracing across the codebase. The implementation includes automatic instrumentation for NumPy and Pandas operations, plus a decorator-based approach for manual instrumentation of key functions.
What's Added
src/telemetry/) with configuration, setup, and decorators@trace_functiondecorator applied to critical functions in: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 operationsenv.examplewith all OpenTelemetry variables documentedHow It Works
Telemetry configuration is managed through
TelemetryConfigwhich reads environment variables with sensible defaults. Configuration can be overridden via environment variables or by passing parameters tosetup_telemetry().Current Implementation:
Configuration defaults (can be overridden via environment variables):
OTEL_SDK_DISABLED=false- Telemetry enabled by defaultOTEL_SERVICE_NAME=optimize-me- Default service nameOTEL_EXPORTER_TYPE=console- Console exporter for developmentOTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318- OTLP endpoint when using otlp exporterInitialization: Call
setup_telemetry()once at application startup (as shown inexamples/run_with_telemetry.py):Automatic instrumentation: Functions are already instrumented with
@trace_functiondecorators:gradient_descentcapturesiterationsandlearning_rateargumentsEnvironment variable overrides: Set variables from
env.exampleto customize behavior without code changes.Testing
Run the example script to see telemetry in action:
This will output trace spans to the console showing execution of instrumented functions including gradient descent, graph traversal, statistical operations, and clustering.
For production, set
OTEL_EXPORTER_TYPE=otlpand configureOTEL_EXPORTER_OTLP_ENDPOINTto point to an OTLP collector (e.g., Jaeger, Tempo).