@@ -6,74 +6,10 @@ OpenTelemetry Google GenAI SDK Instrumentation
66.. |pypi | image :: https://badge.fury.io/py/opentelemetry-instrumentation-google-genai.svg
77 :target: https://pypi.org/project/opentelemetry-instrumentation-google-genai/
88
9- This library adds instrumentation to the `Google GenAI SDK library <https://pypi.org/project/google-genai/ >`_
10- to emit telemetry data following `Semantic Conventions for GenAI systems <https://opentelemetry.io/docs/specs/semconv/gen-ai/ >`_.
11- It adds trace spans for GenAI operations, events/logs for recording prompts/responses, and emits metrics that describe the
12- GenAI operations in aggregate.
9+ This library is a work in progress and is not ready to use. Follow along at
10+ https://github.com/open-telemetry/opentelemetry-python-contrib/issues/3260.
1311
1412
15- Installation
16- ------------
17-
18- If your application is already instrumented with OpenTelemetry, add this
19- package to your requirements.
20- ::
21-
22- pip install opentelemetry-instrumentation-google-genai
23-
24- If you don't have a Google GenAI SDK application, yet, try our `examples <examples >`_.
25-
26- Check out `zero-code example <examples/zero-code >`_ for a quick start.
27-
28- Usage
29- -----
30-
31- This section describes how to set up Google GenAI SDK instrumentation if you're setting OpenTelemetry up manually.
32- Check out the `manual example <examples/manual >`_ for more details.
33-
34- Instrumenting all clients
35- *************************
36-
37- When using the instrumentor, all clients will automatically trace GenAI `generate_content ` operations.
38- You can also optionally capture prompts and responses as log events.
39-
40- Make sure to configure OpenTelemetry tracing, logging, metrics, and events to capture all telemetry emitted by the instrumentation.
41-
42- .. code-block :: python
43-
44- from opentelemetry.instrumentation.google_genai import GoogleGenAiSdkInstrumentor
45- from google.genai import Client
46-
47- GoogleGenAiSdkInstrumentor().instrument()
48-
49-
50- client = Client()
51- response = client.models.generate_content(
52- model = " gemini-1.5-flash-002" ,
53- contents = " Write a short poem on OpenTelemetry." )
54-
55- Enabling message content
56- *************************
57-
58- Message content such as the contents of the prompt and response
59- are not captured by default. To capture message content as log events, set the environment variable
60- `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT ` to `true `.
61-
62- Uninstrument
63- ************
64-
65- To uninstrument clients, call the uninstrument method:
66-
67- .. code-block :: python
68-
69- from opentelemetry.instrumentation.google_genai import GoogleGenAiSdkInstrumentor
70-
71- GoogleGenAiSdkInstrumentor().instrument()
72- # ...
73-
74- # Uninstrument all clients
75- GoogleGenAiSdkInstrumentor().uninstrument()
76-
7713References
7814----------
7915* `Google Gen AI SDK Documentation <https://ai.google.dev/gemini-api/docs/sdks >`_
0 commit comments