-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4357a5
commit 6715d24
Showing
5 changed files
with
101 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...t.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/CustomMetricExporter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.Metrics | ||
{ | ||
using OpenTelemetry.Metrics; | ||
using OpenTelemetry; | ||
using System; | ||
|
||
public class CustomMetricExporter : BaseExporter<Metric> | ||
{ | ||
// This method will be called periodically by OpenTelemetry SDK | ||
public override ExportResult Export(in Batch<Metric> batch) | ||
{ | ||
Console.WriteLine("\n[Custom Exporter] Exporting metrics:"); | ||
|
||
int gaugeCount = 0; | ||
foreach (var metric in batch) | ||
{ | ||
Console.WriteLine($"Metric: {metric.Name}, Type: {metric.MetricType}"); | ||
|
||
foreach (var metricPoint in metric.GetMetricPoints()) | ||
{ | ||
switch (metric.MetricType) | ||
{ | ||
case MetricType.LongSum: | ||
Console.WriteLine($"Value (Counter): {metricPoint.GetSumLong()}"); | ||
break; | ||
case MetricType.LongGauge: | ||
Console.WriteLine($"Value (Gauge): {metricPoint.GetGaugeLastValueLong()}"); | ||
gaugeCount++; | ||
break; | ||
case MetricType.Histogram: | ||
Console.WriteLine($"Value (Histogram): {metricPoint.GetHistogramCount()}"); | ||
|
||
foreach (HistogramBucket bucket in metricPoint.GetHistogramBuckets()) | ||
{ | ||
Console.WriteLine($"{bucket.ExplicitBound} : {bucket.BucketCount}"); | ||
} | ||
break; | ||
} | ||
} | ||
|
||
} | ||
|
||
Console.WriteLine($"Total gauge values exported: {gaugeCount}"); | ||
Console.WriteLine(); | ||
|
||
return ExportResult.Success; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters