Skip to content

Commit 1b99dc0

Browse files
authored
Merge pull request #523 from Scale3-Labs/ali/filter-warnings
clean up warning messages
2 parents 2884436 + 89b5c9f commit 1b99dc0

File tree

2 files changed

+64
-28
lines changed

2 files changed

+64
-28
lines changed

src/langtrace_python_sdk/langtrace.py

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,79 @@
1717
import logging
1818
import os
1919
import sys
20+
import warnings
2021
from typing import Any, Dict, Optional
2122

2223
import sentry_sdk
2324
from colorama import Fore
2425
from opentelemetry import trace
25-
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import \
26-
OTLPSpanExporter as GRPCExporter
27-
from opentelemetry.exporter.otlp.proto.http.trace_exporter import \
28-
OTLPSpanExporter as HTTPExporter
26+
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
27+
OTLPSpanExporter as GRPCExporter,
28+
)
29+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
30+
OTLPSpanExporter as HTTPExporter,
31+
)
2932
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
3033
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
3134
from opentelemetry.sdk.trace import TracerProvider
32-
from opentelemetry.sdk.trace.export import (BatchSpanProcessor,
33-
ConsoleSpanExporter,
34-
SimpleSpanProcessor)
35+
from opentelemetry.sdk.trace.export import (
36+
BatchSpanProcessor,
37+
ConsoleSpanExporter,
38+
SimpleSpanProcessor,
39+
)
3540
from opentelemetry.util.re import parse_env_headers
3641
from sentry_sdk.types import Event, Hint
3742

3843
from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME, SENTRY_DSN
3944
from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
40-
LANGTRACE_REMOTE_URL, LANGTRACE_SESSION_ID_HEADER)
41-
from langtrace_python_sdk.extensions.langtrace_exporter import \
42-
LangTraceExporter
45+
LANGTRACE_REMOTE_URL,
46+
LANGTRACE_SESSION_ID_HEADER,
47+
)
48+
from langtrace_python_sdk.extensions.langtrace_exporter import LangTraceExporter
4349
from langtrace_python_sdk.instrumentation import (
44-
AgnoInstrumentation, AnthropicInstrumentation, AutogenInstrumentation,
45-
AWSBedrockInstrumentation, CerebrasInstrumentation, ChromaInstrumentation,
46-
CleanLabInstrumentation, CohereInstrumentation, CrewAIInstrumentation,
47-
CrewaiToolsInstrumentation, DspyInstrumentation, EmbedchainInstrumentation,
48-
GeminiInstrumentation, GoogleGenaiInstrumentation, GraphlitInstrumentation,
49-
GroqInstrumentation, LangchainCommunityInstrumentation,
50-
LangchainCoreInstrumentation, LangchainInstrumentation, LanggraphInstrumentation,
51-
LiteLLMInstrumentation, LlamaindexInstrumentation, MilvusInstrumentation,
52-
MistralInstrumentation, Neo4jInstrumentation, Neo4jGraphRAGInstrumentation,
53-
OllamaInstrumentor, OpenAIAgentsInstrumentation, OpenAIInstrumentation,
54-
PhiDataInstrumentation, PineconeInstrumentation, PyMongoInstrumentation,
55-
QdrantInstrumentation, VertexAIInstrumentation, WeaviateInstrumentation)
56-
from langtrace_python_sdk.types import (DisableInstrumentations,
57-
InstrumentationMethods)
58-
from langtrace_python_sdk.utils import (check_if_sdk_is_outdated,
59-
get_sdk_version, is_package_installed,
60-
validate_instrumentations)
50+
AgnoInstrumentation,
51+
AnthropicInstrumentation,
52+
AutogenInstrumentation,
53+
AWSBedrockInstrumentation,
54+
CerebrasInstrumentation,
55+
ChromaInstrumentation,
56+
CleanLabInstrumentation,
57+
CohereInstrumentation,
58+
CrewAIInstrumentation,
59+
CrewaiToolsInstrumentation,
60+
DspyInstrumentation,
61+
EmbedchainInstrumentation,
62+
GeminiInstrumentation,
63+
GoogleGenaiInstrumentation,
64+
GraphlitInstrumentation,
65+
GroqInstrumentation,
66+
LangchainCommunityInstrumentation,
67+
LangchainCoreInstrumentation,
68+
LangchainInstrumentation,
69+
LanggraphInstrumentation,
70+
LiteLLMInstrumentation,
71+
LlamaindexInstrumentation,
72+
MilvusInstrumentation,
73+
MistralInstrumentation,
74+
Neo4jInstrumentation,
75+
Neo4jGraphRAGInstrumentation,
76+
OllamaInstrumentor,
77+
OpenAIAgentsInstrumentation,
78+
OpenAIInstrumentation,
79+
PhiDataInstrumentation,
80+
PineconeInstrumentation,
81+
PyMongoInstrumentation,
82+
QdrantInstrumentation,
83+
VertexAIInstrumentation,
84+
WeaviateInstrumentation,
85+
)
86+
from langtrace_python_sdk.types import DisableInstrumentations, InstrumentationMethods
87+
from langtrace_python_sdk.utils import (
88+
check_if_sdk_is_outdated,
89+
get_sdk_version,
90+
is_package_installed,
91+
validate_instrumentations,
92+
)
6193
from langtrace_python_sdk.utils.langtrace_sampler import LangtraceSampler
6294

6395

@@ -329,6 +361,8 @@ def init_instrumentations(
329361
if is_package_installed(name):
330362
try:
331363
v.instrument()
364+
warnings.filterwarnings("ignore", category=DeprecationWarning)
365+
warnings.filterwarnings("ignore", category=UserWarning)
332366
except Exception as e:
333367
print(f"Skipping {name} due to error while instrumenting: {e}")
334368

@@ -354,5 +388,7 @@ def init_instrumentations(
354388
if is_package_installed(name):
355389
try:
356390
v.instrument()
391+
warnings.filterwarnings("ignore", category=DeprecationWarning)
392+
warnings.filterwarnings("ignore", category=UserWarning)
357393
except Exception as e:
358394
print(f"Skipping {name} due to error while instrumenting: {e}")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.8.12"
1+
__version__ = "3.8.13"

0 commit comments

Comments
 (0)