Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Exporter.Geneva] Fix serialization issue when there are no exemplars #1099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ internal unsafe ushort SerializeMetricWithTLV(

MetricSerializer.SerializeByte(this.buffer, ref bufferIndex, 0); // version

// TODO: Avoid this additional enumeration
var exemplarsCount = 0;
foreach (var exemplar in exemplars)
{
Expand All @@ -630,10 +631,10 @@ internal unsafe ushort SerializeMetricWithTLV(
this.SerializeExemplar(exemplar, ref bufferIndex);
}
}
}

payloadTypeLength = (ushort)(bufferIndex - payloadTypeStartIndex - 2);
MetricSerializer.SerializeUInt16(this.buffer, ref payloadTypeStartIndex, payloadTypeLength);
payloadTypeLength = (ushort)(bufferIndex - payloadTypeStartIndex - 2);
MetricSerializer.SerializeUInt16(this.buffer, ref payloadTypeStartIndex, payloadTypeLength);
}

#endregion

Expand Down Expand Up @@ -817,6 +818,7 @@ internal unsafe ushort SerializeHistogramMetricWithTLV(

MetricSerializer.SerializeByte(this.buffer, ref bufferIndex, 0); // version

// TODO: Avoid this additional enumeration
var exemplarsCount = 0;
foreach (var exemplar in exemplars)
{
Expand All @@ -835,10 +837,10 @@ internal unsafe ushort SerializeHistogramMetricWithTLV(
this.SerializeExemplar(exemplar, ref bufferIndex);
}
}
}

payloadTypeLength = (ushort)(bufferIndex - payloadTypeStartIndex - 2);
MetricSerializer.SerializeUInt16(this.buffer, ref payloadTypeStartIndex, payloadTypeLength);
payloadTypeLength = (ushort)(bufferIndex - payloadTypeStartIndex - 2);
MetricSerializer.SerializeUInt16(this.buffer, ref payloadTypeStartIndex, payloadTypeLength);
}

#endregion

Expand Down Expand Up @@ -913,7 +915,7 @@ private void SerializeExemplar(Exemplar exemplar, ref int bufferIndex)

var flags = ExemplarFlags.IsTimestampAvailable; // we only serialize exemplars with Timestamp != default

// TODO: Update the code whenn Exemplars support long values
// TODO: Update the code when Exemplars support long values
var value = exemplar.DoubleValue;

// Check if the double value is actually a whole number that can be serialized as a long instead
Expand Down
Loading