关闭追踪的两种方式
介绍在 Phoenix 追踪体系中临时暂停与永久关闭追踪的两种做法,分别借助上下文管理器包裹特定代码段,或对自动埋点器调用 uninstrument 移除追踪。
## 如何关闭追踪 追踪可以暂时暂停或永久禁用. ### 使用上下文管理器暂停跟踪 如果您的代码中有一节不想要跟踪,例如文档块化过程,可以放入其中 `suppress_tracing` 上下文管理器如下所示。 ``` from phoenix.trace import suppress_tracing with suppress_tracing(): # Code running inside this block doesn't generate traces. # For example, running LLM evals here won't generate additional traces. ... # Tracing will resume outside the block. ... ``` ### 自动装置永久拆除 调用 `.uninstrument()` 自动仪器将永久删除追踪。下面是LangChain、LlamaIndex和OpenAI的例子。 ``` LangChainInstrumentor().uninstrument() LlamaIndexInstrumentor().uninstrument() OpenAIInstrumentor().uninstrument() # etc. ``` 这页有用吗? [建议编辑](<https://github.com/arize-ai/phoenix/edit/main/docs/phoenix/tracing/how-to-tracing/advanced/suppress-tracing.mdx>)提出问题
查看原始来源