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

Remove space between labels #14

Merged
merged 1 commit into from
Jul 16, 2024
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
2 changes: 1 addition & 1 deletion src/Collections/LabelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ static function ( ProvidesNamedValue $label )
$this->labels
);

return '{' . implode( ', ', $labelStrings ) . '}';
return '{' . implode( ',', $labelStrings ) . '}';
}
}
8 changes: 4 additions & 4 deletions tests/Integration/OpenMetrics/PythonParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ private function assertParsedMetricOutput( string $expectedParserOutput, Provide
public function testCanParseGaugeMetricsWithPythonParser() : void
{
$expectedParserOutput = "Name: gauge Labels: {'foo': 'bar'} Value: 1.01 Timestamp: 1234567.000000000\n"
. "Name: gauge Labels: {'bar': 'foo'} Value: 2.0202 Timestamp: 1234567.000000000\n"
. "Name: gauge Labels: {'foobar': 'foo', 'bar': 'foo'} Value: 2.0202 Timestamp: 1234567.000000000\n"
. "Name: gauge Labels: {} Value: 3.0302 Timestamp: None\n";

$collection = GaugeCollection::fromGauges(
MetricName::fromString( 'gauge' ),
Gauge::fromValueAndTimestamp( 1.01, 1234567 )->withLabels(
Label::fromNameAndValue( 'foo', 'bar' )
),
Gauge::fromValueAndTimestamp( 2.0202, 1234567 )->withLabels(
Label::fromNameAndValue( 'bar', 'foo' )
),
Gauge::fromValueAndTimestamp( 2.0202, 1234567 )
->withLabels(Label::fromNameAndValue( 'foobar', 'foo' ))
->withLabels(Label::fromNameAndValue( 'bar', 'foo' ) ),
Gauge::fromValue( 3.0302 )
);

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Collections/LabelCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testCanGetLabelsAsCombinedLabelString() : void
/** @var ProvidesNamedValue $secondLabelStub */
$collection->add( $secondLabelStub );

$this->assertSame( '{name1="value1", name2="value2"}', $collection->getCombinedLabelString() );
$this->assertSame( '{name1="value1",name2="value2"}', $collection->getCombinedLabelString() );
}

/**
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testCanAddMultipleLabels() : void
$collection->add( $firstLabelStub, $secondLabelStub );

$this->assertCount( 2, $collection );
$this->assertSame( '{name1="value1", name2="value2"}', $collection->getCombinedLabelString() );
$this->assertSame( '{name1="value1",name2="value2"}', $collection->getCombinedLabelString() );
}

/**
Expand All @@ -158,7 +158,7 @@ public function testCanGetInstanceFromAssocArray() : void

$this->assertCount( 2, $labels );

$expectedLabelString = '{unit="test", test="unit"}';
$expectedLabelString = '{unit="test",test="unit"}';

$this->assertSame( $expectedLabelString, $labels->getCombinedLabelString() );
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Metrics/CounterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testAddLabels() : void
{
$expectedSampleStringWithoutLabels = '_total 1.000000';
$expectedSampleStringWithOneLabel = '_total{unit_test="123"} 1.000000';
$expectedSampleStringWithThreeLabels = '_total{unit_test="123", test_unit="456", label_last="789"} 1.000000';
$expectedSampleStringWithThreeLabels = '_total{unit_test="123",test_unit="456",label_last="789"} 1.000000';

$gauge = Counter::fromValue( 1 );

Expand Down Expand Up @@ -99,7 +99,7 @@ public function testCanGetCounterWithLabels() : void
Label::fromNameAndValue( 'test', 'unit' )
);

$expectedSampleString = '_total{unit="test", test="unit"} 12.300000';
$expectedSampleString = '_total{unit="test",test="unit"} 12.300000';

$this->assertSame( $expectedSampleString, $gauge->getSampleString() );
}
Expand All @@ -121,7 +121,7 @@ public function testCanGetCounterWithLabelCollection() : void
)
);

$expectedSampleString = '_total{unit="test", test="unit"} 12.300000';
$expectedSampleString = '_total{unit="test",test="unit"} 12.300000';

$this->assertSame( $expectedSampleString, $gauge->getSampleString() );
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Metrics/GaugeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testAddLabels() : void
{
$expectedSampleStringWithoutLabels = ' 1.230000';
$expectedSampleStringWithOneLabel = '{unit_test="123"} 1.230000';
$expectedSampleStringWithThreeLabels = '{unit_test="123", test_unit="456", label_last="789"} 1.230000';
$expectedSampleStringWithThreeLabels = '{unit_test="123",test_unit="456",label_last="789"} 1.230000';

$gauge = Gauge::fromValue( 1.23 );

Expand Down Expand Up @@ -97,7 +97,7 @@ public function testCanGetGaugeWithLabels() : void
Label::fromNameAndValue( 'test', 'unit' )
);

$expectedSampleString = '{unit="test", test="unit"} 12.300000';
$expectedSampleString = '{unit="test",test="unit"} 12.300000';

$this->assertSame( $expectedSampleString, $gauge->getSampleString() );
}
Expand All @@ -120,7 +120,7 @@ public function testCanGetGaugeWithLabelCollection() : void
)
);

$expectedSampleString = '{unit="test", test="unit"} 12.300000';
$expectedSampleString = '{unit="test",test="unit"} 12.300000';

$this->assertSame( $expectedSampleString, $gauge->getSampleString() );
}
Expand Down