netra-sdk 0.1.0__py3-none-any.whl → 0.1.1__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.

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