c# - 如何可视化指标应用洞察?
问题描述
我正在向我的应用程序洞察添加指标,但我不知道如何可视化我跟踪的值。我不知道我这样做是否正确。
我的代码如下所示:
public void AddCustomMetric(String metricName,double Amount, List<Property> additionalProperties)
{
CreateMetric(metricName, Amount, additionalProperties);
}
private void CreateMetric(String metricName, double amount, List<Property> additionalProperties)
{
List<String> metrycsNameList = new List<String>();
List<String> metrycsValueList = new List<String>();
try
{
additionalProperties.ForEach(property => metrycsValueList.Add(property.Value));
additionalProperties.ForEach(property => metrycsNameList.Add(property.Name));
Metric metric = _client.GetMetric(new MetricIdentifier("MetricNamespace", metricName, metrycsNameList));
//metrycsValueList.ForEach(metricValue => metric.TrackValue(Amount, metricValue, "hola", "adios"));
AddMetricValues(metric, amount, metrycsValueList);
}
catch (Exception ex)
{
throw new CustomMetricException("CustomMetricException", "Error adding a Custom Metric", ex.StackTrace);
}
}
private void AddMetricValues(Metric metric, double amount, List<String> metrycsValueList)
{
int numberOfElements = metrycsValueList.Count;
switch (numberOfElements)
{
case 1:
metric.TrackValue(amount, metrycsValueList[0]);
break;
case 2:
metric.TrackValue(amount, metrycsValueList[0], metrycsValueList[1]);
break;
case 3:
metric.TrackValue(amount, metrycsValueList[0], metrycsValueList[1], metrycsValueList[2]);
break;
.........
我将方法称为:
public void AddCustomMetricTestTupla()
{
List<Property> propertiesList = new List<Property>();
propertiesList.Add(new Property("propertyExample", "value"));
propertiesList.Add(new Property("propertyExample1", "value2"));
propertiesList.Add(new Property("propertyExample2", "value3"));
//Tests method AddCustomMetric giving a tuple as a param.
using (AzureInsightsClient azureInsightsClient = new AzureInsightsClient(myClientKey))
{
azureInsightsClient.FlushMetrics();
azureInsightsClient.AddCustomMetric("Example", 2, propertiesList);
}
}
我不知道我是否正确地获得了跟踪,因为我在 Azure Application Insights 上看不到任何内容。
也许我的代码有错误?有人帮忙吗?
解决方案
推荐阅读
- javascript - 如何在 Javascript 中使用 for 循环绘制完整的多边形?
- python - 通过分隔符拆分 Pandas 中的列值而不丢失分隔符
- python - 为什么 len() 函数会计算列表中的每个字符?
- swift - 可以用 NSOrdered 集编码吗?
- javascript - 仅显示选定的项目 - Javascript 替换 innerHTML
- scala - 尝试从本地 S3 中的镶木地板文件构建 DataFrame 时出现 403 异常
- haskell - Haskell中转义的&符号是什么意思?
- google-analytics - Google Analytics - 获取 URL 的页面查看信息
- spring - Spring 应用程序 - 通过测试属性覆盖应用程序属性
- apache-spark - 优化 spark 分区查询