Microsoft Azure Service Profiler

Q: How to enable Service Profiler for Asp.Net Core 1.0 in Azure Web App?

Asp.Net Core 1.0 in Azure Web App will be supported by Service Profiler from August 1st, 2016. We have pre-defined some necessary configurations. You just need to upgrade a dependency package. The package we need to upgrade is "System.Diagnostics.DiagnosticSource", which is responsible for converting 'DiagnoscicSource' events to 'ETW' events. If you want to know more details, you can find the code on GitHub.

Instructions of upgrading the package:

After upgrading the package, you need to redeploy your app to Azure Web App to let Service Profiler pick up the new change.

Q: How to enable Service Profiler for .Net Core Application in general (not "Azure Web App")?

Currently, we can not support .Net Core App running on full .Net Framework (e.g. default Service Fabric Asp.Net Core node). This support will be available in the next full .Net framework (4.6.3) release.

The default logging framework of .Net Core is DiagnosticSource and ILogger. However, Service Profiler need ETW events to pair start and stop events. Fortunately, we can convert the default DiagnosticSource event to ETW event using the .Net Core framework provided bridging feature. We just need to define some configurations. The following is an example configuration setting for ASP.NET Core App:

        {
          "DataCubeName": "<Your data cube name>"
          "General": {
            "ProvideUsageTelemetryData": true
          },
          "DetailedMonitoring": {
            "MonitorSamplingRate": 0.05
          },
          "ActivityMonitoring": {
            "EtwMetrics": [
              {
                /* ASP.NET Core 'DiagnosticSource' events to ETW events conversion*/
                "Provider": {
                  "ProviderName": "Microsoft-Diagnostics-DiagnosticSource",
                  "ProviderKeywords": 72057594037927935, // 0x00FFFFFFFFFFFFFF
                  "ProviderLevel": "Verbose",
                  "SeralizationDelimiter": " ",
                  "DiagnosticSourceConversions": [
                    {
                      "DiagnosticSourceName": "Microsoft.AspNetCore",
                      "DiagnosticSourceEventName": "Microsoft.AspNetCore.Hosting.BeginRequest",
                      "ConvertedETWEventName": "Activity1Start",
                      "ConvertingProperties": [
                        "httpContext.Request.Method",
                        "httpContext.Request.Path"
                      ]
                    },
                    {
                      "DiagnosticSourceName": "Microsoft.AspNetCore",
                      "DiagnosticSourceEventName": "Microsoft.AspNetCore.Hosting.EndRequest",
                      "ConvertedETWEventName": "Activity1Stop"
                    },
                    {
                      "DiagnosticSourceName": "Microsoft.EntityFrameworkCore",
                      "DiagnosticSourceEventName": "Microsoft.EntityFrameworkCore.BeforeExecuteCommand",
                      "ConvertedETWEventName": "Activity2Start",
                      "ConvertingProperties": [
                        "Command.CommandText",
                        "Command.Connection.DataSource",
                        "Command.Connection.Database"
                      ]
                    },
                    {
                      "DiagnosticSourceName": "Microsoft.EntityFrameworkCore",
                      "DiagnosticSourceEventName": "Microsoft.EntityFrameworkCore.AfterExecuteCommand",
                      "ConvertedETWEventName": "Activity2Stop"
                    }
                  ]
                },
                "Metrics": [
                    {
                      "Event": "Activity1Start/Start",
                      "EventStop": "Activity1Stop/Stop",
                      "Name": "Arguments"
                    }
                  ]
              }
            ]
          }
        }

The following part in the previous settings defines converting the framework generated "BeginRequest" DiagnosticSource event to "Activity1Start" ETW event. During the conversion we also forward the http verb ("httpContext.Request.Method") and the relative url path ("httpContext.Request.Path"):

            {
                "DiagnosticSourceName": "Microsoft.AspNetCore",
                "DiagnosticSourceEventName": "Microsoft.AspNetCore.Hosting.BeginRequest",
                "ConvertedETWEventName": "Activity1Start",
                "ConvertingProperties": [
                "httpContext.Request.Method",
                "httpContext.Request.Path"
                ]
            }
Give feedback