public static void InProcessLinkTracerSample() { // start a custom background worker CustomBackgroundWorker customBackgroundWorker = new CustomBackgroundWorker(); // we're using the incoming remote call tracer as an example for an active service call IIncomingRemoteCallTracer incomingRemoteCallTracer = SampleApplication.OneAgentSdk .TraceIncomingRemoteCall("RemoteMethod", "RemoteServiceName", "mrcp://endpoint/service"); incomingRemoteCallTracer.Start(); try { // create an in-process link on the originating thread IInProcessLink inProcessLink = SampleApplication.OneAgentSdk.CreateInProcessLink(); // delegate work to another thread, in this case we use a custom background worker implementation customBackgroundWorker.EnqueueWorkItem(() => { // use the in-process link to link the PurePath on the target thread to its origin IInProcessLinkTracer inProcessLinkTracer = SampleApplication.OneAgentSdk.TraceInProcessLink(inProcessLink); inProcessLinkTracer.Start(); DatabaseRequestTracerSamples.Sync_StartEnd(); // performs a database request traced using the IDatabaseRequestTracer inProcessLinkTracer.End(); }); // the same link can be re-used multiple times customBackgroundWorker.EnqueueWorkItem(() => { IInProcessLinkTracer inProcessLinkTracer = SampleApplication.OneAgentSdk.TraceInProcessLink(inProcessLink); inProcessLinkTracer.Trace(() => { DatabaseRequestTracerSamples.Sync_StartEnd(); }); }); customBackgroundWorker.EnqueueWorkItem(() => { IInProcessLinkTracer inProcessLinkTracer = SampleApplication.OneAgentSdk.TraceInProcessLink(inProcessLink); inProcessLinkTracer.Trace(DatabaseRequestTracerSamples.Sync_StartEnd); }); } catch (Exception e) { incomingRemoteCallTracer.Error(e); throw e; } finally { incomingRemoteCallTracer.End(); customBackgroundWorker.Shutdown(); } }
public IInProcessLinkTracer TraceInProcessLink(IInProcessLink inProcessLink) => dummyInProcessLinkTracer;