Skip to content

Commit

Permalink
Use AWS_LAMBDA_FUNCTION_VERSION env var for release if available (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive authored May 24, 2024
1 parent 8761545 commit 2ceeca4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ private function configureOptions(OptionsResolver $resolver): void
'logger' => null,
'spotlight' => false,
'spotlight_url' => 'http://localhost:8969',
'release' => $_SERVER['SENTRY_RELEASE'] ?? null,
'release' => $_SERVER['SENTRY_RELEASE'] ?? $_SERVER['AWS_LAMBDA_FUNCTION_VERSION'] ?? null,
'dsn' => $_SERVER['SENTRY_DSN'] ?? null,
'server_name' => gethostname(),
'ignore_exceptions' => [],
Expand Down
21 changes: 21 additions & 0 deletions tests/OptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,27 @@ public function testReleaseOptionDefaultValueIsGotFromEnvironmentVariable(): voi
$this->assertSame('0.0.1', (new Options())->getRelease());
}

/**
* @backupGlobals enabled
*/
public function testReleaseOptionDefaultValueIsGotFromLambdaEnvironmentVariable(): void
{
$_SERVER['AWS_LAMBDA_FUNCTION_VERSION'] = '0.0.2';

$this->assertSame('0.0.2', (new Options())->getRelease());
}

/**
* @backupGlobals enabled
*/
public function testReleaseOptionDefaultValueIsPreferredFromSentryEnvironmentVariable(): void
{
$_SERVER['AWS_LAMBDA_FUNCTION_VERSION'] = '0.0.3';
$_SERVER['SENTRY_RELEASE'] = '0.0.4';

$this->assertSame('0.0.4', (new Options())->getRelease());
}

public function testErrorTypesOptionIsNotDynamiclyReadFromErrorReportingLevelWhenSet(): void
{
$errorReportingBeforeTest = error_reporting(\E_ERROR);
Expand Down

0 comments on commit 2ceeca4

Please sign in to comment.