# -*- coding: utf-8 -*-"""The tracing interface class in agentscope."""fromagentscopeimport_config
[docs]defsetup_tracing(endpoint:str)->None:"""Set up the AgentScope tracing by configuring the endpoint URL. Args: endpoint (`str`): The endpoint URL for the tracing exporter. """# Lazy importfromopentelemetry.sdk.traceimportTracerProviderfromopentelemetry.sdk.trace.exportimportBatchSpanProcessorfromopentelemetry.exporter.otlp.proto.http.trace_exporterimport(OTLPSpanExporter,)fromopentelemetryimporttracetracer_provider=TracerProvider()exporter=OTLPSpanExporter(endpoint=endpoint)span_processor=BatchSpanProcessor(exporter)tracer_provider.add_span_processor(span_processor)trace.set_tracer_provider(tracer_provider)_config.trace_enabled=True