MCPcopy Create free account
hub / github.com/google/adk-python / _build_compaction_attributes

Function _build_compaction_attributes

src/google/adk/telemetry/tracing.py:443–471  ·  view source on GitHub ↗

Builds span attributes for event compaction tracing.

(
    *,
    session_id: str,
    trigger: str,
    summarizer_type: str,
    event_count: int,
    token_threshold: int | None = None,
    event_retention_size: int | None = None,
    compaction_interval: int | None = None,
    overlap_size: int | None = None,
)

Source from the content-addressed store, hash-verified

441
442
443def _build_compaction_attributes(
444 *,
445 session_id: str,
446 trigger: str,
447 summarizer_type: str,
448 event_count: int,
449 token_threshold: int | None = None,
450 event_retention_size: int | None = None,
451 compaction_interval: int | None = None,
452 overlap_size: int | None = None,
453) -> dict[str, AttributeValue]:
454 """Builds span attributes for event compaction tracing."""
455 attributes: dict[str, AttributeValue] = {
456 GEN_AI_SYSTEM: _guess_gemini_system_name(),
457 GEN_AI_OPERATION_NAME: "compact_events",
458 GEN_AI_CONVERSATION_ID: session_id,
459 "gen_ai.compaction.trigger": trigger,
460 "gen_ai.compaction.summarizer_type": summarizer_type,
461 "gen_ai.compaction.event_count": event_count,
462 }
463 if token_threshold is not None:
464 attributes["gen_ai.compaction.token_threshold"] = token_threshold
465 if event_retention_size is not None:
466 attributes["gen_ai.compaction.event_retention_size"] = event_retention_size
467 if compaction_interval is not None:
468 attributes["gen_ai.compaction.compaction_interval"] = compaction_interval
469 if overlap_size is not None:
470 attributes["gen_ai.compaction.overlap_size"] = overlap_size
471 return attributes
472
473
474def _build_compaction_result_attributes(

Callers 1

Calls 1

Tested by

no test coverage detected