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

Add a config option to allow overriding Spotlight url #1659

Merged
merged 7 commits into from
Dec 11, 2023
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
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ parameters:
count: 1
path: src/Options.php

-
message: "#^Method Sentry\\\\Options\\:\\:getSpotlightUrl\\(\\) should return string but returns mixed\\.$#"
count: 1
path: src/Options.php

-
message: "#^Method Sentry\\\\Options\\:\\:getTags\\(\\) should return array\\<string, string\\> but returns mixed\\.$#"
count: 1
Expand Down
16 changes: 16 additions & 0 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,20 @@ public function enableSpotlight(bool $enable): self
return $this;
}

public function getSpotlightUrl(): string
{
return $this->options['spotlight_url'];
}

public function setSpotlightUrl(string $url): self
{
$options = array_merge($this->options, ['spotlight_url' => $url]);

$this->options = $this->resolver->resolve($options);

return $this;
}

/**
* Gets the release tag to be passed with every event sent to Sentry.
*/
Expand Down Expand Up @@ -999,6 +1013,7 @@ private function configureOptions(OptionsResolver $resolver): void
'environment' => $_SERVER['SENTRY_ENVIRONMENT'] ?? null,
'logger' => null,
'spotlight' => false,
'spotlight_url' => 'http://localhost:8969',
'release' => $_SERVER['SENTRY_RELEASE'] ?? null,
'dsn' => $_SERVER['SENTRY_DSN'] ?? null,
'server_name' => gethostname(),
Expand Down Expand Up @@ -1047,6 +1062,7 @@ private function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('in_app_include', 'string[]');
$resolver->setAllowedTypes('logger', ['null', LoggerInterface::class]);
$resolver->setAllowedTypes('spotlight', 'bool');
$resolver->setAllowedTypes('spotlight_url', 'string');
$resolver->setAllowedTypes('release', ['null', 'string']);
$resolver->setAllowedTypes('dsn', ['null', 'string', 'bool', Dsn::class]);
$resolver->setAllowedTypes('server_name', 'string');
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/HttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private function sendRequestToSpotlight(Event $event): void
try {
$spotLightResponse = SpotlightClient::sendRequest(
$request,
'http://localhost:8969/stream'
$this->options->getSpotlightUrl() . '/stream'
);

if ($spotLightResponse->hasError()) {
Expand Down
7 changes: 7 additions & 0 deletions tests/OptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ static function (): void {},
'EnableSpotlight',
];

yield [
'spotlight_url',
'http://google.com',
'getSpotlightUrl',
'setSpotlightUrl',
];

yield [
'release',
'dev',
Expand Down