aice-observability 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aice-observability might be problematic. Click here for more details.

Files changed (35) hide show
  1. aice_observability-0.1.0.dist-info/METADATA +746 -0
  2. aice_observability-0.1.0.dist-info/RECORD +35 -0
  3. aice_observability-0.1.0.dist-info/WHEEL +4 -0
  4. observability/__init__.py +3 -0
  5. observability/ai/__init__.py +0 -0
  6. observability/ai/agents.py +155 -0
  7. observability/ai/evaluation.py +0 -0
  8. observability/ai/instrumentation/__init__.py +0 -0
  9. observability/ai/instrumentation/anthropic.py +20 -0
  10. observability/ai/instrumentation/base.py +25 -0
  11. observability/ai/instrumentation/gemini.py +20 -0
  12. observability/ai/instrumentation/langchain.py +16 -0
  13. observability/ai/instrumentation/openai.py +19 -0
  14. observability/ai/instrumentation/registry.py +53 -0
  15. observability/ai/instrumentation/vertexai.py +18 -0
  16. observability/ai/metrics.py +201 -0
  17. observability/ai/rag.py +169 -0
  18. observability/ai/registry.py +0 -0
  19. observability/ai/tracing.py +281 -0
  20. observability/builder.py +130 -0
  21. observability/core/__init__.py +0 -0
  22. observability/core/config.py +65 -0
  23. observability/core/exporters.py +27 -0
  24. observability/core/providers.py +58 -0
  25. observability/core/resources.py +28 -0
  26. observability/frameworks/__init__.py +0 -0
  27. observability/frameworks/django.py +7 -0
  28. observability/frameworks/fastapi.py +7 -0
  29. observability/frameworks/flask.py +7 -0
  30. observability/integrations/__init__.py +0 -0
  31. observability/integrations/httpx.py +19 -0
  32. observability/integrations/psycopg2.py +7 -0
  33. observability/integrations/redis.py +17 -0
  34. observability/integrations/sqlalchemy.py +7 -0
  35. observability/py.typed +0 -0
