Skip to content

Commit 1d2189a

Browse files
committed
chore: remove resource.name
1 parent 6e87dcf commit 1d2189a

File tree

2 files changed

+15
-73
lines changed

2 files changed

+15
-73
lines changed

src/Instrumentation/Symfony/src/MessengerInstrumentation.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -503,23 +503,6 @@ public static function register(): void
503503
}
504504
}
505505

506-
private static function buildResourceName(string $messageClass, ?string $transportName = null, ?string $operation = null): string
507-
{
508-
if (empty($transportName)) {
509-
return $messageClass;
510-
}
511-
512-
if ($operation === 'send') {
513-
return \sprintf('%s -> %s', $messageClass, $transportName);
514-
}
515-
516-
if ($operation === 'receive' || $operation === 'consume') {
517-
return \sprintf('%s -> %s', $transportName, $messageClass);
518-
}
519-
520-
return \sprintf('%s -> %s', $messageClass, $transportName);
521-
}
522-
523506
private static function addMessageStampsToSpan(SpanBuilderInterface $builder, Envelope $envelope): void
524507
{
525508
$busStamp = $envelope->last(BusNameStamp::class);
@@ -584,8 +567,5 @@ private static function addMessageStampsToSpan(SpanBuilderInterface $builder, En
584567
$builder->setAttribute(self::ATTRIBUTE_MESSAGING_MESSAGE_ID, $amazonSqsReceivedStamp->getId());
585568
}
586569
}
587-
588-
// Set resource name
589-
$builder->setAttribute('resource.name', self::buildResourceName($messageClass, $transportName, $operation));
590570
}
591571
}

src/Instrumentation/Symfony/tests/Integration/MessengerInstrumentationTest.php

Lines changed: 15 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -289,60 +289,22 @@ public function test_stamp_information()
289289
$this->assertArrayHasKey('Symfony\Component\Messenger\Stamp\TransportMessageIdStamp', $stamps);
290290
}
291291

292-
public function test_resource_names()
292+
public function test_throw_exception(): void
293293
{
294-
$transport = $this->getTransport();
295-
$message = new SendEmailMessage('Hello Again');
296-
297-
// Test send operation
298-
$envelope = new Envelope($message, [
299-
new \Symfony\Component\Messenger\Stamp\SentStamp('test_transport', 'TestSender'),
300-
]);
301-
$transport->send($envelope);
302-
303-
$this->assertCount(1, $this->storage);
304-
$sendSpan = $this->storage[0];
305-
$this->assertTrue($sendSpan->getAttributes()->has('resource.name'));
306-
$this->assertEquals(
307-
'OpenTelemetry\Tests\Instrumentation\Symfony\tests\Integration\SendEmailMessage -> TestSender',
308-
$sendSpan->getAttributes()->get('resource.name')
309-
);
310-
311-
// Clear storage for next test
312-
$this->storage = new ArrayObject();
313-
314-
// Test receive operation
315-
$envelope = new Envelope($message, [
316-
new \Symfony\Component\Messenger\Stamp\ReceivedStamp('test_transport'),
317-
]);
318-
319-
// First send the message to the transport
320-
$transport->send($envelope);
321-
322-
// Create a worker and handle the message
323-
$bus = $this->getMessenger();
324-
$worker = new \Symfony\Component\Messenger\Worker(
325-
['test_transport' => $transport],
326-
$bus
327-
);
328-
329-
// Get and handle the message
330-
$messages = iterator_to_array($transport->get());
331-
$receivedEnvelope = $messages[0];
332-
333-
// Use reflection to call the protected handleMessage method
334-
$reflection = new \ReflectionClass($worker);
335-
$handleMessageMethod = $reflection->getMethod('handleMessage');
336-
$handleMessageMethod->setAccessible(true);
337-
$handleMessageMethod->invoke($worker, $receivedEnvelope, 'test_transport');
338-
339-
$this->assertCount(1, $this->storage);
340-
$receiveSpan = $this->storage[0];
341-
$this->assertTrue($receiveSpan->getAttributes()->has('resource.name'));
342-
$this->assertEquals(
343-
'test_transport -> OpenTelemetry\Tests\Instrumentation\Symfony\tests\Integration\SendEmailMessage',
344-
$receiveSpan->getAttributes()->get('resource.name')
345-
);
294+
$this->expectException(\RuntimeException::class);
295+
$this->expectExceptionMessage('test');
296+
297+
$bus = $this->getBus(__FUNCTION__);
298+
$bus->dispatch(new TestMessage());
299+
}
300+
301+
public function test_throw_exception_with_retry(): void
302+
{
303+
$this->expectException(\RuntimeException::class);
304+
$this->expectExceptionMessage('test');
305+
306+
$bus = $this->getBus(__FUNCTION__);
307+
$bus->dispatch(new TestMessageWithRetry());
346308
}
347309

348310
public function sendDataProvider(): array

0 commit comments

Comments
 (0)