Skip to content
Draft
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
3 changes: 0 additions & 3 deletions examples/chatbot/basic-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ logger.add_llm_span(

# Conclude the trace
logger.conclude(output=response.choices[0].message.content.strip())

# Flush the traces to Splunk AO
logger.flush()
```

This approach gives you more control over what gets logged and when, allowing you to:
Expand Down
3 changes: 0 additions & 3 deletions examples/chatbot/basic-examples/hallucination.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,3 @@ def run_hallucination_demo():

# Run the main demonstration
results = run_hallucination_demo()

# Flush the traces to Splunk AO
logger.flush()
3 changes: 0 additions & 3 deletions examples/chatbot/basic-examples/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,5 @@
# Conclude the trace
logger.conclude(output=response_content)

# Flush the traces to Splunk AO
logger.flush()

# Print the response
print(response_content)
2 changes: 1 addition & 1 deletion examples/chatbot/sample-project-chatbot/anthropic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
as a workflow span
- The call to the LLM is logged manually as an LLM span.
- After the response is received, the trace is concluded with the response
and flushed to ensure it is sent to Splunk AO.
and the export queue is drained.

To run this, you will need to have the following environment variables set:
- `SPLUNK_AO_API_KEY`: Your Splunk AO API key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
as a workflow span
- The call to the LLM is logged manually as an LLM span.
- After the response is received, the trace is concluded with the response
and flushed to ensure it is sent to Splunk AO.
and the export queue is drained.

To run this, you will need to have the following environment variables set:
- `SPLUNK_AO_API_KEY`: Your Splunk AO API key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- The call to the LLM is logged as an LLM span using the Splunk AO OpenAI integration
which logs the span automatically.
- After the response is received, the trace is concluded with the response
and flushed to ensure it is sent to Splunk AO.
and the export queue is drained.

To run this, you will need to have the following environment variables set:
- `SPLUNK_AO_API_KEY`: Your Splunk AO API key.
Expand Down
3 changes: 0 additions & 3 deletions examples/logging-samples/splunk-ao-logger/basic-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
# Conclude the trace with the final output
logger.conclude(output="Hello, this is a test", duration_ns=1000)

# Flush the trace to Splunk AO
logger.flush()


# Show link to Splunk AO log stream
config = SplunkAOConfig.get()
Expand Down
3 changes: 0 additions & 3 deletions examples/logging-samples/splunk-ao-logger/metadata-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
# Conclude the trace with the final output
logger.conclude(output_answer)

# Flush the trace to Splunk AO
logger.flush()

# Show link to Splunk AO log stream
config = SplunkAOConfig.get()
project_url = f"{config.console_url}project/{logger.project_id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
redacted_input = user_input.replace(sensitive_info, "***")
trace = logger.start_trace(input=user_input, redacted_input=redacted_input)

logger.flush() # send the trace to Splunk AO
logger.flush() # drain the OTLP export queue

# Example of how to create "redacted_input", matching email as sensitive info
# ---------------------------------------------------------------------------
Expand All @@ -37,7 +37,7 @@
else:
trace = logger.start_trace(input=user_input)

logger.flush() # send the trace to Splunk AO
logger.flush() # drain the OTLP export queue

# It's also possible to use a service such as https://www.private-ai.com/ to create the redacted_input

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@

logger.conclude(output="This is another trace conclude", duration_ns=1000)

# Flush the traces to splunk_ao
logger.flush()


# Show link to Splunk AO log stream
config = SplunkAOConfig.get()
Expand Down
4 changes: 2 additions & 2 deletions splunk-ao-migration-tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ logger = GalileoLogger(project="my-project", log_stream="production")
logger.start_session(name="my-session")
logger.add_llm_span(input="Hello", output="Hi", model="gpt-4")
logger.conclude() # closes current span; no flush kwarg
logger.flush() # uploads traces
logger.flush() # drain the OTLP export queue
```

### After (splunk-ao)
Expand All @@ -418,7 +418,7 @@ logger = SplunkAOLogger(project="my-project", agent_stream="production")
logger.start_session(name="my-session")
logger.add_llm_span(input="Hello", output="Hi", model="gpt-4")
logger.conclude() # closes current span; no flush kwarg
logger.flush() # uploads traces
logger.flush() # drain the OTLP export queue
```

---
Expand Down
2 changes: 1 addition & 1 deletion splunk-ao-migration-tool/examples/after_splunk_ao.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def call_llm(prompt: str) -> str:
logger.start_session(name="my-session")
logger.add_llm_span(input="Hello", output="Hi", model="gpt-4")
logger.conclude() # closes current span; no flush kwarg
logger.flush() # uploads traces
logger.flush() # drain the OTLP export queue
2 changes: 1 addition & 1 deletion splunk-ao-migration-tool/examples/before_galileo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def call_llm(prompt: str) -> str:
logger.start_session(name="my-session")
logger.add_llm_span(input="Hello", output="Hi", model="gpt-4")
logger.conclude() # closes current span; no flush kwarg
logger.flush() # uploads traces
logger.flush() # drain the OTLP export queue
10 changes: 6 additions & 4 deletions src/splunk_ao/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,9 +1309,10 @@ def flush(
on_error: Callable[[Exception], None] | None = None,
) -> None:
"""
Upload all captured traces under a project and agent stream context to Splunk AO.
Drain the OTLP export queue for a specific project and agent stream context.

If no project or agent stream is provided, then the currently initialized context is used.
Does not conclude open spans or upload traces directly. If no project or
agent stream is provided, the currently initialized context is used.

Parameters
----------
Expand Down Expand Up @@ -1349,9 +1350,10 @@ def _on_flush_error(exc: Exception) -> None:

def flush_all(self) -> None:
"""
Upload all captured traces under all contexts to Splunk AO.
Drain the OTLP export queue for all active logger contexts.

This method flushes all traces regardless of project or log stream.
This method drains all loggers regardless of project or agent stream.
It does not conclude open spans or upload traces directly.
"""
SplunkAOLoggerSingleton().flush_all()

Expand Down
1 change: 0 additions & 1 deletion src/splunk_ao/logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class SplunkAOLogger(TracesLogger):
duration_ns=1000
)
logger.conclude(output="I am!", duration_ns=2000)
logger.flush()
```
"""

Expand Down
10 changes: 5 additions & 5 deletions src/splunk_ao/utils/singleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ def flush(
agent_stream_id: str | None = None,
) -> None:
"""
Flush (upload and clear) a SplunkAOLogger instance.
Drain the OTLP export queue for a SplunkAOLogger instance.

If both project and agent_stream are None, then all cached loggers are flushed
and cleared. Otherwise, only the specific logger corresponding to the provided
key (project, agent_stream) is flushed and removed.
If both project and agent_stream are None, then all cached loggers are drained.
Otherwise, only the specific logger corresponding to the provided
key (project, agent_stream) is drained.

Parameters
----------
Expand Down Expand Up @@ -331,7 +331,7 @@ def flush(
self._splunk_ao_loggers[key].flush()

def flush_all(self) -> None:
"""Flush (upload and clear) all SplunkAOLogger instances."""
"""Drain the OTLP export queue for all SplunkAOLogger instances."""
with self._lock:
# Terminate and clear all logger instances.
for logger in self._splunk_ao_loggers.values():
Expand Down
Loading