Yes, you can filter out or disable HTTP request traces by customizing your OpenTelemetry setup. Use a custom SpanProcessor to filter out spans (e.g., those with names like "HTTP POST" or "HTTP GET") before they are sent to Phoenix. This is done by subclassing BatchSpanProcessor and overriding its on_start/on_end methods to skip unwanted spans.
Example:
```
from phoenix.otel import register, BatchSpanProcessor
from opentelemetry.context import Context
from opentelemetry.sdk.trace import ReadableSpan, Span
class FilteringSpanProcessor(BatchSpanProcessor):
def _filter_condition(self, span: Span) -> bool:
# Filter out HTTP request spans by name or attributes
return span.name.startswith("HTTP")
def on_start(self, span: Span, parent_context: Context) -> None:
if self._filter_condition(span):
return
super().on_start(span, parent_context)
def on_end(self, span: ReadableSpan) -> None:
if self._filter_condition(span):
return
super().on_end(span)
tracer_provider = register(
project_name="openai-agents-test",
endpoint="http://localhost:6006/v1/traces",
auto_instrument=True,
)
tracer_provider.add_span_processor(FilteringSpanProcessor(
endpoint="http://localhost:6006/v1/traces",
protocol="http/protobuf",
))
```
This will prevent HTTP request spans from being exported to Phoenix. Would you like more detail on customizing the filter or other approaches?
Sources:
- <https://arize.com/docs/phoenix/tracing/how-to-tracing/advanced/modifying-spans|Phoenix Docs: Modifying Spans>
- <https://github.com/Arize-ai/phoenix/blob/main/docs/tracing/how-to-tracing/advanced/modifying-spans.md|FilteringSpanProcessor Example>
- <https://arize.com/docs/phoenix/tracing/how-to-tracing/advanced/modifying-spans#%3AS1%3A|Phoenix Docs: Filter Spans to Export>