-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compliance tests for environment variables (#648)
* Add compliance tests for environment variables * Add tests to verify compliance * Add Makefile task for testing compliance
- Loading branch information
Showing
2 changed files
with
138 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\Tests\Integration\SDK; | ||
|
||
use AssertWell\PHPUnitGlobalState\EnvironmentVariables; | ||
use OpenTelemetry\SDK\Trace\SpanLimitsBuilder; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SpanLimitsBuilderTest extends TestCase | ||
{ | ||
use EnvironmentVariables; | ||
|
||
public function tearDown(): void | ||
{ | ||
$this->restoreEnvironmentVariables(); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_length_limits_builder_uses_environment_variable(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT', 9); | ||
$builder = new SpanLimitsBuilder(); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(9, $spanLimits->getAttributeLimits()->getAttributeValueLengthLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_length_limits_builder_uses_configured_value(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT', 9); | ||
$builder = new SpanLimitsBuilder(); | ||
$builder->setAttributeValueLengthLimit(201); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(201, $spanLimits->getAttributeLimits()->getAttributeValueLengthLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_event_limits_builder_uses_environment_variable(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_SPAN_EVENT_COUNT_LIMIT', 200); | ||
$builder = new SpanLimitsBuilder(); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(200, $spanLimits->getEventCountLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_event_limits_builder_uses_configured_value(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_SPAN_EVENT_COUNT_LIMIT', 200); | ||
$builder = new SpanLimitsBuilder(); | ||
$builder->setEventCountLimit(185); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(185, $spanLimits->getEventCountLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_limits_link_builder_uses_environment_variable(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_SPAN_LINK_COUNT_LIMIT', 1101); | ||
$builder = new SpanLimitsBuilder(); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(1101, $spanLimits->getLinkCountLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_limits_link_builder_uses_configured_value(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_SPAN_LINK_COUNT_LIMIT', 1102); | ||
$builder = new SpanLimitsBuilder(); | ||
$builder->setLinkCountLimit(193); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(193, $spanLimits->getLinkCountLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_attribute_per_event_count_limits_builder_uses_environment_variable(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 400); | ||
$builder = new SpanLimitsBuilder(); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(400, $spanLimits->getAttributePerEventCountLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_event_attribute_per_event_count_limits_builder_uses_configured_value(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 400); | ||
$builder = new SpanLimitsBuilder(); | ||
$builder->setAttributePerEventCountLimit(155); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(155, $spanLimits->getAttributePerEventCountLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_attribute_per_link_count_limits_builder_uses_environment_variable(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', 500); | ||
$builder = new SpanLimitsBuilder(); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(500, $spanLimits->getAttributePerLinkCountLimit()); | ||
} | ||
|
||
/** | ||
* @group trace-compliance | ||
*/ | ||
public function test_span_link_attribute_per_event_count_limits_builder_uses_configured_value(): void | ||
{ | ||
$this->setEnvironmentVariable('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', 500); | ||
$builder = new SpanLimitsBuilder(); | ||
$builder->setAttributePerLinkCountLimit(450); | ||
$spanLimits = $builder->build(); | ||
$this->assertEquals(450, $spanLimits->getAttributePerLinkCountLimit()); | ||
} | ||
} |