Skip to content

Commit 9ef75f7

Browse files
committed
fix: lint
1 parent 3f20dbc commit 9ef75f7

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/generate_content.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ def _add_request_options_to_span(
221221
span.set_attribute(key, value)
222222

223223

224-
def _get_gen_ai_request_attributes(config: Union[GenerateContentConfigOrDict, None]) -> dict[str, Any]:
224+
def _get_gen_ai_request_attributes(
225+
config: Union[GenerateContentConfigOrDict, None],
226+
) -> dict[str, Any]:
225227
if not config:
226228
return {}
227229
attributes: dict[str, Any] = {}
228230
config = _coerce_config_to_object(config)
229231
if config.seed:
230-
attributes[gen_ai_attributes.GEN_AI_REQUEST_SEED] = (
231-
config.seed
232-
)
232+
attributes[gen_ai_attributes.GEN_AI_REQUEST_SEED] = config.seed
233233
if config.candidate_count:
234234
attributes[gen_ai_attributes.GEN_AI_REQUEST_CHOICE_COUNT] = (
235235
config.candidate_count
@@ -400,7 +400,9 @@ def process_completion(
400400
config: Optional[GenerateContentConfigOrDict] = None,
401401
):
402402
self._update_response(response)
403-
self._maybe_log_completion_details(request, response.candidates or [], config)
403+
self._maybe_log_completion_details(
404+
request, response.candidates or [], config
405+
)
404406

405407
def process_error(self, e: Exception):
406408
self._error_type = str(e.__class__.__name__)
@@ -499,9 +501,7 @@ def _maybe_log_completion_details(
499501
input_messages = to_input_messages(
500502
contents=transformers.t_contents(request)
501503
)
502-
output_messages = to_output_messages(
503-
candidates=candidates
504-
)
504+
output_messages = to_output_messages(candidates=candidates)
505505

506506
span = trace.get_current_span()
507507
event = Event(
@@ -515,12 +515,10 @@ def _maybe_log_completion_details(
515515
span=span,
516516
log_record=event,
517517
)
518-
completion_details_attributes = (
519-
_create_completion_details_attributes(
520-
input_messages,
521-
output_messages,
522-
system_instructions,
523-
)
518+
completion_details_attributes = _create_completion_details_attributes(
519+
input_messages,
520+
output_messages,
521+
system_instructions,
524522
)
525523
if self._content_recording_enabled in [
526524
ContentCapturingMode.EVENT_ONLY,
@@ -536,7 +534,12 @@ def _maybe_log_completion_details(
536534
ContentCapturingMode.SPAN_ONLY,
537535
ContentCapturingMode.SPAN_AND_EVENT,
538536
]:
539-
span.set_attributes({k: gen_ai_json_dumps(v) for k, v in completion_details_attributes.items()})
537+
span.set_attributes(
538+
{
539+
k: gen_ai_json_dumps(v)
540+
for k, v in completion_details_attributes.items()
541+
}
542+
)
540543
span.set_attributes(attributes)
541544

542545
def _maybe_log_system_instruction(
@@ -844,7 +847,9 @@ def instrumented_generate_content_stream(
844847
helper.process_error(error)
845848
raise
846849
finally:
847-
helper._maybe_log_completion_details(contents, candidates, config)
850+
helper._maybe_log_completion_details(
851+
contents, candidates, config
852+
)
848853
helper.finalize_processing()
849854

850855
return instrumented_generate_content_stream
@@ -982,7 +987,9 @@ async def _response_async_generator_wrapper():
982987
helper.process_error(error)
983988
raise
984989
finally:
985-
helper._maybe_log_completion_details(contents, candidates, config)
990+
helper._maybe_log_completion_details(
991+
contents, candidates, config
992+
)
986993
helper.finalize_processing()
987994

988995
return _response_async_generator_wrapper()

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from __future__ import annotations
1616

1717
import logging
18-
from enum import Enum
1918
from dataclasses import dataclass
19+
from enum import Enum
2020
from typing import Literal
2121

2222
from google.genai import types as genai_types

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/otel_wrapper.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import google.genai
2020

21-
from opentelemetry._logs import LogRecord, Logger, LoggerProvider
21+
from opentelemetry._logs import Logger, LoggerProvider, LogRecord
2222
from opentelemetry.metrics import Meter, MeterProvider
2323
from opentelemetry.semconv._incubating.metrics import gen_ai_metrics
2424
from opentelemetry.semconv.schemas import Schemas
@@ -40,9 +40,7 @@
4040

4141

4242
class OTelWrapper:
43-
def __init__(
44-
self, tracer: Tracer, logger: Logger, meter: Meter
45-
):
43+
def __init__(self, tracer: Tracer, logger: Logger, meter: Meter):
4644
self._tracer = tracer
4745
self._logger = logger
4846
self._meter = meter

0 commit comments

Comments
 (0)