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

Prometheus Exporter: Misc code review feedback #2749

Merged
merged 3 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -52,18 +52,13 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric)
{
buffer[cursor++] = unchecked((byte)'{');

int i = 0;
foreach (var tag in tags)
{
if (i++ > 0)
{
buffer[cursor++] = unchecked((byte)',');
}

cursor = WriteLabel(buffer, cursor, tag.Key, tag.Value);
buffer[cursor++] = unchecked((byte)',');
}

buffer[cursor++] = unchecked((byte)'}');
buffer[cursor - 1] = unchecked((byte)'}'); // Note: We write the '}' over the last written comma, which is extra.
}

buffer[cursor++] = unchecked((byte)' ');
Expand Down Expand Up @@ -151,18 +146,13 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric)
{
buffer[cursor++] = unchecked((byte)'{');

int i = 0;
foreach (var tag in tags)
{
if (i++ > 0)
{
buffer[cursor++] = unchecked((byte)',');
}

cursor = WriteLabel(buffer, cursor, tag.Key, tag.Value);
buffer[cursor++] = unchecked((byte)',');
}

buffer[cursor++] = unchecked((byte)'}');
buffer[cursor - 1] = unchecked((byte)'}'); // Note: We write the '}' over the last written comma, which is extra.
}

buffer[cursor++] = unchecked((byte)' ');
Expand All @@ -182,18 +172,13 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric)
{
buffer[cursor++] = unchecked((byte)'{');

int i = 0;
foreach (var tag in tags)
{
if (i++ > 0)
{
buffer[cursor++] = unchecked((byte)',');
}

cursor = WriteLabel(buffer, cursor, tag.Key, tag.Value);
buffer[cursor++] = unchecked((byte)',');
}

buffer[cursor++] = unchecked((byte)'}');
buffer[cursor - 1] = unchecked((byte)'}'); // Note: We write the '}' over the last written comma, which is extra.
}

buffer[cursor++] = unchecked((byte)' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using System;
using System.Collections.Generic;
using OpenTelemetry.Internal;

namespace OpenTelemetry.Exporter
{
Expand Down Expand Up @@ -65,10 +66,7 @@ public int ScrapeResponseCacheDurationMilliseconds
get => this.scrapeResponseCacheDurationMilliseconds;
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(value), "Value should be greater than or equal to zero.");
}
Guard.Range(value, nameof(value), min: 0);

this.scrapeResponseCacheDurationMilliseconds = value;
}
Expand Down