Parallel Integration with Future AGI for Search and Extract Tracing

Trace Parallel Search and Extract calls in Future AGI with the traceAI-parallel instrumentor for the parallel-web client.

Trace Parallel Search and Extract calls in Future AGI with the maintained traceAI-parallel package. Each call records its duration, result counts and errors. This integration covers the Python client; Task runs, task groups, FindAll and Monitor are not traced.

Install

Use Python 3.10–3.13 and a Parallel API key. Install the instrumentor, tracing SDK and client:

pip install 'traceAI-parallel==0.1.1' 'fi-instrumentation-otel==1.2.3' 'parallel-web==1.3.5'

The instrumentor requires parallel-web>=1.0.1,<2.

Configure credentials and privacy

Set your Parallel and Future AGI API keys in the environment that runs your application:

export PARALLEL_API_KEY="your-parallel-api-key"
export FI_API_KEY="your-futureagi-api-key"
export FI_SECRET_KEY="your-futureagi-secret-key"

Search queries are recorded by default. To hide input content, warning messages and error details, set these variables before initializing the instrumentor:

export FI_HIDE_INPUTS=true
export FI_HIDE_OUTPUTS=true
export FI_HIDE_ERROR_DETAILS=true

These settings preserve counts, mode, IDs, error status and exception types. Requested URLs and objectives are not recorded as attributes unless you enable capture_urls=True or capture_objective=True on instrument(); FI_HIDE_INPUTS=true overrides both options.

Without these privacy settings, error and warning text can contain request content. Key and input redaction replaces verbatim matches only, not escaped or truncated copies. Keep sensitive content out of requests or use the settings above. See TraceConfig for additional controls.

Run a search and extract

Save this as parallel_example.py. Register tracing and instrument the client before making API calls:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from parallel import Parallel
from traceai_parallel import ParallelInstrumentor

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="parallel-search",
)
ParallelInstrumentor().instrument(tracer_provider=trace_provider)

try:
    with Parallel() as client:  # reads PARALLEL_API_KEY
        result = client.search(
            search_queries=["OpenTelemetry distributed tracing"], mode="turbo"
        )
        if result.results:
            extracted = client.extract(
                urls=[result.results[0].url], session_id=result.session_id
            )
            print(f"Extracted {len(extracted.results)} page(s).")
        else:
            print("No search results; try a more specific query.")
finally:
    trace_provider.force_flush()
python parallel_example.py

Open Observe in Future AGI and select parallel-search. Inspect parallel.search and, when the search returns a result, parallel.extract. Calls made under an active span become its children; otherwise each call starts a separate trace.

What is captured

Both Parallel and AsyncParallel are instrumented. Retries within a client call stay in the same span.

CallSpan nameSpan kind
searchparallel.searchRETRIEVER
extractparallel.extractTOOL

Spans include query or URL counts, result counts, failed-URL counts for extraction, search/extract/session IDs, and the search mode when supplied. Search queries are stored in gen_ai.retrieval.query and input.value, capped at 1 KB, unless inputs are hidden. Usage SKU names and counts are recorded when returned; they are not token counts or monetary costs.

The instrumentor does not capture result excerpts, titles, result URLs or page text. Response warnings become parallel.warning events. API errors set the span status to ERROR and propagate unchanged to your code. With error details enabled, exception events contain an exception summary, not traceback frames. An async cancellation sets parallel.cancelled=true.

Calls through copy() and with_options() are also traced. For with_raw_response and with_streaming_response, access those wrappers only after calling instrument(). Their response bodies are not parsed for result counts or IDs; streaming spans end when response headers arrive, not when the body finishes reading.

Troubleshooting

  • No spans appear. Check FI_API_KEY and FI_SECRET_KEY, initialize the instrumentor before API calls, and flush the provider before a short-lived process exits.
  • No extract span appears. An empty search result skips extraction. Try a different query and inspect the search span’s result count.
  • instrument() reports a dependency conflict. Use a parallel-web version within >=1.0.1,<2.
  • ParallelError when creating the client. Set PARALLEL_API_KEY. Client initialization fails before a traced API call when the key is missing.

For Model Context Protocol traffic, use the MCP integration. An agent framework’s tool span describes its tool invocation; this instrumentor adds the underlying Parallel API span beneath it when the framework keeps that span active.

Was this page helpful?

Questions & Discussion