/greet
endpoint that demonstrates how to integrate TrueFoundry’s tracing capabilities.
Create Tracing Project, API Key and copy tracing code
Install Dependencies
Add Tracing code to FastAPI application
Traceloop.init()
call to the application and instrument the FastAPI app with OpenTelemetry.Run your application and view logged trace
Trace custom internal functions
httpx
, you can use the opentelemetry-instrumentation-httpx
package. The same GitHub repository provides instrumentation libraries for many popular Python frameworks and libraries.
For a broader overview of how to integrate these libraries into your app, refer to our Distributed Tracing guide, which also includes examples with httpx
instrumentation.If you’re working with custom internal logic that isn’t covered by existing instrumentation, you can use Traceloop’s decorators to manually trace specific functions.Here’s an example of adding tracing to an internal function using the @task
decorator:Run your application and view traces, including custom function spans