DocsTracing FeaturesTrace URLs

Trace URLs

Each trace has a unique URL that you can use to share it with others or to access it directly.

Get trace url

Sometimes, it is useful to get the trace URL directly in the SDK. E.g. to add it to your logs or interactively look at it when running experiments in notebooks.

The v3 SDK is currently in beta. Please check out the SDK v3 for more details.

When using the @observe() decorator:

from langfuse import observe
 
@observe()
def process_data():
    from langfuse import get_client
    langfuse = get_client()
 
    # Get the URL of the current trace
    trace_url = langfuse.get_trace_url()
    print(f"View trace at: {trace_url}")
 
    # or pass the trace id
    trace_id = langfuse.get_current_trace_id()
    trace_url = langfuse.get_trace_url(trace_id=trace_id)

When using context managers:

from langfuse import Langfuse
 
langfuse = Langfuse()
 
with langfuse.start_as_current_span(name="process-request") as span:
    # Get the URL of this trace
    trace_url = langfuse.get_trace_url()
    print(f"View trace at: {trace_url}")
 
    # or pass the trace id
    trace_id = langfuse.get_current_trace_id()
    trace_url = langfuse.get_trace_url(trace_id=trace_id)

Share trace via url

By default, only members of your Langfuse project can view a trace.

You can make a trace public to share it via a public link. This allows others to view the trace without needing to log in or be members of your Langfuse project.

Example: https://cloud.langfuse.com/project/clkpwwm0m000gmm094odg11gi/traces/2d6b96f2-0a4d-4366-99a5-1ad558c66e99

Was this page useful?

Questions? We're here to help

Subscribe to updates