opentelemetry-instrumentation-vertexai 0.23.0__py3-none-any.whl → 0.25.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of opentelemetry-instrumentation-vertexai might be problematic. Click here for more details.

@@ -15,7 +15,11 @@ from opentelemetry.trace.status import Status, StatusCode
15
15
  from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
16
16
  from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY, unwrap
17
17
 
18
- from opentelemetry.semconv.ai import SpanAttributes, LLMRequestTypeValues
18
+ from opentelemetry.semconv.ai import (
19
+ SUPPRESS_LANGUAGE_MODEL_INSTRUMENTATION_KEY,
20
+ SpanAttributes,
21
+ LLMRequestTypeValues,
22
+ )
19
23
  from opentelemetry.instrumentation.vertexai.version import __version__
20
24
 
21
25
  logger = logging.getLogger(__name__)
@@ -88,7 +92,7 @@ WRAPPED_METHODS = [
88
92
 
89
93
  def should_send_prompts():
90
94
  return (
91
- os.getenv("TRACELOOP_TRACE_CONTENT") or "true"
95
+ os.getenv("TRACELOOP_TRACE_CONTENT") or "true"
92
96
  ).lower() == "true" or context_api.get_value("override_enable_content_tracing")
93
97
 
94
98
 
@@ -124,15 +128,23 @@ def _set_input_attributes(span, args, kwargs, llm_model):
124
128
  )
125
129
 
126
130
  _set_span_attribute(span, SpanAttributes.LLM_REQUEST_MODEL, llm_model)
127
- _set_span_attribute(span, f"{SpanAttributes.LLM_PROMPTS}.0.user", kwargs.get("prompt"))
128
- _set_span_attribute(span, SpanAttributes.LLM_REQUEST_TEMPERATURE, kwargs.get("temperature"))
131
+ _set_span_attribute(
132
+ span, f"{SpanAttributes.LLM_PROMPTS}.0.user", kwargs.get("prompt")
133
+ )
134
+ _set_span_attribute(
135
+ span, SpanAttributes.LLM_REQUEST_TEMPERATURE, kwargs.get("temperature")
136
+ )
129
137
  _set_span_attribute(
130
138
  span, SpanAttributes.LLM_REQUEST_MAX_TOKENS, kwargs.get("max_output_tokens")
131
139
  )
132
140
  _set_span_attribute(span, SpanAttributes.LLM_REQUEST_TOP_P, kwargs.get("top_p"))
133
141
  _set_span_attribute(span, SpanAttributes.LLM_TOP_K, kwargs.get("top_k"))
134
- _set_span_attribute(span, SpanAttributes.LLM_PRESENCE_PENALTY, kwargs.get("presence_penalty"))
135
- _set_span_attribute(span, SpanAttributes.LLM_FREQUENCY_PENALTY, kwargs.get("frequency_penalty"))
142
+ _set_span_attribute(
143
+ span, SpanAttributes.LLM_PRESENCE_PENALTY, kwargs.get("presence_penalty")
144
+ )
145
+ _set_span_attribute(
146
+ span, SpanAttributes.LLM_FREQUENCY_PENALTY, kwargs.get("frequency_penalty")
147
+ )
136
148
 
137
149
  return
138
150
 
@@ -142,7 +154,9 @@ def _set_response_attributes(span, response, llm_model):
142
154
  _set_span_attribute(span, SpanAttributes.LLM_RESPONSE_MODEL, llm_model)
143
155
 
144
156
  if hasattr(response, "text"):
145
- if hasattr(response, "_raw_response") and hasattr(response._raw_response, "usage_metadata"):
157
+ if hasattr(response, "_raw_response") and hasattr(
158
+ response._raw_response, "usage_metadata"
159
+ ):
146
160
  _set_span_attribute(
147
161
  span,
148
162
  SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
@@ -164,14 +178,18 @@ def _set_response_attributes(span, response, llm_model):
164
178
  prefix = f"{SpanAttributes.LLM_COMPLETIONS}.{index}"
165
179
  _set_span_attribute(span, f"{prefix}.content", item.text)
166
180
  elif isinstance(response.text, str):
167
- _set_span_attribute(span, f"{SpanAttributes.LLM_COMPLETIONS}.0.content", response.text)
181
+ _set_span_attribute(
182
+ span, f"{SpanAttributes.LLM_COMPLETIONS}.0.content", response.text
183
+ )
168
184
  else:
169
185
  if isinstance(response, list):
170
186
  for index, item in enumerate(response):
171
187
  prefix = f"{SpanAttributes.LLM_COMPLETIONS}.{index}"
172
188
  _set_span_attribute(span, f"{prefix}.content", item)
173
189
  elif isinstance(response, str):
174
- _set_span_attribute(span, f"{SpanAttributes.LLM_COMPLETIONS}.0.content", response)
190
+ _set_span_attribute(
191
+ span, f"{SpanAttributes.LLM_COMPLETIONS}.0.content", response
192
+ )
175
193
 
176
194
  return
177
195
 
@@ -233,8 +251,10 @@ def _with_tracer_wrapper(func):
233
251
  @_with_tracer_wrapper
234
252
  async def _awrap(tracer, to_wrap, wrapped, instance, args, kwargs):
235
253
  """Instruments and calls every function defined in TO_WRAP."""
236
- if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
237
- return await wrapped(*args, **kwargs)
254
+ if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY) or context_api.get_value(
255
+ SUPPRESS_LANGUAGE_MODEL_INSTRUMENTATION_KEY
256
+ ):
257
+ return wrapped(*args, **kwargs)
238
258
 
