捕获中间件中的操作签名

时间:2017-05-01 14:02:41

标签: asp.net asp.net-core

我想使用自定义工具捕获一些关于中间件中web api性能的指标。我想标记每个指标,以便它易于区分。

我想捕获标签中的操作路径,操作方法和签名。例如POST - /api/values(string param1, string param2, int param3)

我的中间件看起来像这样:

    public Task Invoke(HttpContext context) {
        // Build metric
        var path = context.Request.Path.Value;
        var method = context.Request.Method;
        var signature = // Is it possible to retrieve something like (string, string, int) here?
        var name = BuildMetricName(path, method, signature);

        var metricId = sdk.BeginMetric(name);

        var delegateTask = next(context);

        //work to service request is done, have sdk end the metric
        sdk.EndMetric(metricId);
        return delegateTask;
    }

复合问题是不要减慢处理请求的要求,因此任何昂贵的反射操作都不会削减。

0 个答案:

没有答案