Skip to content

Commit 6d0a38a

Browse files
author
Liudmila Molkova
committed
Update semantic conventions to the latest version, write logs based events instead of span events
1 parent 8582da5 commit 6d0a38a

15 files changed

+2299
-291
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ tox -e py312-test-instrumentation-aiopg
227227
Some of the tox targets install packages from the [OpenTelemetry Python Core Repository](https://github.com/open-telemetry/opentelemetry-python) via pip. The version of the packages installed defaults to the main branch in that repository when tox is run locally. It is possible to install packages tagged with a specific git commit hash by setting an environment variable before running tox as per the following example:
228228

229229
```sh
230-
CORE_REPO_SHA=c49ad57bfe35cfc69bfa863d74058ca9bec55fc3 tox
230+
CORE_REPO_SHA=966750aad4ba2a9c123b4f14785958ffe50b54ae tox
231231
```
232232

233233
The continuous integration overrides that environment variable with as per the configuration [here](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/.github/workflows/test_0.yml#L14).

instrumentation/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
.. code:: python
2525
2626
from openai import OpenAI
27-
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
27+
from opentelemetry.instrumentation.openai_v2 import OpenAIInstrumentor
2828
2929
OpenAIInstrumentor().instrument()
3030
@@ -44,6 +44,7 @@
4444

4545
from wrapt import wrap_function_wrapper
4646

47+
from opentelemetry._events import get_event_logger
4748
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4849
from opentelemetry.instrumentation.openai_v2.package import _instruments
4950
from opentelemetry.instrumentation.utils import unwrap
@@ -64,12 +65,19 @@ def _instrument(self, **kwargs):
6465
__name__,
6566
"",
6667
tracer_provider,
67-
schema_url=Schemas.V1_27_0.value,
68+
schema_url=Schemas.V1_28_0.value,
69+
)
70+
event_provider = kwargs.get("event_provider")
71+
event_logger = get_event_logger(
72+
__name__,
73+
"",
74+
schema_url=Schemas.V1_28_0.value,
75+
event_logger_provider=event_provider,
6876
)
6977
wrap_function_wrapper(
7078
module="openai.resources.chat.completions",
7179
name="Completions.create",
72-
wrapper=chat_completions_create(tracer),
80+
wrapper=chat_completions_create(tracer, event_logger),
7381
)
7482

7583
def _uninstrument(self, **kwargs):

0 commit comments

Comments
 (0)