Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
4d717b1
Merge branch 'development' into release
karthikscale3 Apr 24, 2024
0233826
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Apr 28, 2024
7f4e951
Merge branch 'development' into release
karthikscale3 Apr 28, 2024
81a6ca0
Merge
karthikscale3 Jun 13, 2024
0c19f77
Merge branch 'development' into release
karthikscale3 Jun 13, 2024
c3a6ccf
remove logs
karthikscale3 Jun 13, 2024
a99cf10
remove requirements
karthikscale3 Jun 13, 2024
1379b27
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jun 17, 2024
dae04e7
Merge branch 'development' into release
karthikscale3 Jun 17, 2024
129e927
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jun 24, 2024
16e67f9
Merge branch 'development' into release
karthikscale3 Jun 24, 2024
e604e93
Bump version
karthikscale3 Jun 24, 2024
7e00473
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jun 24, 2024
6ac71aa
Merge branch 'development' into release
karthikscale3 Jun 24, 2024
c39bf01
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jun 24, 2024
f89e38c
Merge branch 'development' into release
karthikscale3 Jun 24, 2024
e95e743
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jul 19, 2024
c62e803
Squash
karthikscale3 Jul 25, 2024
d7fd3fb
Merge
karthikscale3 Jul 25, 2024
c4ea507
Merge branch 'development' into release
karthikscale3 Jul 25, 2024
4c74fd8
Merge
karthikscale3 Jul 31, 2024
9a83e20
Merge branch 'development' into release
karthikscale3 Jul 31, 2024
09d5631
Merge
karthikscale3 Aug 3, 2024
508e72b
Merge
karthikscale3 Aug 3, 2024
ad44fa3
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Aug 13, 2024
ad168b3
Merge branch 'development' into release
karthikscale3 Aug 13, 2024
6876f92
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Aug 30, 2024
630169a
Merge branch 'development' into release
karthikscale3 Aug 30, 2024
0e1aae3
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Sep 1, 2024
c266698
Merge branch 'development' into release
karthikscale3 Sep 1, 2024
5b9895f
merge
karthikscale3 Sep 4, 2024
04fd825
Merge branch 'development' into release
karthikscale3 Sep 4, 2024
510e4b8
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Sep 6, 2024
e63bee2
Merge branch 'development' into release
karthikscale3 Sep 6, 2024
9741a3e
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Sep 8, 2024
4f7f3c4
Merge branch 'development' into release
karthikscale3 Sep 8, 2024
32fac05
merge
karthikscale3 Sep 11, 2024
4920395
Merge branch 'development' into release
karthikscale3 Sep 11, 2024
2e8956d
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Sep 11, 2024
372ae29
Merge branch 'development' into release
karthikscale3 Sep 11, 2024
da82f72
bump version
karthikscale3 Sep 26, 2024
ef0332f
Merge branch 'development' into release
karthikscale3 Sep 26, 2024
105749c
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Oct 8, 2024
0f99827
Merge branch 'development' into release
karthikscale3 Oct 8, 2024
b52fce7
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Oct 8, 2024
ddaf4b5
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Oct 10, 2024
54cddc8
Merge branch 'development' into release
karthikscale3 Oct 10, 2024
ced0a31
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Oct 16, 2024
4e22bde
Merge branch 'development' into release
karthikscale3 Oct 16, 2024
135bdc7
bump version
karthikscale3 Oct 18, 2024
6b0a460
Merge branch 'development' into release
karthikscale3 Oct 22, 2024
7824c39
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Oct 22, 2024
109990a
minor
karthikscale3 Oct 22, 2024
2e9befb
version
karthikscale3 Oct 31, 2024
21cdc08
Merge branch 'development' into release
karthikscale3 Oct 31, 2024
7959744
Merge branch 'development' into release
karthikscale3 Oct 31, 2024
aa3dc2f
switch to http exporter
karthikscale3 Oct 31, 2024
4e22e16
Include setuptools to deps
karthikscale3 Nov 15, 2024
a7b34ab
Merge branch 'development' into release
karthikscale3 Nov 15, 2024
736fb60
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Nov 19, 2024
41c58e8
Merge branch 'development' into release
karthikscale3 Nov 19, 2024
129f764
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Nov 25, 2024
f7188c5
Merge branch 'development' into release
karthikscale3 Nov 25, 2024
d43358a
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Dec 1, 2024
fa7b13b
Merge branch 'development' into release
karthikscale3 Dec 1, 2024
fab8619
merge
karthikscale3 Dec 10, 2024
5649f0a
Merge branch 'development' into release
karthikscale3 Dec 10, 2024
0274620
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jan 20, 2025
0897cc7
Merge branch 'development' into release
karthikscale3 Jan 20, 2025
8eee1e1
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jan 20, 2025
8cc7f7c
Merge branch 'development' into release
karthikscale3 Jan 20, 2025
d6b6531
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jan 20, 2025
30b6e00
Merge branch 'development' into release
karthikscale3 Jan 20, 2025
1d7362a
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jan 22, 2025
36ba737
Merge branch 'development' into release
karthikscale3 Jan 22, 2025
d9bcdb4
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jan 27, 2025
a5f3da6
Merge branch 'development' into release
karthikscale3 Jan 27, 2025
b856e03
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Jan 27, 2025
5f14b58
Merge branch 'development' into release
karthikscale3 Jan 27, 2025
fd9baed
merge
karthikscale3 Feb 6, 2025
ece9c97
Merge branch 'development' into release
karthikscale3 Feb 6, 2025
cd1a481
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Feb 7, 2025
a3730af
Merge branch 'development' into release
karthikscale3 Feb 7, 2025
5453a92
merge
karthikscale3 Mar 5, 2025
5d65fb3
Merge branch 'development' into release
karthikscale3 Mar 5, 2025
0661c29
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Mar 12, 2025
a51cff1
Merge branch 'development' into release
karthikscale3 Mar 12, 2025
0a3a4a6
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Mar 13, 2025
d1695ac
Merge branch 'development' into release
karthikscale3 Mar 13, 2025
2349adc
add instrumentation for neo4j
obinnaokafor Mar 20, 2025
9826364
update version
obinnaokafor Mar 20, 2025
ea6bcd7
update trace attributes version
obinnaokafor Mar 20, 2025
6379505
update imports
obinnaokafor Mar 24, 2025
04766a9
Merge pull request #507 from Scale3-Labs/obinna/S3EN-1111-support-neo…
obinnascale3 Mar 24, 2025
ed83a02
add neo4j result span attributes
obinnaokafor Mar 26, 2025
a3c4c2e
add neo4j result span attributes
obinnaokafor Mar 26, 2025
081e457
bump bersion
obinnaokafor Mar 26, 2025
565f3b9
fix db attributes error and add examples
obinnaokafor Mar 26, 2025
017df27
handle result transformer
obinnaokafor Mar 27, 2025
a76cb32
Merge pull request #510 from Scale3-Labs/obinna/S3EN-1111-update-neo4…
obinnascale3 Mar 27, 2025
75b0db2
fix genai and pinecone instrumentations (#512)
obinnascale3 Apr 2, 2025
7b0810d
Improve Agno instrumentation (#513)
karthikscale3 Apr 2, 2025
5663107
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Apr 2, 2025
d2967d9
Merge branch 'development' into release
karthikscale3 Apr 2, 2025
e5b75c3
Merge branch 'development' into release
karthikscale3 Apr 2, 2025
ab8e6a0
Merge branch 'release' of github.com:Scale3-Labs/langtrace-python-sdk…
karthikscale3 Apr 2, 2025
fe9f482
Merge branch 'development' into release
karthikscale3 Apr 2, 2025
ae3598b
cast token count to int
obinnaokafor Apr 2, 2025
f83afda
bump version
obinnaokafor Apr 2, 2025
528c3d8
only redirect stdout if logging is disabled
obinnaokafor Apr 2, 2025
624cdc3
bump version
obinnaokafor Apr 2, 2025
56e78cb
fix openai agents attribute error
obinnaokafor Apr 2, 2025
519cfdb
bump version
obinnaokafor Apr 2, 2025
34d9396
Merge pull request #518 from Scale3-Labs/obinna/S3EN-3020-fix-openai-…
obinnascale3 Apr 2, 2025
cbaa8aa
Merge pull request #517 from Scale3-Labs/obinna/S3EN-2977-fix-sysout-…
obinnascale3 Apr 2, 2025
db4ca91
Merge pull request #516 from Scale3-Labs/obinna/S3EN-1111-fix-cohere-…
obinnascale3 Apr 2, 2025
3777dd1
fix openai responses api instrumentation (#519)
obinnascale3 Apr 2, 2025
071658a
Merge branch 'main' of github.com:Scale3-Labs/langtrace-python-sdk in…
karthikscale3 Apr 2, 2025
0a4f622
Merge branch 'development' into release
karthikscale3 Apr 2, 2025
8c1dc5a
bump version
karthikscale3 Apr 2, 2025
0abf70b
bump version
karthikscale3 Apr 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 62 additions & 59 deletions src/langtrace_python_sdk/instrumentation/cohere/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,25 @@ def traced_method(wrapped, instance, args, kwargs):
and result.meta.billed_units is not None
):
usage = result.meta.billed_units
if usage is not None:
span.set_attribute(
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
usage.input_tokens or 0,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
usage.output_tokens or 0,
)

span.set_attribute(
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
(usage.input_tokens or 0) + (usage.output_tokens or 0),
)

span.set_attribute(
"search_units",
usage.search_units or 0,
)
input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
span.set_attribute(
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
input_tokens,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
output_tokens,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens,
)
span.set_attribute(
"search_units",
int(usage.search_units) if usage.search_units else 0,
)


span.set_status(StatusCode.OK)
span.end()
Expand Down Expand Up @@ -309,25 +309,25 @@ def traced_method(wrapped, instance, args, kwargs):
and result.meta.billed_units is not None
):
usage = result.meta.billed_units
if usage is not None:
span.set_attribute(
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
usage.input_tokens or 0,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
usage.output_tokens or 0,
)

span.set_attribute(
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
(usage.input_tokens or 0) + (usage.output_tokens or 0),
)

span.set_attribute(
"search_units",
usage.search_units or 0,
)
input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
span.set_attribute(
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
input_tokens,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
output_tokens,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens,
)
span.set_attribute(
"search_units",
int(usage.search_units) if usage.search_units else 0,
)

span.set_status(StatusCode.OK)
span.end()
return result
Expand Down Expand Up @@ -419,10 +419,12 @@ def traced_method(wrapped, instance, args, kwargs):
if (hasattr(result.usage, "billed_units") and
result.usage.billed_units is not None):
usage = result.usage.billed_units
input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
for metric, value in {
"input": usage.input_tokens or 0,
"output": usage.output_tokens or 0,
"total": (usage.input_tokens or 0) + (usage.output_tokens or 0),
"input": input_tokens,
"output": output_tokens,
"total": input_tokens + output_tokens,
}.items():
span.set_attribute(
f"gen_ai.usage.{metric}_tokens",
Expand Down Expand Up @@ -571,26 +573,27 @@ def traced_method(wrapped, instance, args, kwargs):
and response.meta.billed_units is not None
):
usage = response.meta.billed_units
if usage is not None:
span.set_attribute(
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
usage.input_tokens or 0,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
usage.output_tokens or 0,
)

input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
span.set_attribute(
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
input_tokens,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
output_tokens,
)
span.set_attribute(
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens,
)

if usage.search_units is not None:
span.set_attribute(
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
(usage.input_tokens or 0)
+ (usage.output_tokens or 0),
"search_units",
int(usage.search_units) if usage.search_units else 0,
)
if usage.search_units is not None:
span.set_attribute(
"search_units",
usage.search_units or 0,
)


yield event
finally:
Expand Down
5 changes: 4 additions & 1 deletion src/langtrace_python_sdk/instrumentation/openai/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def traced_method(
return StreamWrapper(response, span)
else:
_set_openai_agentic_response_attributes(span, response)

span.set_status(StatusCode.OK)
span.end()
return response
except Exception as err:
span.record_exception(err)
Expand Down Expand Up @@ -738,7 +741,7 @@ def _set_openai_agentic_response_attributes(span: Span, response) -> None:
"input_tokens": response.usage.input_tokens,
"output_tokens": response.usage.output_tokens,
"total_tokens": response.usage.total_tokens,
"cached_tokens": response.usage.input_tokens_details["cached_tokens"],
"cached_tokens": response.usage.input_tokens_details.cached_tokens,
},
)

Expand Down
3 changes: 2 additions & 1 deletion src/langtrace_python_sdk/langtrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ def init(
init_instrumentations(config.disable_instrumentations, all_instrumentations)
add_span_processor(provider, config, exporter)

sys.stdout = sys.__stdout__
if config.disable_logging:
sys.stdout = sys.__stdout__
init_sentry(config, host)


Expand Down
6 changes: 3 additions & 3 deletions src/langtrace_python_sdk/utils/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,19 @@ def set_usage_attributes(span, usage):
set_span_attribute(
span,
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
input_tokens,
int(input_tokens),
)

set_span_attribute(
span,
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
output_tokens,
int(output_tokens),
)

set_span_attribute(
span,
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens,
int(input_tokens) + int(output_tokens),
)

if "search_units" in usage:
Expand Down
2 changes: 1 addition & 1 deletion src/langtrace_python_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.8.10"
__version__ = "3.8.11"
Loading