[Feature Request] Support for custom tracing providers
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- observability-sre
Direzione di ricerca
Inizia leggendo l'inizializzazione di OpenAIAgentsPlugin e l'implementazione mostrata di TemporalTraceProvider, quindi determina come integrare un provider di tracing fornito preservando il comportamento dei workflow Temporal. Il lavoro è completo quando i chiamanti possono passare un provider personalizzato supportato durante la creazione del plugin e il tracing continua a funzionare correttamente nei workflow.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I'd like to add a custom tracing provider for the OpenAI Agents SDK. Importantly, this tracing provider is supported by the OpenAI Agents SDK itself.
The solution I'd like
I'd like to be able to pass the tracing provider to the OpenAI Agents Plugin when initializing the client e.g.
from temporalio.client import Client
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
from custom_tracing_provider import CustomTraceProvider
plugin = OpenAIAgentsPlugin(
trace_provider=CustomTraceProvider()
)
client_config = {
"namespace": NAMESPACE,
"plugins": [plugin],
"API_KEY": os.environ.get("TEMPORAL_API_KEY")
}
_client_instance = await Client.connect(ADDRESS, **client_config)
Given the temporal tracing provider today is implemented on top of the DefaultTracingProvider class provided by OpenAI as shown below, perhaps it wouldn't be too hard to just create a factory that takes any supported tracing provider and returns a Temporal supported one.
class TemporalTraceProvider(DefaultTraceProvider):
"""A trace provider that integrates with Temporal workflows."""
def __init__(self, auto_close_in_workflows: bool = False):
"""Initialize the TemporalTraceProvider."""
super().__init__()
self._original_provider = cast(DefaultTraceProvider, get_trace_provider())
self._multi_processor = _TemporalTracingProcessor(
self._original_provider._multi_processor,
auto_close_in_workflows,
)
def time_iso(self) -> str:
"""Return the current deterministic time in ISO 8601 format."""
if workflow.in_workflow():
return workflow.now().isoformat()
return super().time_iso()
def gen_trace_id(self) -> str:
"""Generate a new trace ID."""
if workflow.in_workflow():
try:
"""Generate a new trace ID."""
return f"trace_{_workflow_uuid()}"
except ReadOnlyContextError:
return f"trace_{uuid.uuid4().hex}"
return super().gen_trace_id()
def gen_span_id(self) -> str:
"""Generate a span ID."""
if workflow.in_workflow():
try:
"""Generate a deterministic span ID."""
return f"span_{_workflow_uuid()}"
except ReadOnlyContextError:
return f"span_{uuid.uuid4().hex[:24]}"
return super().gen_span_id()
def gen_group_id(self) -> str:
"""Generate a group ID."""
if workflow.in_workflow():
try:
"""Generate a deterministic group ID."""
return f"group_{_workflow_uuid()}"
except ReadOnlyContextError:
return f"group_{uuid.uuid4().hex[:24]}"
return super().gen_group_id()
def __enter__(self):
"""Enter the context of the Temporal trace provider."""
return self
def __exit__(
self,
exc_type: type[BaseException],
exc_val: BaseException,
exc_tb: TracebackType,
):
"""Exit the context of the Temporal trace provider."""
self._multi_processor.shutdown()
- Lingua principale
- Python
- Stelle
- 1.2k
- Fork
- 241
- Merge medio
- 3g 2h
- PR unite (30g)
- 49
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di temporalio/sdk-python
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
temporalio/sdk-python#1517 · 10 commenti ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
temporalio/sdk-python#496 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
temporalio/sdk-python#1890 ·
-
[Bug] Local activity resolutions regrouped on replay since 1.32.0, delivering the wrong payload Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
temporalio/sdk-python#1881 · 1 commento ·
-
bug
temporalio/sdk-python#1817 · 1 commento · 1 assegnatario ·
Tutte le issue di temporalio/sdk-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100