From 6ad0a8948db4c09401a67e74d4d931b1ceb5bc26 Mon Sep 17 00:00:00 2001 From: Karthik Kalyanaraman <105607645+karthikscale3@users.noreply.github.com> Date: Thu, 4 Apr 2024 16:01:36 -0700 Subject: [PATCH] Release (#61) * Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version * Cleanup logging (#56) * Fix streaming bug (#57) * Cleanup logging * Fix streaming bug * bump version * add sdk name (#60) --------- Co-authored-by: Ali Waleed <134522290+alizenhom@users.noreply.github.com> Co-authored-by: MayuriS24 Co-authored-by: Rohit Kadhe <113367036+rohit-kadhe@users.noreply.github.com> --- src/langtrace_python_sdk/instrumentation/anthropic/patch.py | 1 + src/langtrace_python_sdk/instrumentation/chroma/patch.py | 1 + src/langtrace_python_sdk/instrumentation/langchain/patch.py | 1 + .../instrumentation/langchain_community/patch.py | 1 + .../instrumentation/langchain_core/patch.py | 2 ++ src/langtrace_python_sdk/instrumentation/llamaindex/patch.py | 1 + src/langtrace_python_sdk/instrumentation/openai/patch.py | 3 +++ src/langtrace_python_sdk/instrumentation/pinecone/patch.py | 1 + src/tests/anthropic/test_anthropic.py | 1 + src/tests/chroma/test_chroma.py | 1 + src/tests/langchain/test_langchain.py | 1 + src/tests/langchain/test_langchain_community.py | 1 + src/tests/langchain/test_langchain_core.py | 2 ++ src/tests/openai/test_chat_completion.py | 1 + src/tests/openai/test_image_generation.py | 1 + src/tests/pinecone/test_pinecone.py | 1 + 16 files changed, 20 insertions(+) diff --git a/src/langtrace_python_sdk/instrumentation/anthropic/patch.py b/src/langtrace_python_sdk/instrumentation/anthropic/patch.py index 8e1eae5c..860ad4ef 100644 --- a/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +++ b/src/langtrace_python_sdk/instrumentation/anthropic/patch.py @@ -35,6 +35,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "llm", "langtrace.service.version": version, diff --git a/src/langtrace_python_sdk/instrumentation/chroma/patch.py b/src/langtrace_python_sdk/instrumentation/chroma/patch.py index 947a5f83..4b73c758 100644 --- a/src/langtrace_python_sdk/instrumentation/chroma/patch.py +++ b/src/langtrace_python_sdk/instrumentation/chroma/patch.py @@ -23,6 +23,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "vectordb", "langtrace.service.version": version, diff --git a/src/langtrace_python_sdk/instrumentation/langchain/patch.py b/src/langtrace_python_sdk/instrumentation/langchain/patch.py index 4df3f142..07b1ece8 100644 --- a/src/langtrace_python_sdk/instrumentation/langchain/patch.py +++ b/src/langtrace_python_sdk/instrumentation/langchain/patch.py @@ -25,6 +25,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, diff --git a/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py b/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py index d00f6452..13443305 100644 --- a/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +++ b/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py @@ -17,6 +17,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, diff --git a/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py b/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py index dd7ed7a0..f768ab28 100644 --- a/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +++ b/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py @@ -31,6 +31,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, @@ -96,6 +97,7 @@ def runnable_patch( def traced_method(wrapped, instance, args, kwargs): service_provider = SERVICE_PROVIDERS["LANGCHAIN_CORE"] span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, diff --git a/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py b/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py index 85434d82..eae77cb3 100644 --- a/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +++ b/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py @@ -20,6 +20,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, diff --git a/src/langtrace_python_sdk/instrumentation/openai/patch.py b/src/langtrace_python_sdk/instrumentation/openai/patch.py index deb57c2f..7abc2bc1 100644 --- a/src/langtrace_python_sdk/instrumentation/openai/patch.py +++ b/src/langtrace_python_sdk/instrumentation/openai/patch.py @@ -30,6 +30,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "llm", "langtrace.service.version": version, @@ -99,6 +100,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "llm", "langtrace.service.version": version, @@ -313,6 +315,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "llm", "langtrace.service.version": version, diff --git a/src/langtrace_python_sdk/instrumentation/pinecone/patch.py b/src/langtrace_python_sdk/instrumentation/pinecone/patch.py index 3f3c203c..c1f519cd 100644 --- a/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +++ b/src/langtrace_python_sdk/instrumentation/pinecone/patch.py @@ -21,6 +21,7 @@ def traced_method(wrapped, instance, args, kwargs): extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY) span_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": service_provider, "langtrace.service.type": "vectordb", "langtrace.service.version": version, diff --git a/src/tests/anthropic/test_anthropic.py b/src/tests/anthropic/test_anthropic.py index dc27ce34..973f9928 100644 --- a/src/tests/anthropic/test_anthropic.py +++ b/src/tests/anthropic/test_anthropic.py @@ -46,6 +46,7 @@ def test_anthropic(self): self.assertTrue(self.span.set_status.has_calls([call(Status(StatusCode.OK))])) expected_attributes = { + "langtrace.sdk.name": "langtrace-python-sdk", "langtrace.service.name": "Anthropic", "langtrace.service.type": "llm", "langtrace.service.version": version, diff --git a/src/tests/chroma/test_chroma.py b/src/tests/chroma/test_chroma.py index 7f1d7cac..210c314d 100644 --- a/src/tests/chroma/test_chroma.py +++ b/src/tests/chroma/test_chroma.py @@ -39,6 +39,7 @@ def test_collection_patch_success(self): # Verify span attributes are set as expected expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', 'langtrace.service.name': 'Chroma', 'langtrace.service.type': 'vectordb', 'langtrace.service.version': '1.2.3', diff --git a/src/tests/langchain/test_langchain.py b/src/tests/langchain/test_langchain.py index 4897a2ac..b05631a0 100644 --- a/src/tests/langchain/test_langchain.py +++ b/src/tests/langchain/test_langchain.py @@ -38,6 +38,7 @@ def test_generic_patch(self): service_provider = "Langchain" expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, diff --git a/src/tests/langchain/test_langchain_community.py b/src/tests/langchain/test_langchain_community.py index 39ba3aea..7a936bdd 100644 --- a/src/tests/langchain/test_langchain_community.py +++ b/src/tests/langchain/test_langchain_community.py @@ -38,6 +38,7 @@ def test_generic_patch(self): service_provider = "Langchain Community" expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, diff --git a/src/tests/langchain/test_langchain_core.py b/src/tests/langchain/test_langchain_core.py index 5a75703a..935fb47b 100644 --- a/src/tests/langchain/test_langchain_core.py +++ b/src/tests/langchain/test_langchain_core.py @@ -38,6 +38,7 @@ def test_generic_patch(self): service_provider = "Langchain Core" expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, @@ -82,6 +83,7 @@ def test_runnable_patch(self): service_provider = "Langchain Core" expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', "langtrace.service.name": service_provider, "langtrace.service.type": "framework", "langtrace.service.version": version, diff --git a/src/tests/openai/test_chat_completion.py b/src/tests/openai/test_chat_completion.py index 7a8a99fc..a1bfdd00 100644 --- a/src/tests/openai/test_chat_completion.py +++ b/src/tests/openai/test_chat_completion.py @@ -63,6 +63,7 @@ def test_chat_completions_create_non_streaming(self): self.assertTrue(self.tracer.start_as_current_span.called_once_with("openai.chat.completions.create", kind=SpanKind.CLIENT)) expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', "langtrace.service.name": "OpenAI", "langtrace.service.type": "llm", "langtrace.service.version": version, diff --git a/src/tests/openai/test_image_generation.py b/src/tests/openai/test_image_generation.py index b01bdd68..e1dddabc 100644 --- a/src/tests/openai/test_image_generation.py +++ b/src/tests/openai/test_image_generation.py @@ -51,6 +51,7 @@ def test_image_generation(self): self.assertTrue(self.tracer.start_as_current_span.called_once_with("openai.images.generate", kind=SpanKind.CLIENT)) expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', "langtrace.service.name": "OpenAI", "langtrace.service.type": "llm", "langtrace.service.version": version, diff --git a/src/tests/pinecone/test_pinecone.py b/src/tests/pinecone/test_pinecone.py index 3be80400..e21cf06b 100644 --- a/src/tests/pinecone/test_pinecone.py +++ b/src/tests/pinecone/test_pinecone.py @@ -42,6 +42,7 @@ def test_pinecone(self): api = APIS[method] service_provider = SERVICE_PROVIDERS["PINECONE"] expected_attributes = { + 'langtrace.sdk.name': 'langtrace-python-sdk', "langtrace.service.name": service_provider, "langtrace.service.type": "vectordb", "langtrace.service.version": version,