Skip to content

Commit

Permalink
[Exporter.Geneva] Update OTel SDK version to 1.5.0 and remove Exempla…
Browse files Browse the repository at this point in the history
…rs support (#1238)
  • Loading branch information
utpilla authored Jun 15, 2023
1 parent dbfeaea commit d3d9ab4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

* Update OpenTelemetry SDK version to `1.5.0`.
([#1238](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1238))

* Removed support for exporting `Exemplars`. This would be added back in the
`1.6.*` prerelease versions right after `1.5.0` stable version is released.
([#1238](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1238))

* Add named options support for `GenevaTraceExporter` and
`GenevaMetricExporter`.
([#1218](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1218))
Expand Down
16 changes: 5 additions & 11 deletions src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public override ExportResult Export(in Batch<Metric> batch)
{
try
{
var exemplars = metricPoint.GetExemplars();
// var exemplars = metricPoint.GetExemplars();

switch (metric.MetricType)
{
Expand All @@ -136,7 +136,6 @@ public override ExportResult Export(in Batch<Metric> batch)
metricPoint.EndTime.ToFileTime(), // Using the endTime here as the timestamp as Geneva Metrics only allows for one field for timestamp
metricPoint.Tags,
metricData,
exemplars,
out monitoringAccount,
out metricNamespace);
this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength);
Expand All @@ -156,7 +155,6 @@ public override ExportResult Export(in Batch<Metric> batch)
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out monitoringAccount,
out metricNamespace);
this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength);
Expand All @@ -176,7 +174,6 @@ public override ExportResult Export(in Batch<Metric> batch)
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out monitoringAccount,
out metricNamespace);
this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength);
Expand All @@ -194,7 +191,6 @@ public override ExportResult Export(in Batch<Metric> batch)
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out monitoringAccount,
out metricNamespace);
this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength);
Expand All @@ -211,7 +207,6 @@ public override ExportResult Export(in Batch<Metric> batch)
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out monitoringAccount,
out metricNamespace);
this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength);
Expand All @@ -237,7 +232,6 @@ public override ExportResult Export(in Batch<Metric> batch)
count,
min,
max,
exemplars,
out monitoringAccount,
out metricNamespace);
this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength);
Expand Down Expand Up @@ -301,7 +295,6 @@ internal unsafe ushort SerializeMetricWithTLV(
long timestamp,
in ReadOnlyTagCollection tags,
MetricData value,
Exemplar[] exemplars,
out string monitoringAccount,
out string metricNamespace)
{
Expand All @@ -328,7 +321,7 @@ internal unsafe ushort SerializeMetricWithTLV(
out monitoringAccount,
out metricNamespace);

SerializeExemplars(exemplars, this.buffer, ref bufferIndex);
// SerializeExemplars(exemplars, this.buffer, ref bufferIndex);

SerializeMonitoringAccount(monitoringAccount, this.buffer, ref bufferIndex);

Expand Down Expand Up @@ -361,7 +354,6 @@ internal unsafe ushort SerializeHistogramMetricWithTLV(
uint count,
double min,
double max,
Exemplar[] exemplars,
out string monitoringAccount,
out string metricNamespace)
{
Expand All @@ -388,7 +380,7 @@ internal unsafe ushort SerializeHistogramMetricWithTLV(
out monitoringAccount,
out metricNamespace);

SerializeExemplars(exemplars, this.buffer, ref bufferIndex);
// SerializeExemplars(exemplars, this.buffer, ref bufferIndex);

SerializeMonitoringAccount(monitoringAccount, this.buffer, ref bufferIndex);

Expand Down Expand Up @@ -433,6 +425,7 @@ private static void SerializeMonitoringAccount(string monitoringAccount, byte[]
MetricSerializer.SerializeString(buffer, ref bufferIndex, monitoringAccount);
}

/* Commenting out Exemplar related code as it's removed from `1.5.0` stable version of OpenTelemetry SDK
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void SerializeExemplars(Exemplar[] exemplars, byte[] buffer, ref int bufferIndex)
{
Expand Down Expand Up @@ -548,6 +541,7 @@ private static void SerializeSingleExmeplar(Exemplar exemplar, byte[] buffer, re
var exemplarLength = bufferIndex - bufferIndexForLength + 1;
MetricSerializer.SerializeByte(buffer, ref bufferIndexForLength, (byte)exemplarLength);
}
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void SerializeNonHistogramMetricData(MetricEventType eventType, MetricData value, long timestamp, byte[] buffer, ref int bufferIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryCoreLatestPrereleaseVersion)" />
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ public void SerializeCounterMetricItemWith3Dimensions()
this.counterMetricPointWith3Dimensions.EndTime.ToFileTime(),
this.counterMetricPointWith3Dimensions.Tags,
this.counterMetricDataWith3Dimensions,
Array.Empty<Exemplar>(),
out _,
out _);
}
Expand All @@ -580,7 +579,6 @@ public void SerializeCounterMetricItemWith4Dimensions()
this.counterMetricPointWith4Dimensions.EndTime.ToFileTime(),
this.counterMetricPointWith4Dimensions.Tags,
this.counterMetricDataWith4Dimensions,
Array.Empty<Exemplar>(),
out _,
out _);
}
Expand Down Expand Up @@ -609,7 +607,6 @@ public void SerializeHistogramMetricItemWith3Dimensions()
this.histogramCountWith3Dimensions,
this.histogramMinWith3Dimensions,
this.histogramMaxWith3Dimensions,
Array.Empty<Exemplar>(),
out _,
out _);
}
Expand All @@ -626,7 +623,6 @@ public void SerializeHistogramMetricItemWith4Dimensions()
this.histogramCountWith4Dimensions,
this.histogramMinWith4Dimensions,
this.histogramMaxWith4Dimensions,
Array.Empty<Exemplar>(),
out _,
out _);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,13 @@ public void SuccessfulExportOnLinux()
var metricDataValue = Convert.ToUInt64(metricPoint.GetSumLong());
var metricData = new MetricData { UInt64Value = metricDataValue };

var exemplars = metricPoint.GetExemplars();
// var exemplars = metricPoint.GetExemplars();
var bodyLength = exporter.SerializeMetricWithTLV(
MetricEventType.ULongMetric,
metric.Name,
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand Down Expand Up @@ -354,7 +353,7 @@ public void SuccessfulSerializationWithTLV(bool testMaxLimits, bool hasExemplars

if (hasExemplars)
{
meterProviderBuilder.SetExemplarFilter(new AlwaysOnExemplarFilter());
// meterProviderBuilder.SetExemplarFilter(new AlwaysOnExemplarFilter());
}

if (hasFilteredTagsForExemplars)
Expand Down Expand Up @@ -949,7 +948,8 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
var metricPointsEnumerator = metric.GetMetricPoints().GetEnumerator();
metricPointsEnumerator.MoveNext();
var metricPoint = metricPointsEnumerator.Current;
var exemplars = metricPoint.GetExemplars();

// var exemplars = metricPoint.GetExemplars();

List<TlvField> fields = null;

Expand All @@ -964,7 +964,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand All @@ -990,7 +989,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand Down Expand Up @@ -1018,7 +1016,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand Down Expand Up @@ -1046,7 +1043,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand Down Expand Up @@ -1081,7 +1077,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
count,
min,
max,
exemplars,
out _,
out _);

Expand Down Expand Up @@ -1120,6 +1115,7 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
Assert.Equal(bodyLength, data.LenBody);
}

/*
if (exemplars.Length > 0)
{
var validExemplars = exemplars.Where(exemplar => exemplar.Timestamp != default).ToList();
Expand All @@ -1141,6 +1137,7 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
AssertExemplarFilteredTagSerialization(expectedExemplar, serializedExemplar);
}
}
*/

// Check metric name, account, and namespace
var connectionStringBuilder = new ConnectionStringBuilder(exporterOptions.ConnectionString);
Expand Down Expand Up @@ -1213,6 +1210,7 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric,
Assert.Equal(dimensionsCount, dimensions.NumDimensions);
}

/*
private static void AssertExemplarFilteredTagSerialization(Exemplar expectedExemplar, SingleExemplar serializedExemplar)
{
var serializedExemplarBody = serializedExemplar.Body;
Expand Down Expand Up @@ -1262,14 +1260,16 @@ private static void AssertExemplarFilteredTagSerialization(Exemplar expectedExem
}
}
}
*/

private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter exporter)
{
var metricType = metric.MetricType;
var metricPointsEnumerator = metric.GetMetricPoints().GetEnumerator();
metricPointsEnumerator.MoveNext();
var metricPoint = metricPointsEnumerator.Current;
var exemplars = metricPoint.GetExemplars();

// var exemplars = metricPoint.GetExemplars();
UserdataV2 result = null;

if (metricType == MetricType.LongSum)
Expand All @@ -1282,7 +1282,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand All @@ -1301,7 +1300,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand All @@ -1322,7 +1320,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand All @@ -1343,7 +1340,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter
metricPoint.EndTime.ToFileTime(),
metricPoint.Tags,
metricData,
exemplars,
out _,
out _);

Expand Down Expand Up @@ -1371,7 +1367,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter
count,
min,
max,
exemplars,
out _,
out _);

Expand Down

0 comments on commit d3d9ab4

Please sign in to comment.