Skip to content

Commit

Permalink
refactor: use suppress_tracing from openinference-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
axiomofjoy committed Mar 26, 2024
1 parent dd54fc7 commit 1091592
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 51 deletions.
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.

0 comments on commit 1091592

Please sign in to comment.