0

I am trying to enable Serilog Tracing (serilog-tracing 2.3.1) in our system. It works well with http communication between our internal processes in my experiments. However, one of our components is an Azure Function app with a set of different triggers.

The setup looks like

var listener = new ActivityListenerConfiguration()
    .Instrument.SqlClientCommands()
    .Instrument.AspNetCoreRequests(opts =>
     {
          opts.IncomingTraceParent = IncomingTraceParent.Trust;
     })
    .TraceToSharedLogger();

Inside the process I have a number of HttpTriggers

  [Function("MyHttpTriggeredFunc")]
  public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Admin, "get")] HttpRequestData req)
    {
        using var activity = Log.Logger.StartActivity("Http func running");
        ... 

When this function is invoked from another of my processes (set up with the same ActivityListenerConfiguration), the span works just like expected.

I also have a number of timer triggers like

[Function("MyTimerTriggeredFunc")]
  public async Task Run([TimerTrigger("4 */2 * * * *", RunOnStartup = false)] TimerInfo myTimer, FunctionContext executionContext) // 4 sec past every 2 min
  {
      using var activity = log.StartActivity("Timer func running");
      ... 

but this activity never gets logged to Seq (or console) at all. Normal logs from my function come out as normal, but no trace shown, and the "Timer func running" does not appear either. Third party spans like from the SQL queries do show, but not my own activities.

I also noticed that if I invoke the HTTP triggered function from Postman, it does not produce a trace log unless i provide a (bogus) traceparent http header.

If I start an activity in my function bootstrap, it comes out fine, but I can only get traces from HTTP functions if they are triggered by another ASPNET Core process. That part is not a problem, but I'd like to get traces from timer (and later Event Grid) triggers as well.

I have experimented some with the ActivityKind argument, but not gotten to a solution or answer as to what is happening.

The behavior is the same when running on my dev box using func start, so the Azure part is not really involved.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.