Added support for otel
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
@@ -8,10 +9,17 @@ namespace SampleApi.Controllers
|
||||
[ApiController]
|
||||
public class DemoController : ControllerBase
|
||||
{
|
||||
private static readonly ActivitySource MyActivitySource = new("SampleApi");
|
||||
|
||||
// GET: api/<DemoController>
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
public IEnumerable<string> Get(ILogger<DemoController> logger)
|
||||
{
|
||||
using var activity = MyActivitySource.StartActivity("ManualTraceTest");
|
||||
activity?.SetTag("test.status", "success");
|
||||
|
||||
logger.LogInformation("sample api log");
|
||||
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user