@@ -0,0 +1,746 @@
1
+ Metadata-Version: 2.4
2
+ Name: aice-observability
3
+ Version: 0.1.0
4
+ Summary: Unified OpenTelemetry-based observability layer for internal Python services
5
+ Author-email: Arnold Opiyo <arnoldopiyo@adanianlabs.io>
6
+ Keywords: metrics,observability,opentelemetry,telemetry,tracing
7
+ Classifier: Operating System :: OS Independent
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Python: >=3.11
12
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.27.0
13
+ Requires-Dist: opentelemetry-instrumentation-django>=0.64b0
14
+ Requires-Dist: opentelemetry-instrumentation-fastapi>=0.48b0
15
+ Requires-Dist: opentelemetry-instrumentation-flask>=0.64b0
16
+ Requires-Dist: opentelemetry-instrumentation-httpx>=0.48b0
17
+ Requires-Dist: opentelemetry-instrumentation-logging>=0.48b0
18
+ Requires-Dist: opentelemetry-instrumentation-psycopg2>=0.64b0
19
+ Requires-Dist: opentelemetry-instrumentation-redis>=0.48b0
20
+ Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.48b0
21
+ Requires-Dist: opentelemetry-instrumentation-system-metrics>=0.48b0
22
+ Requires-Dist: opentelemetry-sdk>=1.27.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: fastapi>=0.100.0; extra == 'dev'
25
+ Requires-Dist: httpx>=0.24.0; extra == 'dev'
26
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
28
+ Requires-Dist: pytest>=8.3.0; extra == 'dev'
29
+ Requires-Dist: redis>=5.0.0; extra == 'dev'
30
+ Requires-Dist: sqlalchemy>=2.0.0; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ Unified OpenTelemetry bootstrap for internal Python services. The objective is to provide every service with a consistent operational view without requiring teams to build dashboards from scratch.
34
+
35
+ ## Usage
36
+
37
+ ```python
38
+ from fastapi import FastAPI
39
+ from observability import Observability
40
+
41
+ app = FastAPI()
42
+
43
+ obs = (
44
+ Observability()
45
+ .service("data-quality-service", version="2.0.0")
46
+ .start() # must come before instrument_*() calls
47
+ .instrument_fastapi(app)
48
+ .instrument_sqlalchemy(engine)
49
+ )
50
+ ```
51
+
52
+ `.start()` must be called before any `instrument_*()` method. OpenTelemetry's
53
+ instrumentation libraries bind to whatever provider is globally registered
54
+ at the moment they run; calling them before `.start()` would silently do
55
+ nothing.
56
+
57
+ httpx is instrumented automatically inside `.start()`, since
58
+ they need no app-specific object.
59
+
60
+ ## Configuration (Environment Variables)
61
+
62
+ | Variable | Required | Default | Description |
63
+ |---|---|---|---|
64
+ | `OTEL_EXPORTER_OTLP_ENDPOINT` | Yes, unless all telemetry is disabled | none | OTLP HTTP endpoint used to export traces, metrics, and logs. Examples: `http://192.168.100.254:4318` (Collector), `https://otlp-gateway-prod-us-central-0.grafana.net/otlp` (Grafana Cloud). |
65
+ | `OTEL_EXPORTER_OTLP_HEADERS` | No | none | Optional authentication headers in `key=value,key=value` format. Required by many hosted OTLP providers. |
66
+ | `OTEL_SERVICE_NAME` | Yes | none | Logical service name reported to the observability backend (for example `dq-service`). |
67
+ | `OTEL_ENVIRONMENT` | No | `development` | Deployment environment such as `development`, `staging`, or `production`. |
68
+ | `OTEL_TRACES_ENABLED` | No | `true` | Enable or disable distributed tracing. |
69
+ | `OTEL_METRICS_ENABLED` | No | `true` | Enable or disable metrics collection. |
70
+ | `OTEL_LOGS_ENABLED` | No | `true` | Enable or disable log export. |
71
+ | `OTEL_LOG_LEVEL` | No | `INFO` | Minimum application log level captured by the logging pipeline. |
72
+
73
+ ### Example: Self-hosted OpenTelemetry Collector
74
+
75
+ ```env
76
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://192.168.100.254:4318
77
+ OTEL_SERVICE_NAME=dq-service
78
+ OTEL_ENVIRONMENT=development
79
+ OTEL_TRACES_ENABLED=true
80
+ OTEL_METRICS_ENABLED=true
81
+ OTEL_LOGS_ENABLED=true
82
+ ```
83
+
84
+
85
+ # Standard Observability Dashboards
86
+
87
+
88
+ The dashboards are designed around operational questions rather than telemetry types. Instead of exposing every metric collected by OpenTelemetry, each dashboard focuses on answering a specific set of questions that engineers, tech leads, and platform teams routinely ask.
89
+
90
+ Version 1 of the observability platform includes the following dashboards:
91
+
92
+ 1. Service Overview
93
+ 2. Infrastructure
94
+ 3. HTTP/API
95
+ 4. Database (conditional)
96
+ 5. External Services (HTTP Client)
97
+ 6. Logs
98
+ 7. Traces
99
+
100
+ ---
101
+
102
+ # 1. Service Overview Dashboard
103
+
104
+ ## Purpose
105
+
106
+ The Service Overview dashboard is the primary landing page for every service.
107
+
108
+ It provides a high level summary of service health, traffic, latency, failures, and operational status.
109
+
110
+ This dashboard should answer the following questions within a few seconds:
111
+
112
+ * Is the service healthy?
113
+ * Is it currently receiving traffic?
114
+ * Has latency increased?
115
+ * Are users experiencing failures?
116
+ * Should I investigate further?
117
+
118
+ ## Target Audience
119
+
120
+ * Tech Leads
121
+ * Backend Engineers
122
+ * DevOps Engineers
123
+ * SREs
124
+ * Engineering Managers
125
+
126
+ ## Panels
127
+
128
+ ### Availability
129
+
130
+ Displays service uptime and overall availability.
131
+
132
+ Purpose:
133
+
134
+ Quickly determine whether the service is operational.
135
+
136
+ ---
137
+
138
+ ### Request Rate (Requests Per Second)
139
+
140
+ Displays incoming request volume.
141
+
142
+ Purpose:
143
+
144
+ Identify traffic spikes, traffic drops, and overall load.
145
+
146
+ ---
147
+
148
+ ### Active Requests
149
+
150
+ Shows the number of requests currently being processed.
151
+
152
+ Purpose:
153
+
154
+ Detect request buildup and possible bottlenecks.
155
+
156
+ ---
157
+
158
+ ### Error Rate
159
+
160
+ Percentage and total number of failed requests.
161
+
162
+ Purpose:
163
+
164
+ Quickly identify service degradation.
165
+
166
+ ---
167
+
168
+ ### Average Response Time
169
+
170
+ Average latency across all requests.
171
+
172
+ Purpose:
173
+
174
+ Monitor overall responsiveness.
175
+
176
+ ---
177
+
178
+ ### P95 Latency
179
+
180
+ 95% of requests complete faster than this value.
181
+
182
+ Purpose:
183
+
184
+ Represents the experience of almost all users.
185
+
186
+ ---
187
+
188
+ ### P99 Latency
189
+
190
+ 99% of requests complete faster than this value.
191
+
192
+ Purpose:
193
+
194
+ Highlights long-tail latency issues.
195
+
196
+ ---
197
+
198
+ ### HTTP Status Code Distribution
199
+
200
+ Breakdown of
201
+
202
+ * 2xx
203
+ * 3xx
204
+ * 4xx
205
+ * 5xx
206
+
207
+ Purpose:
208
+
209
+ Identify client errors versus server failures.
210
+
211
+ ---
212
+
213
+ ### Top Failing Endpoints
214
+
215
+ Endpoints with the highest error count.
216
+
217
+ Purpose:
218
+
219
+ Quickly identify problematic APIs.
220
+
221
+ ---
222
+
223
+ ### Slowest Endpoints
224
+
225
+ Endpoints ranked by average latency.
226
+
227
+ Purpose:
228
+
229
+ Locate performance bottlenecks.
230
+
231
+ ---
232
+
233
+ ### Service Metadata
234
+
235
+ Displays
236
+
237
+ * Service Name
238
+ * Version
239
+ * Environment
240
+ * Instance Count
241
+ * Last Restart Time
242
+
243
+ Purpose:
244
+
245
+ Provide deployment context during incident investigations.
246
+
247
+ ---
248
+
249
+ ### Quick Navigation
250
+
251
+ Links directly to
252
+
253
+ * Logs Dashboard
254
+ * Traces Dashboard
255
+ * Infrastructure Dashboard
256
+
257
+ Purpose:
258
+
259
+ Reduce investigation time.
260
+
261
+ ---
262
+
263
+ # 2. Infrastructure Dashboard
264
+
265
+ ## Purpose
266
+
267
+ The Infrastructure dashboard monitors resource utilization of the application process and host.
268
+
269
+ It helps determine whether performance issues originate from application logic or infrastructure limitations.
270
+
271
+ ## Target Audience
272
+
273
+ * Platform Engineers
274
+ * DevOps Engineers
275
+ * SREs
276
+
277
+ ## Panels
278
+
279
+ ### CPU Usage
280
+
281
+ CPU utilization over time.
282
+
283
+ ---
284
+
285
+ ### Memory Usage
286
+
287
+ Current memory consumption.
288
+
289
+ ---
290
+
291
+ ### Memory Utilization
292
+
293
+ Memory usage as a percentage of available memory.
294
+
295
+ ---
296
+
297
+ ### Disk Usage
298
+
299
+ Disk space utilization.
300
+
301
+ ---
302
+
303
+ ### Disk I/O
304
+
305
+ Read and write throughput.
306
+
307
+ ---
308
+
309
+ ### Network Throughput
310
+
311
+ Incoming and outgoing traffic.
312
+
313
+ ---
314
+
315
+ ### File Descriptors
316
+
317
+ Number of open file descriptors.
318
+
319
+ ---
320
+
321
+ ### Thread Count
322
+
323
+ Active application threads.
324
+
325
+ ---
326
+
327
+ ### Garbage Collection Activity
328
+
329
+ Displays
330
+
331
+ * Collection frequency
332
+ * Objects collected
333
+ * GC pause duration
334
+
335
+ Purpose:
336
+
337
+ Identify memory pressure.
338
+
339
+ ---
340
+
341
+ ### Process Restarts
342
+
343
+ Detect unexpected application restarts.
344
+
345
+ ---
346
+
347
+ # 3. HTTP/API Dashboard
348
+
349
+ ## Purpose
350
+
351
+ Provides endpoint-level visibility into API behaviour.
352
+
353
+ Rather than viewing the service as a whole, this dashboard focuses on individual routes.
354
+
355
+ ## Target Audience
356
+
357
+ * Backend Engineers
358
+ * API Owners
359
+
360
+ ## Panels
361
+
362
+ ### Requests Per Second by Endpoint
363
+
364
+ ---
365
+
366
+ ### Average Latency by Endpoint
367
+
368
+ ---
369
+
370
+ ### P95 Latency by Endpoint
371
+
372
+ ---
373
+
374
+ ### P99 Latency by Endpoint
375
+
376
+ ---
377
+
378
+ ### Error Rate by Endpoint
379
+
380
+ ---
381
+
382
+ ### Slowest Endpoints
383
+
384
+ ---
385
+
386
+ ### Largest Responses
387
+
388
+ ---
389
+
390
+ ### Largest Requests
391
+
392
+ ---
393
+
394
+ ### Request Duration Heatmap
395
+
396
+ Visualizes latency distribution across all requests.
397
+
398
+ ---
399
+
400
+ ### Endpoint Ranking
401
+
402
+ Ranks endpoints by
403
+
404
+ * Traffic
405
+ * Errors
406
+ * Latency
407
+
408
+ ---
409
+
410
+ # 4. Database Dashboard
411
+
412
+ ## Purpose
413
+
414
+ Provides visibility into database interactions.
415
+
416
+ This dashboard is displayed only when database instrumentation is enabled.
417
+
418
+ Supported instrumentations include
419
+
420
+ * SQLAlchemy
421
+ * psycopg2
422
+
423
+ ## Target Audience
424
+
425
+ * Backend Engineers
426
+ * Database Administrators
427
+
428
+ ## Panels
429
+
430
+ ### Queries Per Second
431
+
432
+ ---
433
+
434
+ ### Average Query Duration
435
+
436
+ ---
437
+
438
+ ### Slowest Queries
439
+
440
+ ---
441
+
442
+ ### Database Error Rate
443
+
444
+ ---
445
+
446
+ ### Connection Pool Utilization
447
+
448
+ ---
449
+
450
+ ### Connection Pool Wait Time
451
+
452
+ ---
453
+
454
+ ### Pool Saturation
455
+
456
+ ---
457
+
458
+ ### Failed Queries
459
+
460
+ ---
461
+
462
+ ### Transaction Duration
463
+
464
+ ---
465
+
466
+ ### Database Retries
467
+
468
+ ---
469
+
470
+ ## Conditional Display
471
+
472
+ Visible only if one of the following instrumentations is enabled.
473
+
474
+ * SQLAlchemy
475
+ * psycopg2
476
+
477
+ ---
478
+
479
+ # 5. External Services Dashboard
480
+
481
+ ## Purpose
482
+
483
+ Provides visibility into outbound HTTP requests.
484
+
485
+ This dashboard helps identify slow or failing third-party services.
486
+
487
+ The dashboard is powered by HTTPX instrumentation.
488
+
489
+ ## Target Audience
490
+
491
+ * Backend Engineers
492
+ * Tech Leads
493
+
494
+ ## Panels
495
+
496
+ ### Outbound Requests Per Second
497
+
498
+ ---
499
+
500
+ ### Average Outbound Latency
501
+
502
+ ---
503
+
504
+ ### P95 Outbound Latency
505
+
506
+ ---
507
+
508
+ ### Error Rate by Remote Service
509
+
510
+ ---
511
+
512
+ ### Timeout Count
513
+
514
+ ---
515
+
516
+ ### Retry Count
517
+
518
+ ---
519
+
520
+ ### Top Slowest Remote Hosts
521
+
522
+ ---
523
+
524
+ ### Request Distribution by Host
525
+
526
+ ---
527
+
528
+ ### External Dependency Health
529
+
530
+ Summarizes
531
+
532
+ * Success Rate
533
+ * Failure Rate
534
+ * Average Latency
535
+
536
+ ---
537
+
538
+ # 6. Logs Dashboard
539
+
540
+ ## Purpose
541
+
542
+ Provides centralized log exploration through Grafana and Loki.
543
+
544
+ The dashboard is intended for investigation after metrics indicate abnormal behaviour.
545
+
546
+ ## Target Audience
547
+
548
+ * All Engineers
549
+
550
+ ## Panels
551
+
552
+ ### Live Logs
553
+
554
+ ---
555
+
556
+ ### Error Logs
557
+
558
+ ---
559
+
560
+ ### Warning Logs
561
+
562
+ ---
563
+
564
+ ### Log Volume Over Time
565
+
566
+ ---
567
+
568
+ ### Log Levels
569
+
570
+ Distribution of
571
+
572
+ * DEBUG
573
+ * INFO
574
+ * WARNING
575
+ * ERROR
576
+ * CRITICAL
577
+
578
+ ---
579
+
580
+ ### Service Filter
581
+
582
+ ---
583
+
584
+ ### Search
585
+
586
+ Supports free text search.
587
+
588
+ ---
589
+
590
+ ### Correlation Links
591
+
592
+ Jump directly to related traces.
593
+
594
+ ---
595
+
596
+ # 7. Traces Dashboard
597
+
598
+ ## Purpose
599
+
600
+ Provides distributed tracing through Jaeger.
601
+
602
+ The dashboard allows engineers to follow requests across services.
603
+
604
+ ## Target Audience
605
+
606
+ * Backend Engineers
607
+ * Platform Engineers
608
+ * SREs
609
+
610
+ ## Panels
611
+
612
+ ### Recent Traces
613
+
614
+ ---
615
+
616
+ ### Slowest Traces
617
+
618
+ ---
619
+
620
+ ### Error Traces
621
+
622
+ ---
623
+
624
+ ### Trace Duration Distribution
625
+
626
+ ---
627
+
628
+ ### Service Dependency Graph
629
+
630
+ ---
631
+
632
+ ### Span Timeline
633
+
634
+ ---
635
+
636
+ ### Failed Spans
637
+
638
+ ---
639
+
640
+ ### Trace Search
641
+
642
+ Supports filtering by
643
+
644
+ * Service
645
+ * Endpoint
646
+ * Duration
647
+ * Status
648
+
649
+ ---
650
+
651
+ ### Correlated Logs
652
+
653
+ Jump directly to matching log entries.
654
+
655
+ ---
656
+
657
+ # Dashboard Design Principles
658
+
659
+ Every dashboard should follow these principles.
660
+
661
+ ## Minimal by Default
662
+
663
+ Dashboards should expose only the information required for operational decisions.
664
+
665
+ Avoid displaying every metric collected by OpenTelemetry.
666
+
667
+ ---
668
+
669
+ ## Progressive Investigation
670
+
671
+ Dashboards should naturally lead the user from high level health to detailed diagnostics.
672
+
673
+ Typical investigation flow:
674
+
675
+ Service Overview
676
+
677
+ ↓
678
+
679
+ HTTP/API
680
+
681
+ ↓
682
+
683
+ Database or External Services
684
+
685
+ ↓
686
+
687
+ Logs
688
+
689
+ ↓
690
+
691
+ Traces
692
+
693
+ ---
694
+
695
+ ## Consistency
696
+
697
+ All services should expose the same dashboard structure.
698
+
699
+ This reduces cognitive load when switching between projects.
700
+
701
+ ---
702
+
703
+ ## Conditional Sections
704
+
705
+ Dashboards should only display panels relevant to the service.
706
+
707
+ Examples:
708
+
709
+ A service without Redis should not display Redis metrics.
710
+
711
+ A service without SQLAlchemy should not display SQL metrics.
712
+
713
+ A service without HTTP clients should not display outbound request metrics.
714
+
715
+ ---
716
+
717
+ ## Standard Labels
718
+
719
+ All dashboards should support filtering using common resource attributes.
720
+
721
+ Examples include:
722
+
723
+ * Service Name
724
+ * Environment
725
+ * Version
726
+ * Instance
727
+ * Endpoint
728
+ * HTTP Method
729
+ * Database System
730
+ * Remote Host
731
+
732
+ ---
733
+
734
+ # Future Dashboard Roadmap
735
+
736
+ The following dashboards are planned for future releases.
737
+
738
+ * Redis Dashboard
739
+ * Background Jobs Dashboard
740
+ * AI/LLM Dashboard
741
+ * Cache Dashboard
742
+ * Storage Dashboard
743
+ * Security Dashboard
744
+ * Business Metrics Dashboard
745
+
746
+