netra-sdk 0.1.0__py3-none-any.whl → 0.1.2__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 netra-sdk might be problematic. Click here for more details.

@@ -39,6 +39,8 @@ def init_instrumentations(
39
39
  Instruments.MISTRAL,
40
40
  }
41
41
  )
42
+ if instruments is not None and traceloop_instruments is None and traceloop_block_instruments is None:
43
+ traceloop_block_instruments = set(Instruments)
42
44
 
43
45
  init_instrumentations(
44
46
  should_enrich_metrics=should_enrich_metrics,
@@ -80,6 +82,186 @@ def init_instrumentations(
80
82
  if CustomInstruments.MISTRALAI in netra_custom_instruments:
81
83
  init_mistral_instrumentor()
82
84
 
85
+ # Initialize aio_pika instrumentation.
86
+ if CustomInstruments.AIO_PIKA in netra_custom_instruments:
87
+ init_aio_pika_instrumentation()
88
+
89
+ # Initialize aiohttp_server instrumentation.
90
+ if CustomInstruments.AIOHTTP_SERVER in netra_custom_instruments:
91
+ init_aiohttp_server_instrumentation()
92
+
93
+ # Initialize aiokafka instrumentation.
94
+ if CustomInstruments.AIOKAFKA in netra_custom_instruments:
95
+ init_aiokafka_instrumentation()
96
+
97
+ # Initialize aiopg instrumentation.
98
+ if CustomInstruments.AIOPG in netra_custom_instruments:
99
+ init_aiopg_instrumentation()
100
+
101
+ # Initialize asyncclick instrumentation.
102
+ if CustomInstruments.ASYNCCLICK in netra_custom_instruments:
103
+ init_asyncclick_instrumentation()
104
+
105
+ # Initialize asyncio instrumentation.
106
+ if CustomInstruments.ASYNCIO in netra_custom_instruments:
107
+ init_asyncio_instrumentation()
108
+
109
+ # Initialize asyncpg instrumentation.
110
+ if CustomInstruments.ASYNCPG in netra_custom_instruments:
111
+ init_asyncpg_instrumentation()
112
+
113
+ # Initialize aws_lambda instrumentation.
114
+ if CustomInstruments.AWS_LAMBDA in netra_custom_instruments:
115
+ init_aws_lambda_instrumentation()
116
+
117
+ # Initialize boto instrumentation.
118
+ if CustomInstruments.BOTO in netra_custom_instruments:
119
+ init_boto_instrumentation()
120
+
121
+ # Initialize boto3sqs instrumentation.
122
+ if CustomInstruments.BOTO3SQS in netra_custom_instruments:
123
+ init_boto3sqs_instrumentation()
124
+
125
+ # Initialize botocore instrumentation.
126
+ if CustomInstruments.BOTOCORE in netra_custom_instruments:
127
+ init_botocore_instrumentation()
128
+
129
+ # Initialize cassandra instrumentation.
130
+ if CustomInstruments.CASSANDRA in netra_custom_instruments:
131
+ init_cassandra_instrumentation()
132
+
133
+ # Initialize celery instrumentation.
134
+ if CustomInstruments.CELERY in netra_custom_instruments:
135
+ init_celery_instrumentation()
136
+
137
+ # Initialize click instrumentation.
138
+ if CustomInstruments.CLICK in netra_custom_instruments:
139
+ init_click_instrumentation()
140
+
141
+ # Initialize confluent_kafka instrumentation.
142
+ if CustomInstruments.CONFLUENT_KAFKA in netra_custom_instruments:
143
+ init_confluent_kafka_instrumentation()
144
+
145
+ # Initialize django instrumentation.
146
+ if CustomInstruments.DJANGO in netra_custom_instruments:
147
+ init_django_instrumentation()
148
+
149
+ # Initialize elasticsearch instrumentation.
150
+ if CustomInstruments.ELASTICSEARCH in netra_custom_instruments:
151
+ init_elasticsearch_instrumentation()
152
+
153
+ # Initialize falcon instrumentation.
154
+ if CustomInstruments.FALCON in netra_custom_instruments:
155
+ init_falcon_instrumentation()
156
+
157
+ # Initialize flask instrumentation.
158
+ if CustomInstruments.FLASK in netra_custom_instruments:
159
+ init_flask_instrumentation()
160
+
161
+ # Initialize grpc instrumentation.
162
+ if CustomInstruments.GRPC in netra_custom_instruments:
163
+ init_grpc_instrumentation()
164
+
165
+ # Initialize jinja2 instrumentation.
166
+ if CustomInstruments.JINJA2 in netra_custom_instruments:
167
+ init_jinja2_instrumentation()
168
+
169
+ # Initialize kafka_python instrumentation.
170
+ if CustomInstruments.KAFKA_PYTHON in netra_custom_instruments:
171
+ init_kafka_python_instrumentation()
172
+
173
+ # Initialize logging instrumentation.
174
+ if CustomInstruments.LOGGING in netra_custom_instruments:
175
+ init_logging_instrumentation()
176
+
177
+ # Initialize mysql instrumentation.
178
+ if CustomInstruments.MYSQL in netra_custom_instruments:
179
+ init_mysql_instrumentation()
180
+
181
+ # Initialize mysqlclient instrumentation.
182
+ if CustomInstruments.MYSQLCLIENT in netra_custom_instruments:
183
+ init_mysqlclient_instrumentation()
184
+
185
+ # Initialize pika instrumentation.
186
+ if CustomInstruments.PIKA in netra_custom_instruments:
187
+ init_pika_instrumentation()
188
+
189
+ # Initialize psycopg instrumentation.
190
+ if CustomInstruments.PSYCOPG in netra_custom_instruments:
191
+ init_psycopg_instrumentation()
192
+
193
+ # Initialize psycopg2 instrumentation.
194
+ if CustomInstruments.PSYCOPG2 in netra_custom_instruments:
195
+ init_psycopg2_instrumentation()
196
+
197
+ # Initialize pymemcache instrumentation.
198
+ if CustomInstruments.PYMEMCACHE in netra_custom_instruments:
199
+ init_pymemcache_instrumentation()
200
+
201
+ # Initialize pymongo instrumentation.
202
+ if CustomInstruments.PYMONGO in netra_custom_instruments:
203
+ init_pymongo_instrumentation()
204
+
205
+ # Initialize pymssql instrumentation.
206
+ if CustomInstruments.PYMSSQL in netra_custom_instruments:
207
+ init_pymssql_instrumentation()
208
+
209
+ # Initialize pymysql instrumentation.
210
+ if CustomInstruments.PYMYSQL in netra_custom_instruments:
211
+ init_pymysql_instrumentation()
212
+
213
+ # Initialize pyramid instrumentation.
214
+ if CustomInstruments.PYRAMID in netra_custom_instruments:
215
+ init_pyramid_instrumentation()
216
+
217
+ # Initialize redis instrumentation.
218
+ if CustomInstruments.REDIS in netra_custom_instruments:
219
+ init_redis_instrumentation()
220
+
221
+ # Initialize remoulade instrumentation.
222
+ if CustomInstruments.REMOULADE in netra_custom_instruments:
223
+ init_remoulade_instrumentation()
224
+
225
+ # Initialize requests instrumentation.
226
+ if CustomInstruments.REQUESTS in netra_custom_instruments:
227
+ init_requests_instrumentation()
228
+
229
+ # Initialize sqlalchemy instrumentation.
230
+ if CustomInstruments.SQLALCHEMY in netra_custom_instruments:
231
+ init_sqlalchemy_instrumentation()
232
+
233
+ # Initialize sqlite3 instrumentation.
234
+ if CustomInstruments.SQLITE3 in netra_custom_instruments:
235
+ init_sqlite3_instrumentation()
236
+
237
+ # Initialize starlette instrumentation.
238
+ if CustomInstruments.STARLETTE in netra_custom_instruments:
239
+ init_starlette_instrumentation()
240
+
241
+ # Initialize system_metrics instrumentation.
242
+ if CustomInstruments.SYSTEM_METRICS in netra_custom_instruments:
243
+ init_system_metrics_instrumentation()
244
+
245
+ # Initialize threading instrumentation.
246
+ if CustomInstruments.THREADING in netra_custom_instruments:
247
+ init_threading_instrumentation()
248
+
249
+ # Initialize tornado instrumentation.
250
+ if CustomInstruments.TORNADO in netra_custom_instruments:
251
+ init_tornado_instrumentation()
252
+
253
+ # Initialize tortoiseorm instrumentation.
254
+ if CustomInstruments.TORTOISEORM in netra_custom_instruments:
255
+ init_tortoiseorm_instrumentation()
256
+
257
+ # Initialize urllib instrumentation.
258
+ if CustomInstruments.URLLIB in netra_custom_instruments:
259
+ init_urllib_instrumentation()
260
+
261
+ # Initialize urllib3 instrumentation.
262
+ if CustomInstruments.URLLIB3 in netra_custom_instruments:
263
+ init_urllib3_instrumentation()
264
+
83
265
 
84
266
  def init_google_genai_instrumentation() -> bool:
85
267
  """Initialize Google GenAI instrumentation.
@@ -255,3 +437,721 @@ def init_mistral_instrumentor() -> bool:
255
437
  logging.error(f"-----Error initializing Mistral instrumentor: {e}")
256
438
  Telemetry().log_exception(e)
257
439
  return False
440
+
441
+
442
+ def init_aio_pika_instrumentation() -> bool:
443
+ """Initialize aio_pika instrumentation."""
444
+ try:
445
+ if is_package_installed("aio_pika"):
446
+ from opentelemetry.instrumentation.aio_pika import AioPikaInstrumentor
447
+
448
+ instrumentor = AioPikaInstrumentor()
449
+ if not instrumentor.is_instrumented_by_opentelemetry:
450
+ instrumentor.instrument()
451
+ return True
452
+ except Exception as e:
453
+ logging.error(f"Error initializing aio_pika instrumentor: {e}")
454
+ Telemetry().log_exception(e)
455
+ return False
456
+
457
+
458
+ def init_aiohttp_server_instrumentation() -> bool:
459
+ """Initialize aiohttp_server instrumentation."""
460
+ try:
461
+ if is_package_installed("aiohttp"):
462
+ from opentelemetry.instrumentation.aiohttp_server import AioHttpServerInstrumentor
463
+
464
+ instrumentor = AioHttpServerInstrumentor()
465
+ if not instrumentor.is_instrumented_by_opentelemetry:
466
+ instrumentor.instrument()
467
+ return True
468
+ except Exception as e:
469
+ logging.error(f"Error initializing aiohttp_server instrumentor: {e}")
470
+ Telemetry().log_exception(e)
471
+ return False
472
+
473
+
474
+ def init_aiokafka_instrumentation() -> bool:
475
+ """Initialize aiokafka instrumentation."""
476
+ try:
477
+ if is_package_installed("aiokafka"):
478
+ from opentelemetry.instrumentation.aiokafka import AIOKafkaInstrumentor
479
+
480
+ instrumentor = AIOKafkaInstrumentor()
481
+ if not instrumentor.is_instrumented_by_opentelemetry:
482
+ instrumentor.instrument()
483
+ return True
484
+ except Exception as e:
485
+ logging.error(f"Error initializing aiokafka instrumentor: {e}")
486
+ Telemetry().log_exception(e)
487
+ return False
488
+
489
+
490
+ def init_aiopg_instrumentation() -> bool:
491
+ """Initialize aiopg instrumentation."""
492
+ try:
493
+ if is_package_installed("aiopg"):
494
+ from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
495
+
496
+ instrumentor = AiopgInstrumentor()
497
+ if not instrumentor.is_instrumented_by_opentelemetry:
498
+ instrumentor.instrument()
499
+ return True
500
+ except Exception as e:
501
+ logging.error(f"Error initializing aiopg instrumentor: {e}")
502
+ Telemetry().log_exception(e)
503
+ return False
504
+
505
+
506
+ def init_asyncclick_instrumentation() -> bool:
507
+ """Initialize asyncclick instrumentation."""
508
+ try:
509
+ if is_package_installed("asyncclick"):
510
+ from opentelemetry.instrumentation.asyncclick import AsyncClickInstrumentor
511
+
512
+ instrumentor = AsyncClickInstrumentor()
513
+ if not instrumentor.is_instrumented_by_opentelemetry:
514
+ instrumentor.instrument()
515
+ return True
516
+ except Exception as e:
517
+ logging.error(f"Error initializing asyncclick instrumentor: {e}")
518
+ Telemetry().log_exception(e)
519
+ return False
520
+
521
+
522
+ def init_asyncio_instrumentation() -> bool:
523
+ """Initialize asyncio instrumentation."""
524
+ try:
525
+ if is_package_installed("asyncio"):
526
+ from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
527
+
528
+ instrumentor = AsyncioInstrumentor()
529
+ if not instrumentor.is_instrumented_by_opentelemetry:
530
+ instrumentor.instrument()
531
+ return True
532
+ except Exception as e:
533
+ logging.error(f"Error initializing asyncio instrumentor: {e}")
534
+ Telemetry().log_exception(e)
535
+ return False
536
+
537
+
538
+ def init_asyncpg_instrumentation() -> bool:
539
+ """Initialize asyncpg instrumentation."""
540
+ try:
541
+ if is_package_installed("asyncpg"):
542
+ from opentelemetry.instrumentation.asyncpg import AsyncPGInstrumentor
543
+
544
+ instrumentor = AsyncPGInstrumentor()
545
+ if not instrumentor.is_instrumented_by_opentelemetry:
546
+ instrumentor.instrument()
547
+ return True
548
+ except Exception as e:
549
+ logging.error(f"Error initializing asyncpg instrumentor: {e}")
550
+ Telemetry().log_exception(e)
551
+ return False
552
+
553
+
554
+ def init_aws_lambda_instrumentation() -> bool:
555
+ """Initialize aws_lambda instrumentation."""
556
+ try:
557
+ if is_package_installed("aws_lambda"):
558
+ from opentelemetry.instrumentation.aws_lambda import AwsLambdaInstrumentor
559
+
560
+ instrumentor = AwsLambdaInstrumentor()
561
+ if not instrumentor.is_instrumented_by_opentelemetry:
562
+ instrumentor.instrument()
563
+ return True
564
+ except Exception as e:
565
+ logging.error(f"Error initializing aws_lambda instrumentor: {e}")
566
+ Telemetry().log_exception(e)
567
+ return False
568
+
569
+
570
+ def init_boto_instrumentation() -> bool:
571
+ """Initialize boto instrumentation."""
572
+ try:
573
+ if is_package_installed("boto"):
574
+ from opentelemetry.instrumentation.boto import BotoInstrumentor
575
+
576
+ instrumentor = BotoInstrumentor()
577
+ if not instrumentor.is_instrumented_by_opentelemetry:
578
+ instrumentor.instrument()
579
+ return True
580
+ except Exception as e:
581
+ logging.error(f"Error initializing boto instrumentor: {e}")
582
+ Telemetry().log_exception(e)
583
+ return False
584
+
585
+
586
+ def init_boto3sqs_instrumentation() -> bool:
587
+ """Initialize boto3sqs instrumentation."""
588
+ try:
589
+ if is_package_installed("boto3"):
590
+ from opentelemetry.instrumentation.boto3sqs import Boto3SQSInstrumentor
591
+
592
+ instrumentor = Boto3SQSInstrumentor()
593
+ if not instrumentor.is_instrumented_by_opentelemetry:
594
+ instrumentor.instrument()
595
+ return True
596
+ except Exception as e:
597
+ logging.error(f"Error initializing boto3sqs instrumentor: {e}")
598
+ Telemetry().log_exception(e)
599
+ return False
600
+
601
+
602
+ def init_botocore_instrumentation() -> bool:
603
+ """Initialize botocore instrumentation."""
604
+ try:
605
+ if is_package_installed("botocore"):
606
+ from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
607
+
608
+ instrumentor = BotocoreInstrumentor()
609
+ if not instrumentor.is_instrumented_by_opentelemetry:
610
+ instrumentor.instrument()
611
+ return True
612
+ except Exception as e:
613
+ logging.error(f"Error initializing botocore instrumentor: {e}")
614
+ Telemetry().log_exception(e)
615
+ return False
616
+
617
+
618
+ def init_cassandra_instrumentation() -> bool:
619
+ """Initialize cassandra instrumentation."""
620
+ try:
621
+ if is_package_installed("cassandra-driver"):
622
+ from opentelemetry.instrumentation.cassandra import CassandraInstrumentor
623
+
624
+ instrumentor = CassandraInstrumentor()
625
+ if not instrumentor.is_instrumented_by_opentelemetry:
626
+ instrumentor.instrument()
627
+ return True
628
+ except Exception as e:
629
+ logging.error(f"Error initializing cassandra instrumentor: {e}")
630
+ Telemetry().log_exception(e)
631
+ return False
632
+
633
+
634
+ def init_celery_instrumentation() -> bool:
635
+ """Initialize celery instrumentation."""
636
+ try:
637
+ if is_package_installed("celery"):
638
+ from opentelemetry.instrumentation.celery import CeleryInstrumentor
639
+
640
+ instrumentor = CeleryInstrumentor()
641
+ if not instrumentor.is_instrumented_by_opentelemetry:
642
+ instrumentor.instrument()
643
+ return True
644
+ except Exception as e:
645
+ logging.error(f"Error initializing celery instrumentor: {e}")
646
+ Telemetry().log_exception(e)
647
+ return False
648
+
649
+
650
+ def init_click_instrumentation() -> bool:
651
+ """Initialize click instrumentation."""
652
+ try:
653
+ if is_package_installed("click"):
654
+ from opentelemetry.instrumentation.click import ClickInstrumentor
655
+
656
+ instrumentor = ClickInstrumentor()
657
+ if not instrumentor.is_instrumented_by_opentelemetry:
658
+ instrumentor.instrument()
659
+ return True
660
+ except Exception as e:
661
+ logging.error(f"Error initializing click instrumentor: {e}")
662
+ Telemetry().log_exception(e)
663
+ return False
664
+
665
+
666
+ def init_confluent_kafka_instrumentation() -> bool:
667
+ """Initialize confluent_kafka instrumentation."""
668
+ try:
669
+ if is_package_installed("confluent-kafka"):
670
+ from opentelemetry.instrumentation.confluent_kafka import ConfluentKafkaInstrumentor
671
+
672
+ instrumentor = ConfluentKafkaInstrumentor()
673
+ if not instrumentor.is_instrumented_by_opentelemetry:
674
+ instrumentor.instrument()
675
+ return True
676
+ except Exception as e:
677
+ logging.error(f"Error initializing confluent_kafka instrumentor: {e}")
678
+ Telemetry().log_exception(e)
679
+ return False
680
+
681
+
682
+ def init_django_instrumentation() -> bool:
683
+ """Initialize django instrumentation."""
684
+ try:
685
+ if is_package_installed("django"):
686
+ from opentelemetry.instrumentation.django import DjangoInstrumentor
687
+
688
+ instrumentor = DjangoInstrumentor()
689
+ if not instrumentor.is_instrumented_by_opentelemetry:
690
+ instrumentor.instrument()
691
+ return True
692
+ except Exception as e:
693
+ logging.error(f"Error initializing django instrumentor: {e}")
694
+ Telemetry().log_exception(e)
695
+ return False
696
+
697
+
698
+ def init_elasticsearch_instrumentation() -> bool:
699
+ """Initialize elasticsearch instrumentation."""
700
+ try:
701
+ if is_package_installed("elasticsearch"):
702
+ from opentelemetry.instrumentation.elasticsearch import ElasticsearchInstrumentor
703
+
704
+ instrumentor = ElasticsearchInstrumentor()
705
+ if not instrumentor.is_instrumented_by_opentelemetry:
706
+ instrumentor.instrument()
707
+ return True
708
+ except Exception as e:
709
+ logging.error(f"Error initializing elasticsearch instrumentor: {e}")
710
+ Telemetry().log_exception(e)
711
+ return False
712
+
713
+
714
+ def init_falcon_instrumentation() -> bool:
715
+ """Initialize falcon instrumentation."""
716
+ try:
717
+ if is_package_installed("falcon"):
718
+ from opentelemetry.instrumentation.falcon import FalconInstrumentor
719
+
720
+ instrumentor = FalconInstrumentor()
721
+ if not instrumentor.is_instrumented_by_opentelemetry:
722
+ instrumentor.instrument()
723
+ return True
724
+ except Exception as e:
725
+ logging.error(f"Error initializing falcon instrumentor: {e}")
726
+ Telemetry().log_exception(e)
727
+ return False
728
+
729
+
730
+ def init_flask_instrumentation() -> bool:
731
+ """Initialize flask instrumentation."""
732
+ try:
733
+ if is_package_installed("flask"):
734
+ from opentelemetry.instrumentation.flask import FlaskInstrumentor
735
+
736
+ instrumentor = FlaskInstrumentor()
737
+ if not instrumentor.is_instrumented_by_opentelemetry:
738
+ instrumentor.instrument()
739
+ return True
740
+ except Exception as e:
741
+ logging.error(f"Error initializing flask instrumentor: {e}")
742
+ Telemetry().log_exception(e)
743
+ return False
744
+
745
+
746
+ def init_grpc_instrumentation() -> bool:
747
+ """Initialize grpc instrumentation."""
748
+ try:
749
+ if is_package_installed("grpcio"):
750
+ from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient
751
+
752
+ instrumentor = GrpcInstrumentorClient()
753
+ if not instrumentor.is_instrumented_by_opentelemetry:
754
+ instrumentor.instrument()
755
+ return True
756
+ except Exception as e:
757
+ logging.error(f"Error initializing grpc instrumentor: {e}")
758
+ Telemetry().log_exception(e)
759
+ return False
760
+
761
+
762
+ def init_jinja2_instrumentation() -> bool:
763
+ """Initialize jinja2 instrumentation."""
764
+ try:
765
+ if is_package_installed("jinja2"):
766
+ from opentelemetry.instrumentation.jinja2 import Jinja2Instrumentor
767
+
768
+ instrumentor = Jinja2Instrumentor()
769
+ if not instrumentor.is_instrumented_by_opentelemetry:
770
+ instrumentor.instrument()
771
+ return True
772
+ except Exception as e:
773
+ logging.error(f"Error initializing jinja2 instrumentor: {e}")
774
+ Telemetry().log_exception(e)
775
+ return False
776
+
777
+
778
+ def init_kafka_python_instrumentation() -> bool:
779
+ """Initialize kafka_python instrumentation."""
780
+ try:
781
+ if is_package_installed("kafka-python"):
782
+ from opentelemetry.instrumentation.kafka import KafkaInstrumentor
783
+
784
+ instrumentor = KafkaInstrumentor()
785
+ if not instrumentor.is_instrumented_by_opentelemetry:
786
+ instrumentor.instrument()
787
+ return True
788
+ except Exception as e:
789
+ logging.error(f"Error initializing kafka_python instrumentor: {e}")
790
+ Telemetry().log_exception(e)
791
+ return False
792
+
793
+
794
+ def init_logging_instrumentation() -> bool:
795
+ """Initialize logging instrumentation."""
796
+ try:
797
+ if is_package_installed("logging"):
798
+ from opentelemetry.instrumentation.logging import LoggingInstrumentor
799
+
800
+ instrumentor = LoggingInstrumentor()
801
+ if not instrumentor.is_instrumented_by_opentelemetry:
802
+ instrumentor.instrument()
803
+ return True
804
+ except Exception as e:
805
+ logging.error(f"Error initializing logging instrumentor: {e}")
806
+ Telemetry().log_exception(e)
807
+ return False
808
+
809
+
810
+ def init_mysql_instrumentation() -> bool:
811
+ """Initialize mysql instrumentation."""
812
+ try:
813
+ if is_package_installed("mysql-connector-python"):
814
+ from opentelemetry.instrumentation.mysql import MySQLInstrumentor
815
+
816
+ instrumentor = MySQLInstrumentor()
817
+ if not instrumentor.is_instrumented_by_opentelemetry:
818
+ instrumentor.instrument()
819
+ return True
820
+ except Exception as e:
821
+ logging.error(f"Error initializing mysql instrumentor: {e}")
822
+ Telemetry().log_exception(e)
823
+ return False
824
+
825
+
826
+ def init_mysqlclient_instrumentation() -> bool:
827
+ """Initialize mysqlclient instrumentation."""
828
+ try:
829
+ if is_package_installed("mysqlclient"):
830
+ from opentelemetry.instrumentation.mysqlclient import MySQLClientInstrumentor
831
+
832
+ instrumentor = MySQLClientInstrumentor()
833
+ if not instrumentor.is_instrumented_by_opentelemetry:
834
+ instrumentor.instrument()
835
+ return True
836
+ except Exception as e:
837
+ logging.error(f"Error initializing mysqlclient instrumentor: {e}")
838
+ Telemetry().log_exception(e)
839
+ return False
840
+
841
+
842
+ def init_pika_instrumentation() -> bool:
843
+ """Initialize pika instrumentation."""
844
+ try:
845
+ if is_package_installed("pika"):
846
+ from opentelemetry.instrumentation.pika import PikaInstrumentor
847
+
848
+ instrumentor = PikaInstrumentor()
849
+ if not instrumentor.is_instrumented_by_opentelemetry:
850
+ instrumentor.instrument()
851
+ return True
852
+ except Exception as e:
853
+ logging.error(f"Error initializing pika instrumentor: {e}")
854
+ Telemetry().log_exception(e)
855
+ return False
856
+
857
+
858
+ def init_psycopg_instrumentation() -> bool:
859
+ """Initialize psycopg instrumentation."""
860
+ try:
861
+ if is_package_installed("psycopg"):
862
+ from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
863
+
864
+ instrumentor = PsycopgInstrumentor()
865
+ if not instrumentor.is_instrumented_by_opentelemetry:
866
+ instrumentor.instrument()
867
+ return True
868
+ except Exception as e:
869
+ logging.error(f"Error initializing psycopg instrumentor: {e}")
870
+ Telemetry().log_exception(e)
871
+ return False
872
+
873
+
874
+ def init_psycopg2_instrumentation() -> bool:
875
+ """Initialize psycopg2 instrumentation."""
876
+ try:
877
+ if is_package_installed("psycopg2"):
878
+ from opentelemetry.instrumentation.psycopg2 import Psycopg2Instrumentor
879
+
880
+ instrumentor = Psycopg2Instrumentor()
881
+ if not instrumentor.is_instrumented_by_opentelemetry:
882
+ instrumentor.instrument()
883
+ return True
884
+ except Exception as e:
885
+ logging.error(f"Error initializing psycopg2 instrumentor: {e}")
886
+ Telemetry().log_exception(e)
887
+ return False
888
+
889
+
890
+ def init_pymemcache_instrumentation() -> bool:
891
+ """Initialize pymemcache instrumentation."""
892
+ try:
893
+ if is_package_installed("pymemcache"):
894
+ from opentelemetry.instrumentation.pymemcache import PymemcacheInstrumentor
895
+
896
+ instrumentor = PymemcacheInstrumentor()
897
+ if not instrumentor.is_instrumented_by_opentelemetry:
898
+ instrumentor.instrument()
899
+ return True
900
+ except Exception as e:
901
+ logging.error(f"Error initializing pymemcache instrumentor: {e}")
902
+ Telemetry().log_exception(e)
903
+ return False
904
+
905
+
906
+ def init_pymongo_instrumentation() -> bool:
907
+ """Initialize pymongo instrumentation."""
908
+ try:
909
+ if is_package_installed("pymongo"):
910
+ from opentelemetry.instrumentation.pymongo import PymongoInstrumentor
911
+
912
+ instrumentor = PymongoInstrumentor()
913
+ if not instrumentor.is_instrumented_by_opentelemetry:
914
+ instrumentor.instrument()
915
+ return True
916
+ except Exception as e:
917
+ logging.error(f"Error initializing pymongo instrumentor: {e}")
918
+ Telemetry().log_exception(e)
919
+ return False
920
+
921
+
922
+ def init_pymssql_instrumentation() -> bool:
923
+ """Initialize pymssql instrumentation."""
924
+ try:
925
+ if is_package_installed("pymssql"):
926
+ from opentelemetry.instrumentation.pymssql import PyMSSQLInstrumentor
927
+
928
+ instrumentor = PyMSSQLInstrumentor()
929
+ if not instrumentor.is_instrumented_by_opentelemetry:
930
+ instrumentor.instrument()
931
+ return True
932
+ except Exception as e:
933
+ logging.error(f"Error initializing pymssql instrumentor: {e}")
934
+ Telemetry().log_exception(e)
935
+ return False
936
+
937
+
938
+ def init_pymysql_instrumentation() -> bool:
939
+ """Initialize pymysql instrumentation."""
940
+ try:
941
+ if is_package_installed("PyMySQL"):
942
+ from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor
943
+
944
+ instrumentor = PyMySQLInstrumentor()
945
+ if not instrumentor.is_instrumented_by_opentelemetry:
946
+ instrumentor.instrument()
947
+ return True
948
+ except Exception as e:
949
+ logging.error(f"Error initializing pymysql instrumentor: {e}")
950
+ Telemetry().log_exception(e)
951
+ return False
952
+
953
+
954
+ def init_pyramid_instrumentation() -> bool:
955
+ """Initialize pyramid instrumentation."""
956
+ try:
957
+ if is_package_installed("pyramid"):
958
+ from opentelemetry.instrumentation.pyramid import PyramidInstrumentor
959
+
960
+ instrumentor = PyramidInstrumentor()
961
+ if not instrumentor.is_instrumented_by_opentelemetry:
962
+ instrumentor.instrument()
963
+ return True
964
+ except Exception as e:
965
+ logging.error(f"Error initializing pyramid instrumentor: {e}")
966
+ Telemetry().log_exception(e)
967
+ return False
968
+
969
+
970
+ def init_redis_instrumentation() -> bool:
971
+ """Initialize redis instrumentation."""
972
+ try:
973
+ if is_package_installed("redis"):
974
+ from opentelemetry.instrumentation.redis import RedisInstrumentor
975
+
976
+ instrumentor = RedisInstrumentor()
977
+ if not instrumentor.is_instrumented_by_opentelemetry:
978
+ instrumentor.instrument()
979
+ return True
980
+ except Exception as e:
981
+ logging.error(f"Error initializing redis instrumentor: {e}")
982
+ Telemetry().log_exception(e)
983
+ return False
984
+
985
+
986
+ def init_remoulade_instrumentation() -> bool:
987
+ """Initialize remoulade instrumentation."""
988
+ try:
989
+ if is_package_installed("remoulade"):
990
+ from opentelemetry.instrumentation.remoulade import RemouladeInstrumentor
991
+
992
+ instrumentor = RemouladeInstrumentor()
993
+ if not instrumentor.is_instrumented_by_opentelemetry:
994
+ instrumentor.instrument()
995
+ return True
996
+ except Exception as e:
997
+ logging.error(f"Error initializing remoulade instrumentor: {e}")
998
+ Telemetry().log_exception(e)
999
+ return False
1000
+
1001
+
1002
+ def init_requests_instrumentation() -> bool:
1003
+ """Initialize requests instrumentation."""
1004
+ try:
1005
+ if is_package_installed("requests"):
1006
+ from opentelemetry.instrumentation.requests import RequestsInstrumentor
1007
+
1008
+ instrumentor = RequestsInstrumentor()
1009
+ if not instrumentor.is_instrumented_by_opentelemetry:
1010
+ instrumentor.instrument()
1011
+ return True
1012
+ except Exception as e:
1013
+ logging.error(f"Error initializing requests instrumentor: {e}")
1014
+ Telemetry().log_exception(e)
1015
+ return False
1016
+
1017
+
1018
+ def init_sqlalchemy_instrumentation() -> bool:
1019
+ """Initialize sqlalchemy instrumentation."""
1020
+ try:
1021
+ if is_package_installed("sqlalchemy"):
1022
+ from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
1023
+
1024
+ instrumentor = SQLAlchemyInstrumentor()
1025
+ if not instrumentor.is_instrumented_by_opentelemetry:
1026
+ instrumentor.instrument()
1027
+ return True
1028
+ except Exception as e:
1029
+ logging.error(f"Error initializing sqlalchemy instrumentor: {e}")
1030
+ Telemetry().log_exception(e)
1031
+ return False
1032
+
1033
+
1034
+ def init_sqlite3_instrumentation() -> bool:
1035
+ """Initialize sqlite3 instrumentation."""
1036
+ try:
1037
+ if is_package_installed("sqlite3"):
1038
+ from opentelemetry.instrumentation.sqlite3 import SQLite3Instrumentor
1039
+
1040
+ instrumentor = SQLite3Instrumentor()
1041
+ if not instrumentor.is_instrumented_by_opentelemetry:
1042
+ instrumentor.instrument()
1043
+ return True
1044
+ except Exception as e:
1045
+ logging.error(f"Error initializing sqlite3 instrumentor: {e}")
1046
+ Telemetry().log_exception(e)
1047
+ return False
1048
+
1049
+
1050
+ def init_starlette_instrumentation() -> bool:
1051
+ """Initialize starlette instrumentation."""
1052
+ try:
1053
+ if is_package_installed("starlette"):
1054
+ from opentelemetry.instrumentation.starlette import StarletteInstrumentor
1055
+
1056
+ instrumentor = StarletteInstrumentor()
1057
+ if not instrumentor.is_instrumented_by_opentelemetry:
1058
+ instrumentor.instrument()
1059
+ return True
1060
+ except Exception as e:
1061
+ logging.error(f"Error initializing starlette instrumentor: {e}")
1062
+ Telemetry().log_exception(e)
1063
+ return False
1064
+
1065
+
1066
+ def init_system_metrics_instrumentation() -> bool:
1067
+ """Initialize system_metrics instrumentation."""
1068
+ try:
1069
+ if is_package_installed("psutil"):
1070
+ from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
1071
+
1072
+ instrumentor = SystemMetricsInstrumentor()
1073
+ if not instrumentor.is_instrumented_by_opentelemetry:
1074
+ instrumentor.instrument()
1075
+ return True
1076
+ except Exception as e:
1077
+ logging.error(f"Error initializing system_metrics instrumentor: {e}")
1078
+ Telemetry().log_exception(e)
1079
+ return False
1080
+
1081
+
1082
+ def init_threading_instrumentation() -> bool:
1083
+ """Initialize threading instrumentation."""
1084
+ try:
1085
+ from opentelemetry.instrumentation.threading import ThreadingInstrumentor
1086
+
1087
+ instrumentor = ThreadingInstrumentor()
1088
+ if not instrumentor.is_instrumented_by_opentelemetry:
1089
+ instrumentor.instrument()
1090
+ return True
1091
+ except Exception as e:
1092
+ logging.error(f"Error initializing threading instrumentor: {e}")
1093
+ Telemetry().log_exception(e)
1094
+ return False
1095
+
1096
+
1097
+ def init_tornado_instrumentation() -> bool:
1098
+ """Initialize tornado instrumentation."""
1099
+ try:
1100
+ if is_package_installed("tornado"):
1101
+ from opentelemetry.instrumentation.tornado import TornadoInstrumentor
1102
+
1103
+ instrumentor = TornadoInstrumentor()
1104
+ if not instrumentor.is_instrumented_by_opentelemetry:
1105
+ instrumentor.instrument()
1106
+ return True
1107
+ except Exception as e:
1108
+ logging.error(f"Error initializing tornado instrumentor: {e}")
1109
+ Telemetry().log_exception(e)
1110
+ return False
1111
+
1112
+
1113
+ def init_tortoiseorm_instrumentation() -> bool:
1114
+ """Initialize tortoiseorm instrumentation."""
1115
+ try:
1116
+ if is_package_installed("tortoise-orm"):
1117
+ from opentelemetry.instrumentation.tortoiseorm import TortoiseORMInstrumentor
1118
+
1119
+ instrumentor = TortoiseORMInstrumentor()
1120
+ if not instrumentor.is_instrumented_by_opentelemetry:
1121
+ instrumentor.instrument()
1122
+ return True
1123
+ except Exception as e:
1124
+ logging.error(f"Error initializing tortoiseorm instrumentor: {e}")
1125
+ Telemetry().log_exception(e)
1126
+ return False
1127
+
1128
+
1129
+ def init_urllib_instrumentation() -> bool:
1130
+ """Initialize urllib instrumentation."""
1131
+ try:
1132
+ from opentelemetry.instrumentation.urllib import URLLibInstrumentor
1133
+
1134
+ instrumentor = URLLibInstrumentor()
1135
+ if not instrumentor.is_instrumented_by_opentelemetry:
1136
+ instrumentor.instrument()
1137
+ return True
1138
+ except Exception as e:
1139
+ logging.error(f"Error initializing urllib instrumentor: {e}")
1140
+ Telemetry().log_exception(e)
1141
+ return False
1142
+
1143
+
1144
+ def init_urllib3_instrumentation() -> bool:
1145
+ """Initialize urllib3 instrumentation."""
1146
+ try:
1147
+ if is_package_installed("urllib3"):
1148
+ from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
1149
+
1150
+ instrumentor = URLLib3Instrumentor()
1151
+ if not instrumentor.is_instrumented_by_opentelemetry:
1152
+ instrumentor.instrument()
1153
+ return True
1154
+ except Exception as e:
1155
+ logging.error(f"Error initializing urllib3 instrumentor: {e}")
1156
+ Telemetry().log_exception(e)
1157
+ return False