Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding inference trace injection #36890

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
06cef91
adding inference trace injection
Aug 14, 2024
9dc2cf9
changing the interface based on feedback
Aug 16, 2024
58a032b
updates
Aug 16, 2024
ec1cd16
changing name of environment variable
Aug 20, 2024
3270076
changes based on review comments and some other changes
Sep 6, 2024
7cbbc0b
file name change
Sep 6, 2024
941a9ae
fixing exception handling
Sep 10, 2024
bcc6e74
relocating inference trace instrumentation
Sep 10, 2024
709923c
reverting change in azure core tracing
Sep 10, 2024
baac83f
Merge branch 'main' into mhietala/inference_genai_tracing
Sep 16, 2024
a64d870
fixes
Sep 16, 2024
198b9cd
changing span and model name for cases when model info not available
Sep 17, 2024
cd8bba2
some fixes
Sep 17, 2024
b28a3fe
adding sync trace tests
Sep 20, 2024
b549b38
fix and async trace test
Sep 23, 2024
469d32c
updating readme and setup
Sep 23, 2024
f1424a1
adding tracing sample
Sep 23, 2024
92da09a
changes based on review comments
Sep 25, 2024
d9652f5
changed to readme based on review comments
Sep 26, 2024
6da2a7d
removed distributed_trace and some other updates
Sep 26, 2024
521f7f0
fixing pre python v3.10 issue
Sep 26, 2024
814f87f
Merge branch 'Azure:main' into mhietala/inference_genai_tracing
M-Hietala Sep 26, 2024
8c80099
test fixes
Sep 26, 2024
514dea4
Fix some of the non-trace tests
dargilco Sep 26, 2024
83f85d6
fixing issues reported by tools
Sep 27, 2024
79ea9b3
Merge branch 'mhietala/inference_genai_tracing' of https://github.com…
Sep 27, 2024
e8dd67d
adding uninstrumentation to the beginning of tracing tests
Sep 27, 2024
0c286c3
updating readme and sample
Sep 27, 2024
1aaf87c
adding ignore related to tool issue
Sep 27, 2024
a1b1f13
Merge branch 'Azure:main' into mhietala/inference_genai_tracing
M-Hietala Sep 30, 2024
510a6ca
updating code snippet in readme
Sep 30, 2024
04da0e6
Merge branch 'mhietala/inference_genai_tracing' of https://github.com…
Sep 30, 2024
fa8e8b0
Add missing `@recorded_by_proxy` decorators to new tracing tests
dargilco Oct 1, 2024
e410c31
Push new recordings
dargilco Oct 1, 2024
18b3d92
fixing issues reported by tools
Oct 2, 2024
200ab61
Merge branch 'mhietala/inference_genai_tracing' of https://github.com…
Oct 2, 2024
4a56354
adding inference to shared requirements
Oct 2, 2024
3113e35
Merge branch 'Azure:main' into mhietala/inference_genai_tracing
M-Hietala Oct 2, 2024
58a754f
remove inference from setup
Oct 2, 2024
4ed67dc
adding comma to setup
Oct 3, 2024
5a0aa71
updating version requirement for core
Oct 3, 2024
1214978
changes based on review comments
Oct 7, 2024
1350293
Merge branch 'Azure:main' into mhietala/inference_genai_tracing
M-Hietala Oct 10, 2024
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
1 change: 1 addition & 0 deletions sdk/core/azure-core/azure/core/tracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
HttpSpanMixin,
M-Hietala marked this conversation as resolved.
Show resolved Hide resolved
Link,
)
from ._ai_inference_api_instrumentor import AiInferenceApiInstrumentor

__all__ = ["AbstractSpan", "SpanKind", "HttpSpanMixin", "Link"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import os
from .azure_telemetry_instrumentor import AzureTelemetryInstrumentor

class AiInferenceApiInstrumentor(AzureTelemetryInstrumentor):
def __init__(self):
super().__init__()

def str_to_bool(self, s):
if s is None:
return False
return str(s).lower() == 'true'

def instrument(self):
if self.is_instrumented():
raise RuntimeError("Already instrumented")

var_value = os.environ.get("AZUREAI_INFERENCE_API_ENABLE_CONTENT_TRACING")
M-Hietala marked this conversation as resolved.
Show resolved Hide resolved
enable_content_tracing = self.str_to_bool(var_value)
from ._inference_api_instrumentor_impl import _inject_inference_api
_inject_inference_api(enable_content_tracing)

def uninstrument(self):
if not self.is_instrumented():
raise RuntimeError("Not instrumented")

from ._inference_api_instrumentor_impl import _restore_inference_api
_restore_inference_api()

def is_instrumented(self):
from ._inference_api_instrumentor_impl import _is_instrumented
return _is_instrumented()
Loading
Loading