Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use suppress_tracing from openinference-instrumentation #2700

Merged
merged 1 commit into from
Mar 28, 2024
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies = [
"opentelemetry-proto",
"opentelemetry-exporter-otlp",
"openinference-semantic-conventions>=0.1.5",
"openinference-instrumentation",
"openinference-instrumentation-langchain>=0.1.12",
"openinference-instrumentation-llama-index>=1.2.0",
"openinference-instrumentation-openai>=0.1.4",
Expand Down
24 changes: 2 additions & 22 deletions src/phoenix/trace/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import contextlib
from typing import Iterator
from openinference.instrumentation import suppress_tracing

from .projects import using_project
from .span_evaluations import DocumentEvaluations, Evaluations, SpanEvaluations, TraceEvaluations
Expand All @@ -12,24 +11,5 @@
"DocumentEvaluations",
"TraceEvaluations",
"using_project",
"suppress_tracing",
]


@contextlib.contextmanager
def suppress_tracing() -> Iterator[None]:
"""
Context manager to pause OpenTelemetry instrumentation.

Examples:
with suppress_tracing():
# No tracing will occur within this block
...
"""
try:
from opentelemetry.context import _SUPPRESS_INSTRUMENTATION_KEY, attach, detach, set_value
except ImportError:
yield
return
token = attach(set_value(_SUPPRESS_INSTRUMENTATION_KEY, True))
yield
detach(token)
29 changes: 0 additions & 29 deletions tests/trace/test_suppress_tracing.py

This file was deleted.

Loading