Activity API or instrumentation libraries will be captured.
Instrument libraries
HttpClient calls and libraries that create spans using their own ActivitySource, such as Npgsql, are captured automatically without any additional setup.
Other libraries require OpenTelemetry instrumentation packages. For example, to trace database queries made with Microsoft.Data.SqlClient, install OpenTelemetry.Extensions.Hosting and OpenTelemetry.Instrumentation.SqlClient:
Program.cs file:
Program.cs
Create custom spans
For custom operations that are not covered by library instrumentation, you can create spans using theStartActivity() method of the IApitally service. It is a thin wrapper around the standard .NET ActivitySource API, which you can also use directly.
StartActivity() method
Use StartActivity() to trace code blocks within a request handler. The span ends when the returned activity is disposed:
ActivitySource. If your application registers its own tracer provider, add the source to it with AddSource().
Capture handled exceptions
Apitally includes exceptions in request traces to help you diagnose server errors. Exceptions that propagate through ASP.NET Core are captured automatically. If your application catches an exception and handles it without rethrowing it, callCaptureException() on the IApitally service to include it in the current request trace.