I am using aspnet core with opentelemetry. When I try to set tag in activityEvent. It appears in customdeminsion field in trace log in azure app insight. However. When I try to setTag in activity. I cannot find anywhere to see those tags. Where can I check them? Thanks a lot.
If you want to use in activity and not with activity event you can use something like below code in your code:
You can use Console activity to send data without activity event:
using System.Diagnostics;
using Azure.Monitor.OpenTelemetry.Exporter;
using OpenTelemetry;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
class Program
{
static async Task Main(string[] args)
{
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyService"))
.AddSource("ConsoleApp")
.AddAzureMonitorTraceExporter(azureExporterOptions =>
{
azureExporterOptions.ConnectionString = "InstrumentationKey=344b8760-g6s-f72;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=a0fh8-8gd8-976f";
})
.Build();
await Rith_func();
}
public static async Task Rith_func()
{
using var ri_src = new ActivitySource("ConsoleApp");
using (var rith_act = ri_src.StartActivity("Rithwik_test_activity"))
{
rith_act?.SetTag("rith_tag", "rith_value");
Console.WriteLine("Hello Rithwik Bojja, Activity is started !!");
await Task.Delay(1000);
Console.WriteLine("Hello Rithwik Bojja, Activity is ended !!");
}
}
}
Output: