Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Note: if you would like to point to an environment other than `app.galileo.ai`,
```python
import os

from splunk_ao import galileo_context
from splunk_ao import splunk_ao_context
from splunk_ao.openai import openai

# If you've set your GALILEO_PROJECT and GALILEO_LOG_STREAM env vars, you can skip this step
galileo_context.init(project="your-project-name", log_stream="your-log-stream-name")
splunk_ao_context.init(project="your-project-name", log_stream="your-log-stream-name")

# Initialize the Galileo wrapped OpenAI client
client = openai.OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
Expand All @@ -61,7 +61,7 @@ def call_openai():
call_openai()

# This will upload the trace to Galileo
galileo_context.flush()
splunk_ao_context.flush()
```

You can also use the `@log` decorator to log spans. Here's how to create a workflow span with two nested LLM spans:
Expand All @@ -75,7 +75,7 @@ def make_nested_call():
call_openai()

# If you've set your GALILEO_PROJECT and GALILEO_LOG_STREAM env vars, you can skip this step
galileo_context.init(project="your-project-name", log_stream="your-log-stream-name")
splunk_ao_context.init(project="your-project-name", log_stream="your-log-stream-name")

# This will create a trace with a workflow span and two nested LLM spans containing the OpenAI calls
make_nested_call()
Expand Down Expand Up @@ -107,27 +107,27 @@ def tool_call(input: str = "tool call input"):
tool_call(input="question")

# This will upload the trace to Galileo
galileo_context.flush()
splunk_ao_context.flush()
```

In some cases, you may want to wrap a block of code to start and flush a trace automatically. You can do this using the `galileo_context` context manager:
In some cases, you may want to wrap a block of code to start and flush a trace automatically. You can do this using the `splunk_ao_context` context manager:

```python
from splunk_ao import galileo_context
from splunk_ao import splunk_ao_context

# This will log a block of code to the project and log stream specified in the context manager
with galileo_context():
with splunk_ao_context():
content = make_nested_call()
print(content)
```

`galileo_context` also allows you specify a separate project and log stream for the trace:
`splunk_ao_context` also allows you specify a separate project and log stream for the trace:

```python
from splunk_ao import galileo_context
from splunk_ao import splunk_ao_context

# This will log to the project and log stream specified in the context manager
with galileo_context(project="gen-ai-project", log_stream="test2"):
with splunk_ao_context(project="gen-ai-project", log_stream="test2"):
content = make_nested_call()
print(content)
```
Expand Down Expand Up @@ -162,9 +162,9 @@ current Galileo log stream as the runtime target:

```python
import agent_control
from splunk_ao import galileo_context, get_agent_control_target
from splunk_ao import splunk_ao_context, get_agent_control_target

galileo_context.init(project="my-project", log_stream="prod")
splunk_ao_context.init(project="my-project", log_stream="prod")

target = get_agent_control_target()

