Skip to content

Commit 6c3eb0e

Browse files
authored
fix(logs): use server.address instead of sentry.server.address (#2040)
1 parent 1532647 commit 6c3eb0e

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Logs/LogsAggregator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function add(
7979
$log = (new Log($timestamp, $traceId, $level, $formattedMessage))
8080
->setAttribute('sentry.release', $options->getRelease())
8181
->setAttribute('sentry.environment', $options->getEnvironment() ?? Event::DEFAULT_ENVIRONMENT)
82-
->setAttribute('sentry.server.address', $options->getServerName())
82+
->setAttribute('server.address', $options->getServerName())
8383
->setAttribute('sentry.trace.parent_span_id', $parentSpanId);
8484

8585
if ($client instanceof Client) {

tests/Logs/LogsAggregatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testAttributes(array $attributes, array $expected): void
5454
$log->attributes()->toSimpleArray(),
5555
static function (string $key) {
5656
// We are not testing internal Sentry attributes here, only the ones the user supplied
57-
return !str_starts_with($key, 'sentry.');
57+
return !str_starts_with($key, 'sentry.') && $key !== 'server.address';
5858
},
5959
\ARRAY_FILTER_USE_KEY
6060
)
@@ -200,7 +200,7 @@ public function testAttributesAreAddedToLogMessage(): void
200200

201201
$this->assertSame('1.0.0', $attributes->get('sentry.release')->getValue());
202202
$this->assertSame('production', $attributes->get('sentry.environment')->getValue());
203-
$this->assertSame('web-server-01', $attributes->get('sentry.server.address')->getValue());
203+
$this->assertSame('web-server-01', $attributes->get('server.address')->getValue());
204204
$this->assertSame('User %s performed action %s', $attributes->get('sentry.message.template')->getValue());
205205
$this->assertSame('566e3688a61d4bc8', $attributes->get('sentry.trace.parent_span_id')->getValue());
206206
$this->assertSame('sentry.php', $attributes->get('sentry.sdk.name')->getValue());

tests/Monolog/LogsHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testHandle($record, Log $expectedLog): void
5454
$log->attributes()->toSimpleArray(),
5555
static function (string $key) {
5656
// We are not testing Sentry's own attributes here, only the ones the user supplied so filter them out of the expected attributes
57-
return !str_starts_with($key, 'sentry.');
57+
return !str_starts_with($key, 'sentry.') && $key !== 'server.address';
5858
},
5959
\ARRAY_FILTER_USE_KEY
6060
)

0 commit comments

Comments
 (0)