Skip to content

Commit 5bcb73a

Browse files
committed
Fill out 'requirements.txt' and 'README.rst' for the manual instrumentation example.
1 parent 6ecd69c commit 5bcb73a

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
OpenTelemetry Google GenAI SDK Manual Instrumentation Example
2+
============================================
3+
4+
This is an example of how to instrument Google GenAI SDK calls when configuring
5+
OpenTelemetry SDK and Instrumentations manually.
6+
7+
When `main.py <main.py>`_ is run, it exports traces, logs, and metrics to an OTLP
8+
compatible endpoint. Traces include details such as the model used and the
9+
duration of the chat request. Logs capture the chat request and the generated
10+
response, providing a comprehensive view of the performance and behavior of
11+
your GenAI SDK requests. Metrics include aggregate statistics such as the aggregate
12+
token usage as well as the latency distribution of the GenAI operations.
13+
14+
Note: `.env <.env>`_ file configures additional environment variables:
15+
16+
- `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true` configures
17+
Google GenAI SDK instrumentation to capture prompt and completion contents on
18+
events.
19+
20+
Setup
21+
-----
22+
23+
An OTLP compatible endpoint should be listening for traces, logs, and metrics on
24+
http://localhost:4317. If not, update "OTEL_EXPORTER_OTLP_ENDPOINT" as well.
25+
26+
Next, set up a virtual environment like this:
27+
28+
::
29+
30+
python3 -m venv .venv
31+
source .venv/bin/activate
32+
pip install "python-dotenv[cli]"
33+
pip install -r requirements.txt
34+
35+
Run
36+
---
37+
38+
Run the example like this:
39+
40+
::
41+
42+
export PROMPT="Your prompt here"
43+
dotenv run -- python main.py
44+

instrumentation-genai/opentelemetry-instrumentation-google-genai/examples/manual/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
google-genai
16+
opentelemetry-api
17+
opentelemetry-sdk
18+
opentelemetry-instrumentation-requests
19+
opentelemetry-instrumentation-google-genai

0 commit comments

Comments
 (0)