Expand All @@ -178,7 +178,7 @@ agent_control.init(
```

The helper resolves an explicit log stream ID, `GALILEO_LOG_STREAM_ID`, or an
already-initialized `galileo_context` logger. It does not import the Agent
already-initialized `splunk_ao_context` logger. It does not import the Agent
Control SDK or resolve log stream names over the network. If you use a direct
Agent Control client instead of `agent_control.init(...)`, pass
`target.target_type` and `target.target_id` on each evaluation call.
Expand Down Expand Up @@ -210,10 +210,10 @@ In some cases (like long-running processes), it may be necessary to explicitly f
```python
import os

from splunk_ao import galileo_context
from splunk_ao import splunk_ao_context
from splunk_ao.openai import openai

galileo_context.init(project="your-project-name", log_stream="your-log-stream-name")
splunk_ao_context.init(project="your-project-name", log_stream="your-log-stream-name")

# Initialize the Galileo wrapped OpenAI client
client = openai.OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
Expand All @@ -230,7 +230,7 @@ def call_openai():
call_openai()

# This will upload the trace to Galileo
galileo_context.flush()
splunk_ao_context.flush()
```

Using the Langchain callback handler:
Expand Down Expand Up @@ -404,16 +404,16 @@ logger.conclude()
logger.flush()
```

All of this can also be done using the `galileo_context` context manager:
All of this can also be done using the `splunk_ao_context` context manager:

```python
from splunk_ao import galileo_context
from splunk_ao import splunk_ao_context

session_id = galileo_context.start_session(name="my-session-name")
session_id = splunk_ao_context.start_session(name="my-session-name")

# OR

galileo_context.set_session(session_id=session_id)
splunk_ao_context.set_session(session_id=session_id)

```

Expand Down
8 changes: 4 additions & 4 deletions galileo-a2a/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ pip install galileo-a2a
## Quick Start

```python
from splunk_ao.otel import GalileoSpanProcessor, add_galileo_span_processor
from galileo.otel import GalileoSpanProcessor, add_splunk_ao_span_processor
from galileo_a2a import A2AInstrumentor
from opentelemetry.sdk.trace import TracerProvider

provider = TracerProvider()
add_galileo_span_processor(provider, GalileoSpanProcessor())
add_splunk_ao_span_processor(provider, GalileoSpanProcessor())
A2AInstrumentor().instrument(tracer_provider=provider, agent_name="orchestrator")
```

Expand Down Expand Up @@ -119,7 +119,7 @@ from a2a.types import (
AgentCapabilities, AgentCard, AgentSkill, Message, Role,
TaskState, TaskStatus, TaskStatusUpdateEvent, TextPart,
)
from splunk_ao.otel import GalileoSpanProcessor, add_galileo_span_processor
from splunk_ao.otel import GalileoSpanProcessor, add_splunk_ao_span_processor
from galileo_a2a import A2AInstrumentor
from langchain.agents import create_agent
from langchain_core.tools import tool
Expand All @@ -132,7 +132,7 @@ from typing_extensions import TypedDict

# ---- Only 4 lines needed for full distributed tracing ----
provider = TracerProvider()
add_galileo_span_processor(provider, GalileoSpanProcessor())
add_splunk_ao_span_processor(provider, GalileoSpanProcessor())
A2AInstrumentor().instrument(tracer_provider=provider, agent_name="orchestrator")
LangchainInstrumentor().instrument(tracer_provider=provider)

Expand Down
4 changes: 2 additions & 2 deletions galileo-a2a/examples/two_agent_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from langgraph.graph import END, START, StateGraph
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from splunk_ao.otel import SplunkAOSpanProcessor, add_galileo_span_processor
from splunk_ao.otel import SplunkAOSpanProcessor, add_splunk_ao_span_processor
from starlette.applications import Starlette
from typing_extensions import TypedDict

Expand All @@ -61,7 +61,7 @@
# ---------------------------------------------------------------------------

provider = TracerProvider()
add_galileo_span_processor(provider, SplunkAOSpanProcessor())
add_splunk_ao_span_processor(provider, SplunkAOSpanProcessor())
A2AInstrumentor().instrument(tracer_provider=provider, agent_name="orchestrator")
LangchainInstrumentor().instrument(tracer_provider=provider)

Expand Down
4 changes: 2 additions & 2 deletions galileo-a2a/src/galileo_a2a/instrumentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class A2AInstrumentor(BaseInstrumentor): # type: ignore[misc]
Example::

from opentelemetry.sdk.trace import TracerProvider
from splunk_ao.otel import SplunkAOSpanProcessor, add_galileo_span_processor
from splunk_ao.otel import SplunkAOSpanProcessor, add_splunk_ao_span_processor
from galileo_a2a import A2AInstrumentor

provider = TracerProvider()
add_galileo_span_processor(provider, SplunkAOSpanProcessor())
add_splunk_ao_span_processor(provider, SplunkAOSpanProcessor())
A2AInstrumentor().instrument(tracer_provider=provider, agent_name="my-agent")

# To disable message content capture (e.g. for PII compliance):
Expand Down
6 changes: 3 additions & 3 deletions galileo-adk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ if __name__ == "__main__":

### Retriever Spans

By default, all `FunctionTool` calls are logged as tool spans. To log a retriever function as a **retriever span** (enabling RAG quality metrics in Galileo), decorate it with `@galileo_retriever`:
By default, all `FunctionTool` calls are logged as tool spans. To log a retriever function as a **retriever span** (enabling RAG quality metrics in Galileo), decorate it with `@splunk_ao_retriever`:

```python
from galileo_adk import galileo_retriever
from galileo_adk import splunk_ao_retriever
from google.adk.tools import FunctionTool

@galileo_retriever
@splunk_ao_retriever
def search_docs(query: str) -> str:
"""Search the knowledge base."""
results = my_vector_db.search(query)
Expand Down
4 changes: 2 additions & 2 deletions galileo-adk/src/galileo_adk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
__version__ = "2.0.1"

from galileo_adk.callback import GalileoADKCallback
from galileo_adk.decorator import galileo_retriever
from galileo_adk.decorator import splunk_ao_retriever
from galileo_adk.observer import get_custom_metadata
from galileo_adk.plugin import GalileoADKPlugin

__all__ = [
"GalileoADKPlugin",
"GalileoADKCallback",
"galileo_retriever",
"splunk_ao_retriever",
"get_custom_metadata",
]
4 changes: 2 additions & 2 deletions galileo-adk/src/galileo_adk/data_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def generate_tool_call_id(name: str, index: int = 0) -> str:
return f"call_{name}_{index}_{uuid.uuid4().hex[:8]}"


def convert_adk_content_to_galileo_messages(content: Any) -> list[Message]:
def convert_adk_content_to_splunk_ao_messages(content: Any) -> list[Message]:
"""Convert ADK Content to list of Galileo Messages, preserving part order.

Tracks call IDs for function calls and links them to their responses.
Expand Down Expand Up @@ -158,7 +158,7 @@ def _map_adk_role_to_galileo(adk_role: str) -> MessageRole:
return _ADK_ROLE_TO_GALILEO.get(adk_role.lower(), MessageRole.user)


def convert_adk_tools_to_galileo_format(tools: Any) -> list[dict[str, Any]]:
def convert_adk_tools_to_splunk_ao_format(tools: Any) -> list[dict[str, Any]]:
"""Convert ADK tools to OpenAI-compatible format."""
galileo_tools: list[dict[str, Any]] = []
for tool in tools:
Expand Down
10 changes: 5 additions & 5 deletions galileo-adk/src/galileo_adk/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
from typing import Any


def galileo_retriever(func: Callable[..., Any]) -> Callable[..., Any]:
def splunk_ao_retriever(func: Callable[..., Any]) -> Callable[..., Any]:
"""Mark a function as a retriever for Galileo observability.

When a function decorated with @galileo_retriever is wrapped in a
When a function decorated with @splunk_ao_retriever is wrapped in a
FunctionTool, Galileo will log it as a retriever span (node_type="retriever")
instead of a tool span, enabling RAG quality metrics.

Example
-------
>>> from galileo_adk import galileo_retriever
>>> @galileo_retriever
>>> from galileo_adk import splunk_ao_retriever
>>> @splunk_ao_retriever
... def my_search(query: str) -> str:
... return search_docs(query)
>>> tool = FunctionTool(my_search)
"""
func._galileo_is_retriever = True # type: ignore[attr-defined]
func._splunk_ao_is_retriever = True # type: ignore[attr-defined]
return func
18 changes: 9 additions & 9 deletions galileo-adk/src/galileo_adk/observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from typing import Any
from uuid import UUID

from splunk_ao import galileo_context
from splunk_ao import splunk_ao_context
from splunk_ao.handlers.base_handler import SplunkAOBaseHandler
from splunk_ao.schema.trace import TracesIngestRequest
from splunk_ao.utils.serialization import serialize_to_str

from galileo_adk.data_converters import (
convert_adk_content_to_galileo_messages,
convert_adk_tools_to_galileo_format,
convert_adk_content_to_splunk_ao_messages,
convert_adk_tools_to_splunk_ao_format,
extract_text_from_adk_content,
)
from galileo_adk.span_manager import SpanManager
Expand Down Expand Up @@ -156,7 +156,7 @@ def __init__(
)
else:
self._trace_builder = None
galileo_logger = galileo_context.get_logger_instance(project=project, log_stream=log_stream)
galileo_logger = splunk_ao_context.get_logger_instance(project=project, log_stream=log_stream)
self._handler = SplunkAOBaseHandler(
galileo_logger=galileo_logger,
start_new_trace=True,
Expand Down Expand Up @@ -393,12 +393,12 @@ def _is_retriever_tool(self, tool: Any) -> bool:

Detection uses two strategies:
1. isinstance check against google.adk.tools.retrieval.BaseRetrievalTool
2. Custom functions decorated with @galileo_retriever (sets _galileo_is_retriever on func)
2. Custom functions decorated with @splunk_ao_retriever (sets _splunk_ao_is_retriever on func)
"""
if _BaseRetrievalTool is not None and isinstance(tool, _BaseRetrievalTool):
return True
func = getattr(tool, "func", None)
return bool(func is not None and getattr(func, "_galileo_is_retriever", False))
return bool(func is not None and getattr(func, "_splunk_ao_is_retriever", False))

def on_tool_start(
self,
Expand Down Expand Up @@ -469,13 +469,13 @@ def _extract_llm_input(self, llm_request: Any) -> list[Any]:
return []
messages = []
for content in llm_request.contents:
messages.extend(convert_adk_content_to_galileo_messages(content))
messages.extend(convert_adk_content_to_splunk_ao_messages(content))
return messages

def _extract_llm_output(self, llm_response: Any) -> list[Any]:
"""Extract LLM output as list of Messages to preserve all parts including tool_calls."""
if llm_response and hasattr(llm_response, "content"):
return convert_adk_content_to_galileo_messages(llm_response.content)
return convert_adk_content_to_splunk_ao_messages(llm_response.content)
return []

def _extract_model_name(self, llm_request: Any) -> str | None:
Expand All @@ -495,7 +495,7 @@ def _extract_tools(self, llm_request: Any) -> list[dict[str, Any]] | None:
if hasattr(llm_request, "config") and llm_request.config:
tools = getattr(llm_request.config, "tools", None)
if tools:
return convert_adk_tools_to_galileo_format(tools)
return convert_adk_tools_to_splunk_ao_format(tools)
return None

def _extract_usage_metadata(self, llm_response: Any) -> dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion galileo-adk/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def mock_decode_jwt() -> Generator[MagicMock, None, None]:

@pytest.fixture
def mock_projects(mock_request: Callable) -> Generator[None, None, None]:
"""Mock the projects endpoint used by galileo_context.get_logger_instance().
"""Mock the projects endpoint used by splunk_ao_context.get_logger_instance().

ProjectDB schema requires:
- id, created_by, created_by_user (UserInfo), runs, created_at, updated_at
Expand Down
2 changes: 1 addition & 1 deletion galileo-adk/tests/test_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_initialization_with_ingestion_hook(self) -> None:
assert callback._handler is not None

def test_initialization_with_project_and_log_stream(self) -> None:
with patch("galileo_adk.observer.galileo_context") as mock_context:
with patch("galileo_adk.observer.splunk_ao_context") as mock_context:
mock_logger = MagicMock()
mock_context.get_logger_instance.return_value = mock_logger

Expand Down
Loading
Loading