public override object ExecuteScalar() { object result; var commandId = Guid.NewGuid(); using (var trace = new LocalTrace(this.CommandText).AnnotateWith(PredefinedTag.SqlQuery, this.CommandText)) { try { result = InnerCommand.ExecuteScalar(); } catch (Exception exception) { trace.AnnotateWith(PredefinedTag.Error, exception.Message); throw; } } return(result); }
static void Main(string[] args) { new Zipkin.ZipkinBootstrapper("api-sample", IPAddress.Loopback, 1234) .ZipkinAt("localhost") .WithSampleRate(1.0) // means log everything .Start(); using (var roottrace = new StartClientTrace("client-op")) // Starts a root trace + span { var crossProcessBag = new Dictionary <string, object>(); TraceContextPropagation.PropagateTraceIdOnto(crossProcessBag); Thread.Sleep(20); roottrace.TimeAnnotateWith("custom"); using (new StartServerTrace("server-op", crossProcessBag).SetLocalComponentName("fake-server")) { using (new LocalTrace("op1").AnnotateWith(PredefinedTag.SqlQuery, "select * from ...")) { Thread.Sleep(70); } using (var trace = new LocalTrace("op2")) { Thread.Sleep(90); trace.AnnotateWith(PredefinedTag.Error, "error message"); // mark it with an error } using (new LocalTrace("op3").TimeAnnotateWith(PredefinedTag.ServerSend)) { Thread.Sleep(90); } } } Thread.Sleep(1000); }
private static Task <bool> CompleteWithinSpawnedTask() { var local = new LocalTrace("childspan2"); var cur = TraceContextPropagation.CurrentSpan; local.Span.Should().Be(cur); return(Task.Run(new Func <bool>(() => { // Thread.Sleep(20); var cur2 = TraceContextPropagation.CurrentSpan; cur2.Should().Be(local.Span); local.Dispose(); cur2 = TraceContextPropagation.CurrentSpan; // cur2.Should().Be(local.Span); return true; }))); }
public static string Generate(VersionTable <SiteHost> _versionTable, TimeSpan _warmUp, string _watchFolder, bool _isScanning, Exception _lastScanError) { var body = T.g("body"); var page = T.g("html")[ T.g("head")[ T.g("title")["Wrapper proxy test page"], T.g("style")[".good {stroke: #0A0; } .bad {stroke: #A00; } path { stroke-width: 2.5px; fill: none; opacity: 0.5;}"] ], body ]; body.Add(T.g("h1")["Status"]); if (_warmUp.Ticks == 0) { body.Add(T.g("p")["The proxy is starting up. Versions will be listed below as they are ready."]); } else { body.Add(T.g("p")["Three flavours"]); body.Add(T.g("p")["The proxy is active. Initial warm up took: " + _warmUp]); } body.Add(T.g("p")["Currently loaded: " + _versionTable.VersionsAvailable()]); body.Add(T.g("p")["Watch folder: ", T.g("tt")[_watchFolder], " ", (_isScanning) ? ("Scan is in progress") : ("Scanner is idle")]); // ReSharper disable once InconsistentlySynchronizedField if (_lastScanError != null) { body.Add(T.g("p")["Last scan error: ", _lastScanError.ToString()]); } // run a health check against all versions and spit them out here... body.Add(T.g("h1")["Health check"]); var list = _versionTable.AllVersions().ToList(); foreach (var version in list) { var result = version.HostedSite.DirectCall(HealthRequest); body.Add(T.g("h3")["Version " + version.VersionName]); body.Add(T.g("p")[version.CallCount + " calls, " + (100 * version.SuccessRate).ToString("0.00") + "% successful"]); body.Add(T.g("p")[result.StatusCode + " " + result.StatusMessage]); if (result.Content != null) { body.Add(T.g("pre")[Encoding.UTF8.GetString(result.Content)]); } if (version.LastError != null) { body.Add(T.g("p")["Last proxy error: " + version.LastError]); } } body.Add(T.g("h1")["Recent log entries"]); // This double container lets us put the scroll-bar on the left. I just like it better that way :-) body.Add(T.g("div", "style", "direction:rtl;overflow-y:scroll;height:40%;")[ T.g("pre", "style", "direction: ltr;")[LocalTrace.ReadAll()] ]); // Some graphs body.Add(T.g("h1")["Recent History"], T.g("p")["Logarithmic time scale. Left is last few seconds, right is last week."]); foreach (var version in list) { body.Add(T.g("h3")["Version " + version.MajorVersion]); body.Add(T.g("div")[RenderGraph(version.SuccessHistory, version.FailureHistory)]); } return(page.ToString()); }