Tagging in .NET SDK
Thundra's .NET agent enables you to add custom tags to your invocations or applications, which will help you better filter your data.
You can add custom tags to your invocation with the help of static methods of Thundra.Agent.Lambda.Core.InvocationSupport object. These are the methods you can find in the InvocationSupport class.
Shown below is the
InvocationSupport
's programmatic tag API:InvocationSupport.cs
public static string InvocationId;
public static Dictionary<string, object> GetTags();
public static void SetTag(string key, object value);
public static object GetTag(string key);
public static void SetError(Exception error);
public static Exception GetError();
public static void ClearTag(string key);
The example below shows an usage of the
InvocationSupport
class:using Thundra.Agent.Lambda.Core.InvocationSupport;
...
Console.WriteLine(InvocationSupport.InvocationId);
InvocationSupport.SetTag("user-id", 1980);
InvocationSupport.SetTag("user-name", "Dudley Dursley");
InvocationSupport.SetTag("is-muggle", true);
InvocationSupport.SetError(new UserException("Muggles not allowed"));
Thundra.Agent.Lambda.Core.SpanSupport
tags a custom span that is created via OpenTracing API as erroneous. To learn more about how to create custom spans in order to further your monitoring experience, visit the Enrich Tracing page.using (IScope updateEntityScope =
GlobalTracer.Instance.BuildSpan("UpdateEntity")
.StartActive(finishSpanOnDispose: true))
{
try
{
DoRiskyThings();
}
catch(Exception e)
{
SpanSupport.SetError(updateEntityScope.Span, e);
throw e;
}
}
Last modified 2yr ago