public Metric1DWrapper(string mdmAccountName, string mdmNamespace, string metricName, string dimension1Name) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { this.metric = MeasureMetric1D.Create(mdmAccountName, mdmNamespace, metricName, dimension1Name, addDefaultDimension: true); } }
static void MdmSample() { ErrorContext mdmError = new ErrorContext(); // MeasureMetric usage sample MeasureMetric1D testMeasure = MeasureMetric1D.Create( "Fabricator", // MonitoringAccount "Microsoft/Azure/Fabric/Tenant Manager/Management", // MetricNamespace "HI node count", // MetricName "Cluster", // dimension 1 ref mdmError); if (testMeasure == null) { Console.WriteLine("Fail to create MeasureMetric, error code is {0:X}", mdmError.ErrorCode); Console.WriteLine(" error message: {0}", mdmError.ErrorMessage); } if (!testMeasure.LogValue(29, "Ch3PrdDDC03", ref mdmError)) { Console.WriteLine("Fail to set MeasureMetric value, error code is {0:X}", mdmError.ErrorCode); Console.WriteLine(" error message: {0}", mdmError.ErrorMessage); } if (!testMeasure.LogValue(DateTime.UtcNow, 1, "HK2PrdApp03", ref mdmError)) { Console.WriteLine("Fail to set MeasureMetric value, error code is {0:X}", mdmError.ErrorCode); Console.WriteLine(" error message: {0}", mdmError.ErrorMessage); } Thread.Sleep(1000); if (!testMeasure.LogValue(DateTime.UtcNow, 3, "HK2PrdApp03", ref mdmError)) { Console.WriteLine("Fail to set MeasureMetric value, error code is {0:X}", mdmError.ErrorCode); Console.WriteLine(" error message: {0}", mdmError.ErrorMessage); } }
static void EmitMetrics() { ErrorContext mdmError = new ErrorContext(); MeasureMetric1D testMeasure = MeasureMetric1D.Create( "MyMonitoringAccount", "MyMetricNamespace", "MyMetricName", "MyDimensionName", ref mdmError); if (testMeasure == null) { Console.WriteLine("Fail to create MeasureMetric, error code is {0:X}, error message is {1}", mdmError.ErrorCode, mdmError.ErrorMessage); } else if (!testMeasure.LogValue(101, "MyDimensionValue", ref mdmError)) { Console.WriteLine("Fail to log MeasureMetric value, error code is {0:X}, error message is {1}", mdmError.ErrorCode, mdmError.ErrorMessage); } }