239
259
  llm_model = "unknown"
240
260
  if hasattr(instance, "_model_id"):
@@ -271,7 +291,9 @@ async def _awrap(tracer, to_wrap, wrapped, instance, args, kwargs):
271
291
  @_with_tracer_wrapper
272
292
  def _wrap(tracer, to_wrap, wrapped, instance, args, kwargs):
273
293
  """Instruments and calls every function defined in TO_WRAP."""
274
- if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
294
+ if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY) or context_api.get_value(
295
+ SUPPRESS_LANGUAGE_MODEL_INSTRUMENTATION_KEY
296
+ ):
275
297
  return wrapped(*args, **kwargs)
276
298
 
277
299
  llm_model = "unknown"
@@ -1 +1 @@
1
- __version__ = "0.23.0"
1
+ __version__ = "0.25.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentelemetry-instrumentation-vertexai
3
- Version: 0.23.0
3
+ Version: 0.25.0
4
4
  Summary: OpenTelemetry Vertex AI instrumentation
5
5
  Home-page: https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-vertexai
6
6
  License: Apache-2.0
@@ -17,7 +17,7 @@ Provides-Extra: instruments
17
17
  Requires-Dist: opentelemetry-api (>=1.25.0,<2.0.0)
18
18
  Requires-Dist: opentelemetry-instrumentation (>=0.46b0,<0.47)
19
19
  Requires-Dist: opentelemetry-semantic-conventions (>=0.46b0,<0.47)
20
- Requires-Dist: opentelemetry-semantic-conventions-ai (==0.3.1)
20
+ Requires-Dist: opentelemetry-semantic-conventions-ai (==0.3.4)
21
21
  Project-URL: Repository, https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-vertexai
22
22
  Description-Content-Type: text/markdown
23
23
 
@@ -0,0 +1,8 @@
1
+ opentelemetry/instrumentation/vertexai/__init__.py,sha256=gx1eMOe9vFa2kEqN5H0B4GXWF_CVvR4z0p45wDtkvcw,11795
2
+ opentelemetry/instrumentation/vertexai/config.py,sha256=CtypZov_ytI9nSrfN9lWnjcufbAR9sfkXRA0OstDEUw,42
3
+ opentelemetry/instrumentation/vertexai/utils.py,sha256=xQHvL1ZiTkjV8LS5DibI1dzoA-gnOLeixPrfeVIqlYA,809
4
+ opentelemetry/instrumentation/vertexai/version.py,sha256=Mu4JbSLl5nr-J2figk5hmW2mrw4skf_oeIzxbnpcgwY,23
5
+ opentelemetry_instrumentation_vertexai-0.25.0.dist-info/METADATA,sha256=xXDZZRH9Y6PesI-eksC5kjKKUCC5vkwMNEGeucg_bbk,2253
6
+ opentelemetry_instrumentation_vertexai-0.25.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
+ opentelemetry_instrumentation_vertexai-0.25.0.dist-info/entry_points.txt,sha256=HbacwtKx_31YuUruZKYKWOiTGnRw3YaazUKF3TPbzDc,114
8
+ opentelemetry_instrumentation_vertexai-0.25.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- opentelemetry/instrumentation/vertexai/__init__.py,sha256=QLs6c9wYOuicl8n8ks9EIQmPu-pJEqle5a4wGXZVPu0,11437
2
- opentelemetry/instrumentation/vertexai/config.py,sha256=CtypZov_ytI9nSrfN9lWnjcufbAR9sfkXRA0OstDEUw,42
3
- opentelemetry/instrumentation/vertexai/utils.py,sha256=xQHvL1ZiTkjV8LS5DibI1dzoA-gnOLeixPrfeVIqlYA,809
4
- opentelemetry/instrumentation/vertexai/version.py,sha256=6bYcjtcATvc99ZNMjTUfPlrJP3-1WenVEc656roVn_I,23
5
- opentelemetry_instrumentation_vertexai-0.23.0.dist-info/METADATA,sha256=bhs05Ais2iyZqiiiC6s7A6KcKxYYGIcBULvFs7bSBiE,2253
6
- opentelemetry_instrumentation_vertexai-0.23.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
- opentelemetry_instrumentation_vertexai-0.23.0.dist-info/entry_points.txt,sha256=HbacwtKx_31YuUruZKYKWOiTGnRw3YaazUKF3TPbzDc,114
8
- opentelemetry_instrumentation_vertexai-0.23.0.dist-info/RECORD,,