Skip to content

Commit 5dfc282

Browse files
committed
small fixes, get CI passing
1 parent 816212b commit 5dfc282

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/patch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def traced_method(
5252
args: Any,
5353
kwargs: Any,
5454
):
55-
# Use exact parameter signature to handle named vs positional args robustly
55+
# Use parameter signature from
56+
# https://github.com/googleapis/python-aiplatform/blob/v1.76.0/vertexai/generative_models/_generative_models.py#L595
57+
# to handle named vs positional args robustly
5658
def extract_params(
5759
contents: ContentsType,
5860
*,
@@ -62,6 +64,7 @@ def extract_params(
6264
tool_config: Optional[ToolConfig] = None,
6365
labels: Optional[dict[str, str]] = None,
6466
stream: bool = False,
67+
**_kwargs: Any,
6568
) -> GenerateContentParams:
6669
return GenerateContentParams(
6770
contents=contents,

instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class GenerationConfigDict(TypedDict, total=False):
7070

7171

7272
def get_genai_request_attributes(
73-
# TODO: use types
7473
instance: _GenerativeModel,
7574
params: GenerateContentParams,
7675
operation_name: GenAIAttributes.GenAiOperationNameValues = GenAIAttributes.GenAiOperationNameValues.CHAT,
@@ -130,10 +129,6 @@ def _get_model_name(instance: _GenerativeModel) -> str:
130129
return model_name
131130

132131

133-
# TODO: Everything below here should be replaced with
134-
# opentelemetry.instrumentation.genai_utils instead once it is released.
135-
# https://github.com/open-telemetry/opentelemetry-python-contrib/issues/3191
136-
137132
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = (
138133
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"
139134
)

instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/conftest.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,17 @@ def fixture_meter_provider(metric_reader):
8181

8282
@pytest.fixture(autouse=True)
8383
def vertexai_init(vcr: VCR) -> None:
84-
# Unfortunately I couldn't find a nice way to globally reset the global_config for each
85-
# test because different vertex submodules reference the global instance directly
86-
# https://github.com/googleapis/python-aiplatform/blob/v1.74.0/google/cloud/aiplatform/initializer.py#L687
87-
# so this config will leak if we don't call init() for each test.
88-
8984
# When not recording (in CI), don't do any auth. That prevents trying to read application
9085
# default credentials from the filesystem or metadata server and oauth token exchange. This
9186
# is not the interesting part of our instrumentation to test.
92-
vertex_init_kwargs = {"api_transport": "rest"}
87+
credentials = None
88+
project = None
9389
if vcr.record_mode == RecordMode.NONE:
94-
vertex_init_kwargs["credentials"] = AnonymousCredentials()
95-
vertex_init_kwargs["project"] = FAKE_PROJECT
96-
vertexai.init(**vertex_init_kwargs)
90+
credentials = AnonymousCredentials()
91+
project = FAKE_PROJECT
92+
vertexai.init(
93+
api_transport="rest", credentials=credentials, project=project
94+
)
9795

9896

9997
@pytest.fixture

0 commit comments

Comments
 (0)