Simple extensions on top of the OpenTracing APIs.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Simple extensions on top of the OpenTracing APIs.

Notable pieces...


This name is verbose, don't be surprised if it changes slightly :)

Allows setting tags from an anonymous type. E.g. setting arguments from a method easily.

Before and After

void MyMethod(string a, int b, ulong c, bool d)
  using (GlobalTracer.Instance
-   .WithTag(nameof(a), a)
-   .WithTag(nameof(b), b)
-   .WithTag(nameof(c), c)
-   .WithTag(nameof(d), d)
+   // Automatically captures the parameter names due to how anonymous types work :-)
+   .WithTagsFromAnonymousType(new { a, b, c, d })


And its related ISpan.LogWithMemberInfo and ISpanBuilder.WithCallerMemberNameTag

I'm not sure LogMemberInfo is actually useful aside from the other two methods, it might be removed

Log the member name (and even line number) easily.

Before and After

void MyMethod()
  using (var scope = GlobalTracer.Instance
-    // Hopefully doesn't get refactored to another method :-S
-    .SetTag("fromMethod", nameof(MyMethod))
+    .WithCallerMemberNameTag(tagName: "fromMethod")
-      .Log(
+      .LogWithMemberInfo(
        // [nit] - Dictionary is not as efficient as an Array of KeyValuePair's, but it is a nicer syntax :)
        fields: new Dictionary<string, object>(3)
-         ["memberName"] = nameof(MyMethod),
-         ["memberLineNumber"] = /* This actually isn't possible */,
          ["someKey"] = true

ISpan.Log(string key, object value)

And its related overloads

Allows logging a single KeyValuePair to the ISpan, without having the noise of initializing an array in your log code.

Before and After

ISpan span;
-  new []
-  {
-    new KeyValuePair<string, object>("myField", "myValue"),
-  });
+span.Log("myField", "myValue");