Skip to content

Commit 6a366d0

Browse files
committed
Minor tweaks in the code generation. Add casette files.
1 parent 6fdb82e commit 6a366d0

10 files changed

+865
-43
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/common/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _create_client(self):
7070
location=self._location,
7171
credentials=self._credentials,
7272
)
73-
return google.genai.Client(api_key=self._api_key)
73+
return google.genai.Client(vertexai=False, api_key=self._api_key)
7474

7575
def tearDown(self):
7676
if self._instrumentation_context is not None:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
interactions:
2+
- request:
3+
body: |-
4+
{
5+
"contents": [
6+
{
7+
"parts": [
8+
{
9+
"text": "Create a poem about Open Telemetry."
10+
}
11+
],
12+
"role": "user"
13+
}
14+
]
15+
}
16+
headers:
17+
Accept:
18+
- '*/*'
19+
Accept-Encoding:
20+
- gzip, deflate
21+
Connection:
22+
- keep-alive
23+
Content-Length:
24+
- '92'
25+
Content-Type:
26+
- application/json
27+
user-agent:
28+
- google-genai-sdk/1.0.0 gl-python/3.12.8
29+
x-goog-api-client:
30+
- <REDACTED>
31+
x-goog-user-project:
32+
- <REDACTED>
33+
method: POST
34+
uri: https://test-location-aiplatform.googleapis.com/v1beta1/projects/test-project/locations/test-location/publishers/google/models/gemini-1.5-flash-002:generateContent
35+
response:
36+
body:
37+
string: |-
38+
{
39+
"candidates": [
40+
{
41+
"content": {
42+
"role": "model",
43+
"parts": [
44+
{
45+
"text": "No more dark, inscrutable ways,\nTo trace a request through hazy days.\nOpen Telemetry, a beacon bright,\nIlluminates the path, both day and night.\n\nFrom metrics gathered, a clear display,\nOf latency's dance, and errors' sway.\nTraces unwind, a silken thread,\nShowing the journey, from start to head.\n\nLogs interweave, a richer hue,\nContextual clues, for me and you.\nNo vendor lock-in, a freedom's call,\nTo choose your tools, to stand up tall.\n\nExporters aplenty, a varied choice,\nTo send your data, amplify your voice.\nJaeger, Zipkin, Prometheus' might,\nAll integrate, a glorious sight.\n\nWith spans and attributes, a detailed scene,\nOf how your system works, both sleek and keen.\nPerformance bottlenecks, now laid bare,\nOpen Telemetry, beyond compare.\n\nSo embrace the light, let darkness flee,\nWith Open Telemetry, set your systems free.\nObserve, and learn, and optimize with grace,\nA brighter future, in this digital space.\n"
46+
}
47+
]
48+
},
49+
"finishReason": "STOP",
50+
"avgLogprobs": -0.3303731600443522
51+
}
52+
],
53+
"usageMetadata": {
54+
"promptTokenCount": 8,
55+
"candidatesTokenCount": 240,
56+
"totalTokenCount": 248,
57+
"promptTokensDetails": [
58+
{
59+
"modality": "TEXT",
60+
"tokenCount": 8
61+
}
62+
],
63+
"candidatesTokensDetails": [
64+
{
65+
"modality": "TEXT",
66+
"tokenCount": 240
67+
}
68+
]
69+
},
70+
"modelVersion": "gemini-1.5-flash-002",
71+
"createTime": "2025-03-07T22:19:18.083091Z",
72+
"responseId": "5nDLZ5OJBdyY3NoPiZGx0Ag"
73+
}
74+
headers:
75+
Content-Encoding:
76+
- gzip
77+
Content-Type:
78+
- application/json; charset=UTF-8
79+
Transfer-Encoding:
80+
- chunked
81+
Vary:
82+
- Origin
83+
- X-Origin
84+
- Referer
85+
X-Content-Type-Options:
86+
- nosniff
87+
X-Frame-Options:
88+
- SAMEORIGIN
89+
X-XSS-Protection:
90+
- '0'
91+
status:
92+
code: 200
93+
message: OK
94+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
interactions:
2+
- request:
3+
body: |-
4+
{
5+
"contents": [
6+
{
7+
"parts": [
8+
{
9+
"text": "Create a poem about Open Telemetry."
10+
}
11+
],
12+
"role": "user"
13+
}
14+
]
15+
}
16+
headers:
17+
Accept:
18+
- '*/*'
19+
Accept-Encoding:
20+
- gzip, deflate
21+
Connection:
22+
- keep-alive
23+
Content-Length:
24+
- '92'
25+
Content-Type:
26+
- application/json
27+
user-agent:
28+
- google-genai-sdk/1.0.0 gl-python/3.12.8
29+
x-goog-api-client:
30+
- <REDACTED>
31+
x-goog-user-project:
32+
- <REDACTED>
33+
method: POST
34+
uri: https://test-location-aiplatform.googleapis.com/v1beta1/projects/test-project/locations/test-location/publishers/google/models/gemini-1.5-flash-002:generateContent
35+
response:
36+
body:
37+
string: |-
38+
{
39+
"candidates": [
40+
{
41+
"content": {
42+
"role": "model",
43+
"parts": [
44+
{
45+
"text": "No more dark logs, a cryptic, hidden trace,\nOf failing systems, lost in time and space.\nOpenTelemetry, a beacon shining bright,\nIlluminating paths, both dark and light.\n\nFrom microservices, a sprawling, tangled mesh,\nTo monolithic beasts, put to the test,\nIt gathers traces, spans, and metrics too,\nA holistic view, for me and you.\n\nWith signals clear, from every single node,\nPerformance bottlenecks, instantly bestowed.\nDistributed tracing, paints a vivid scene,\nWhere latency lurks, and slowdowns intervene.\n\nExporters rise, to send the data forth,\nTo dashboards grand, of proven, measured worth.\nPrometheus, Grafana, Jaeger, fluent streams,\nVisualizing insights, fulfilling data dreams.\n\nFrom Jaeger's diagrams, a branching, flowing art,\nTo Grafana's charts, that play a vital part,\nThe mysteries unravel, hidden deep inside,\nWhere errors slumber, and slow responses hide.\n\nSo hail OpenTelemetry, a gift to all who code,\nA brighter future, on a well-lit road.\nNo more guesswork, no more fruitless chase,\nJust clear observability, in time and space.\n"
46+
}
47+
]
48+
},
49+
"finishReason": "STOP",
50+
"avgLogprobs": -0.45532724261283875
51+
}
52+
],
53+
"usageMetadata": {
54+
"promptTokenCount": 8,
55+
"candidatesTokenCount": 256,
56+
"totalTokenCount": 264,
57+
"promptTokensDetails": [
58+
{
59+
"modality": "TEXT",
60+
"tokenCount": 8
61+
}
62+
],
63+
"candidatesTokensDetails": [
64+
{
65+
"modality": "TEXT",
66+
"tokenCount": 256
67+
}
68+
]
69+
},
70+
"modelVersion": "gemini-1.5-flash-002",
71+
"createTime": "2025-03-07T22:19:15.268428Z",
72+
"responseId": "43DLZ4yxEM6F3NoPzaTkiQU"
73+
}
74+
headers:
75+
Content-Encoding:
76+
- gzip
77+
Content-Type:
78+
- application/json; charset=UTF-8
79+
Transfer-Encoding:
80+
- chunked
81+
Vary:
82+
- Origin
83+
- X-Origin
84+
- Referer
85+
X-Content-Type-Options:
86+
- nosniff
87+
X-Frame-Options:
88+
- SAMEORIGIN
89+
X-XSS-Protection:
90+
- '0'
91+
status:
92+
code: 200
93+
message: OK
94+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
interactions:
2+
- request:
3+
body: |-
4+
{
5+
"contents": [
6+
{
7+
"parts": [
8+
{
9+
"text": "Create a poem about Open Telemetry."
10+
}
11+
],
12+
"role": "user"
13+
}
14+
]
15+
}
16+
headers:
17+
Accept:
18+
- '*/*'
19+
Accept-Encoding:
20+
- gzip, deflate
21+
Connection:
22+
- keep-alive
23+
Content-Length:
24+
- '92'
25+
Content-Type:
26+
- application/json
27+
user-agent:
28+
- google-genai-sdk/1.0.0 gl-python/3.12.8
29+
x-goog-api-client:
30+
- <REDACTED>
31+
x-goog-user-project:
32+
- <REDACTED>
33+
method: POST
34+
uri: https://test-location-aiplatform.googleapis.com/v1beta1/projects/test-project/locations/test-location/publishers/google/models/gemini-1.5-flash-002:generateContent
35+
response:
36+
body:
37+
string: |-
38+
{
39+
"candidates": [
40+
{
41+
"content": {
42+
"role": "model",
43+
"parts": [
44+
{
45+
"text": "No more dark, mysterious traces,\nNo more guessing, in empty spaces.\nOpenTelemetry's light now shines,\nIlluminating all our designs.\n\nFrom microservices, small and fleet,\nTo monolithic beasts, hard to beat,\nIt weaves a net, both fine and strong,\nWhere metrics flow, where logs belong.\n\nTraces dance, a vibrant hue,\nShowing journeys, old and new.\nSpans unfold, a story told,\nOf requests handled, brave and bold.\n\nMetrics hum, a steady beat,\nLatency, errors, can't be beat.\nDistribution charts, a clear display,\nGuiding us along the way.\n\nLogs provide a detailed view,\nOf what happened, me and you.\nContext rich, with helpful clues,\nDebugging woes, it quickly subdues.\n\nWith exporters wise, a thoughtful choice,\nTo Prometheus, Jaeger, or Zipkin's voice,\nOur data flows, a precious stream,\nReal-time insights, a waking dream.\n\nSo hail to OpenTelemetry's might,\nBringing clarity to our darkest night.\nObservability's champion, bold and true,\nA brighter future, for me and you.\n"
46+
}
47+
]
48+
},
49+
"finishReason": "STOP",
50+
"avgLogprobs": -0.4071464086238575
51+
}
52+
],
53+
"usageMetadata": {
54+
"promptTokenCount": 8,
55+
"candidatesTokenCount": 253,
56+
"totalTokenCount": 261,
57+
"promptTokensDetails": [
58+
{
59+
"modality": "TEXT",
60+
"tokenCount": 8
61+
}
62+
],
63+
"candidatesTokensDetails": [
64+
{
65+
"modality": "TEXT",
66+
"tokenCount": 253
67+
}
68+
]
69+
},
70+
"modelVersion": "gemini-1.5-flash-002",
71+
"createTime": "2025-03-07T22:19:12.443989Z",
72+
"responseId": "4HDLZ9WMG6SK698Pr5uZ2Qw"
73+
}
74+
headers:
75+
Content-Encoding:
76+
- gzip
77+
Content-Type:
78+
- application/json; charset=UTF-8
79+
Transfer-Encoding:
80+
- chunked
81+
Vary:
82+
- Origin
83+
- X-Origin
84+
- Referer
85+
X-Content-Type-Options:
86+
- nosniff
87+
X-Frame-Options:
88+
- SAMEORIGIN
89+
X-XSS-Protection:
90+
- '0'
91+
status:
92+
code: 200
93+
message: OK
94+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
interactions:
2+
- request:
3+
body: |-
4+
{
5+
"contents": [
6+
{
7+
"parts": [
8+
{
9+
"text": "Create a poem about Open Telemetry."
10+
}
11+
],
12+
"role": "user"
13+
}
14+
]
15+
}
16+
headers:
17+
Accept:
18+
- '*/*'
19+
Accept-Encoding:
20+
- gzip, deflate
21+
Connection:
22+
- keep-alive
23+
Content-Length:
24+
- '92'
25+
Content-Type:
26+
- application/json
27+
user-agent:
28+
- google-genai-sdk/1.0.0 gl-python/3.12.8
29+
x-goog-api-client:
30+
- <REDACTED>
31+
x-goog-user-project:
32+
- <REDACTED>
33+
method: POST
34+
uri: https://test-location-aiplatform.googleapis.com/v1beta1/projects/test-project/locations/test-location/publishers/google/models/gemini-1.5-flash-002:generateContent
35+
response:
36+
body:
37+
string: |-
38+
{
39+
"candidates": [
40+
{
41+
"content": {
42+
"role": "model",
43+
"parts": [
44+
{
45+
"text": "No more dark, mysterious traces,\nOf failing systems, hidden spaces.\nOpen Telemetry's light shines bright,\nGuiding us through the darkest night.\n\nFrom metrics gathered, finely spun,\nTo logs that tell of tasks undone,\nAnd traces linking every call,\nIt answers questions, standing tall.\n\nDistributed systems, complex and vast,\nTheir hidden flaws, no longer cast\nIn shadows deep, beyond our view,\nOpen Telemetry sees them through.\n\nWith spans and attributes, it weaves a tale,\nOf requests flowing, never frail.\nIt pinpoints bottlenecks, slow and grim,\nAnd helps us optimize, system trim.\n\nAcross languages, a common ground,\nWhere data's shared, and insights found.\nExporters whisper, collectors hum,\nA symphony of data, overcome.\n\nSo raise a glass, to this open source,\nA shining beacon, a powerful force.\nOpen Telemetry, a guiding star,\nRevealing secrets, near and far.\n"
46+
}
47+
]
48+
},
49+
"finishReason": "STOP",
50+
"avgLogprobs": -0.3586180628193498
51+
}
52+
],
53+
"usageMetadata": {
54+
"promptTokenCount": 8,
55+
"candidatesTokenCount": 211,
56+
"totalTokenCount": 219,
57+
"promptTokensDetails": [
58+
{
59+
"modality": "TEXT",
60+
"tokenCount": 8
61+
}
62+
],
63+
"candidatesTokensDetails": [
64+
{
65+
"modality": "TEXT",
66+
"tokenCount": 211
67+
}
68+
]
69+
},
70+
"modelVersion": "gemini-1.5-flash-002",
71+
"createTime": "2025-03-07T22:19:09.936326Z",
72+
"responseId": "3XDLZ4aTOZSpnvgPn-e0qQk"
73+
}
74+
headers:
75+
Content-Encoding:
76+
- gzip
77+
Content-Type:
78+
- application/json; charset=UTF-8
79+
Transfer-Encoding:
80+
- chunked
81+
Vary:
82+
- Origin
83+
- X-Origin
84+
- Referer
85+
X-Content-Type-Options:
86+
- nosniff
87+
X-Frame-Options:
88+
- SAMEORIGIN
89+
X-XSS-Protection:
90+
- '0'
91+
status:
92+
code: 200
93+
message: OK
94+
version: 1

0 commit comments

Comments
 (0)