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
4 changes: 2 additions & 2 deletions splunk-ao-adk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if __name__ == "__main__":
| Parameter | Environment Variable | Description |
|-----------|---------------------|-------------|
| `project` | `SPLUNK_AO_PROJECT` | Project name (required unless `ingestion_hook` provided) |
| `log_stream` | `SPLUNK_AO_LOG_STREAM` | Log stream name (required unless `ingestion_hook` provided) |
| `log_stream` | `SPLUNK_AO_AGENT_STREAM` | Log stream name (required unless `ingestion_hook` provided) |
| `ingestion_hook` | - | Custom callback for trace data (bypasses Splunk AO backend) |

## Features
Expand Down Expand Up @@ -194,7 +194,7 @@ from google.genai import types

logger = SplunkAOLogger(
project=os.getenv("SPLUNK_AO_PROJECT", "my-project"),
log_stream=os.getenv("SPLUNK_AO_LOG_STREAM", "dev"),
log_stream=os.getenv("SPLUNK_AO_AGENT_STREAM", "dev"),
)

def my_ingestion_hook(request):
Expand Down
5 changes: 4 additions & 1 deletion splunk-ao-adk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ env = [
"SPLUNK_AO_CONSOLE_URL=http://fake.test:8088",
"SPLUNK_AO_API_KEY=api-1234567890",
"SPLUNK_AO_PROJECT=test-project",
"SPLUNK_AO_LOG_STREAM=test-log-stream",
"SPLUNK_AO_AGENT_STREAM=test-log-stream",
]
addopts = [
"-v",
Expand Down Expand Up @@ -138,6 +138,9 @@ dev = [
"coverage>=7.9.2",
"splunk-ao>=0.1.0,<1.0.0",
"galileo-core[testing]>=3.82.0",
# 1.13.0 is the only stable release and is yanked; >=1.12.0a0 opts this package into
# pre-releases so uv picks the latest non-yanked version automatically.
"opentelemetry-resourcedetector-gcp>=1.12.0a0",
]

[build-system]
Expand Down
6 changes: 3 additions & 3 deletions splunk-ao-adk/src/splunk_ao_adk/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SplunkAOADKCallback:
Splunk AO project name. Can also be set via SPLUNK_AO_PROJECT env var.
Required unless `ingestion_hook` is provided.
log_stream : str, optional
Log stream name within the project. Can also be set via SPLUNK_AO_LOG_STREAM env var.
Log stream name within the project. Can also be set via SPLUNK_AO_AGENT_STREAM env var.
Required unless `ingestion_hook` is provided.
ingestion_hook : Callable[[TracesIngestRequest], None], optional
Custom callback to receive trace data instead of sending to Splunk AO.
Expand All @@ -77,11 +77,11 @@ def __init__(
ingestion_hook: Callable[[TracesIngestRequest], None] | None = None,
) -> None:
effective_project = project or os.environ.get("SPLUNK_AO_PROJECT")
effective_log_stream = log_stream or os.environ.get("SPLUNK_AO_LOG_STREAM")
effective_log_stream = log_stream or os.environ.get("SPLUNK_AO_AGENT_STREAM")
if not ingestion_hook and (not effective_project or not effective_log_stream):
raise ValueError(
"Both 'project' and 'log_stream' must be provided via parameters or "
"SPLUNK_AO_PROJECT/SPLUNK_AO_LOG_STREAM environment variables"
"SPLUNK_AO_PROJECT/SPLUNK_AO_AGENT_STREAM environment variables"
)
Comment thread
fercor-cisco marked this conversation as resolved.

self._observer = SplunkAOObserver(
Expand Down
6 changes: 3 additions & 3 deletions splunk-ao-adk/src/splunk_ao_adk/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class SplunkAOADKPlugin(BasePlugin):
Splunk AO project name. Can also be set via SPLUNK_AO_PROJECT env var.
Required unless `ingestion_hook` is provided.
log_stream : str, optional
Log stream name within the project. Can also be set via SPLUNK_AO_LOG_STREAM env var.
Log stream name within the project. Can also be set via SPLUNK_AO_AGENT_STREAM env var.
Required unless `ingestion_hook` is provided.
ingestion_hook : Callable[[TracesIngestRequest], None], optional
Custom callback to receive trace data instead of sending to Splunk AO.
Expand All @@ -139,11 +139,11 @@ def __init__(
ingestion_hook: Callable[[TracesIngestRequest], None] | None = None,
) -> None:
effective_project = project or os.environ.get("SPLUNK_AO_PROJECT")
effective_log_stream = log_stream or os.environ.get("SPLUNK_AO_LOG_STREAM")
effective_log_stream = log_stream or os.environ.get("SPLUNK_AO_AGENT_STREAM")
if not ingestion_hook and (not effective_project or not effective_log_stream):
raise ValueError(
"Both 'project' and 'log_stream' must be provided via parameters or "
"SPLUNK_AO_PROJECT/SPLUNK_AO_LOG_STREAM environment variables"
"SPLUNK_AO_PROJECT/SPLUNK_AO_AGENT_STREAM environment variables"
)

super().__init__(name="splunk_ao")
Expand Down
8 changes: 4 additions & 4 deletions splunk-ao-adk/tests/test_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ class TestSplunkAOADKCallbackInit:

def test_init_requires_project_and_log_stream(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""Callback raises error when neither project/log_stream nor hook provided."""
# Given: SPLUNK_AO_PROJECT and SPLUNK_AO_LOG_STREAM env vars are not set
# Given: SPLUNK_AO_PROJECT and SPLUNK_AO_AGENT_STREAM env vars are not set
monkeypatch.delenv("SPLUNK_AO_PROJECT", raising=False)
monkeypatch.delenv("SPLUNK_AO_LOG_STREAM", raising=False)
monkeypatch.delenv("SPLUNK_AO_AGENT_STREAM", raising=False)

# When/Then: creating callback without project or log_stream raises an error
with pytest.raises(ValueError, match="Both 'project' and 'log_stream' must be provided"):
SplunkAOADKCallback()

def test_init_requires_log_stream(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""Callback raises error when project is provided but log_stream is not."""
# Given: SPLUNK_AO_LOG_STREAM env var is not set
monkeypatch.delenv("SPLUNK_AO_LOG_STREAM", raising=False)
# Given: SPLUNK_AO_AGENT_STREAM env var is not set
monkeypatch.delenv("SPLUNK_AO_AGENT_STREAM", raising=False)

# When/Then: creating callback with project but no log_stream raises an error
with pytest.raises(ValueError, match="Both 'project' and 'log_stream' must be provided"):
Expand Down
10 changes: 5 additions & 5 deletions splunk-ao-adk/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_init_with_ingestion_hook_without_env_vars(self, monkeypatch: pytest.Mon
"""Plugin with ingestion_hook works without any Galileo environment variables."""
# Given: no Galileo environment variables are set
monkeypatch.delenv("SPLUNK_AO_PROJECT", raising=False)
monkeypatch.delenv("SPLUNK_AO_LOG_STREAM", raising=False)
monkeypatch.delenv("SPLUNK_AO_AGENT_STREAM", raising=False)
monkeypatch.delenv("SPLUNK_AO_API_KEY", raising=False)
monkeypatch.delenv("SPLUNK_AO_CONSOLE_URL", raising=False)

Expand All @@ -47,18 +47,18 @@ def test_init_with_ingestion_hook_without_env_vars(self, monkeypatch: pytest.Mon

def test_init_requires_project_and_log_stream(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""Plugin raises error when neither project/log_stream nor hook provided."""
# Given: SPLUNK_AO_PROJECT and SPLUNK_AO_LOG_STREAM env vars are not set
# Given: SPLUNK_AO_PROJECT and SPLUNK_AO_AGENT_STREAM env vars are not set
monkeypatch.delenv("SPLUNK_AO_PROJECT", raising=False)
monkeypatch.delenv("SPLUNK_AO_LOG_STREAM", raising=False)
monkeypatch.delenv("SPLUNK_AO_AGENT_STREAM", raising=False)

# When/Then: creating plugin without project or log_stream raises an error
with pytest.raises(ValueError, match="Both 'project' and 'log_stream' must be provided"):
SplunkAOADKPlugin()

def test_init_requires_log_stream(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""Plugin raises error when project is provided but log_stream is not."""
# Given: SPLUNK_AO_LOG_STREAM env var is not set
monkeypatch.delenv("SPLUNK_AO_LOG_STREAM", raising=False)
# Given: SPLUNK_AO_AGENT_STREAM env var is not set
monkeypatch.delenv("SPLUNK_AO_AGENT_STREAM", raising=False)

# When/Then: creating plugin with project but no log_stream raises an error
with pytest.raises(ValueError, match="Both 'project' and 'log_stream' must be provided"):
Expand Down
Loading