Skip to content

Commit 49d4f28

Browse files
committed
Changed the name to meet OTEL instrumentation uses
1 parent 064518f commit 49d4f28

9 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/Instrumentation/Magento2/src/Magento2Instrumentation.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static function register(): void
6363
pre: static function (Bootstrap $bootstrap, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) {
6464
$exception = $params[0] instanceof Throwable ? $params[0] : null;
6565
$span = $instrumentation->tracer()
66-
->spanBuilder('Bootstrap::terminate')
66+
->spanBuilder('bootstrap.terminate')
6767
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
6868
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
6969
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)
@@ -182,7 +182,7 @@ public static function register(): void
182182
'dispatch',
183183
pre: static function (FrontController $frontController, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) {
184184
$span = $instrumentation->tracer()
185-
->spanBuilder('FrontController.dispatch')
185+
->spanBuilder('frontController.dispatch')
186186
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
187187
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
188188
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)
@@ -214,7 +214,7 @@ public static function register(): void
214214
/** @var non-empty-string $actionName */
215215
$actionName = $request?->getFullActionName() ?? 'unknown';
216216
$span = $instrumentation->tracer()
217-
->spanBuilder($actionName)
217+
->spanBuilder('action.dispatch ' . $actionName)
218218
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
219219
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
220220
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)
@@ -242,7 +242,7 @@ public static function register(): void
242242
'execute',
243243
pre: static function (ActionInterface $actionInterface, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) {
244244
$span = $instrumentation->tracer()
245-
->spanBuilder('ActionInterface.execute')
245+
->spanBuilder('actionInterface.execute')
246246
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
247247
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
248248
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)
@@ -268,9 +268,9 @@ public static function register(): void
268268
Manager::class,
269269
'dispatch',
270270
pre: static function (Manager $manager, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) {
271-
$eventName = (string) ($params[0]);
271+
$eventName = is_string($params[0]) && $params[0] !== '' ? $params[0] : 'unknown';
272272
$span = $instrumentation->tracer()
273-
->spanBuilder('EVENT: ' . $eventName)
273+
->spanBuilder('event.dispatch ' . $eventName)
274274
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
275275
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
276276
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)
@@ -297,7 +297,7 @@ public static function register(): void
297297
? $configuration['name']
298298
: 'unknown';
299299
$span = $instrumentation->tracer()
300-
->spanBuilder('OBSERVER: ' . $observerName)
300+
->spanBuilder('observer ' . $observerName)
301301
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
302302
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
303303
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)
@@ -321,7 +321,7 @@ public static function register(): void
321321
pre: static function (Template $template, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) {
322322
$filename = is_string($params[0]) ? $params[0] : null;
323323
$span = $instrumentation->tracer()
324-
->spanBuilder('TEMPLATE: ' . ($filename ?? 'unknown'))
324+
->spanBuilder('template ' . ($filename ?? 'unknown'))
325325
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
326326
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
327327
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)
@@ -348,7 +348,7 @@ public static function register(): void
348348
'renderLayout',
349349
pre: static function (View $view, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) {
350350
$span = $instrumentation->tracer()
351-
->spanBuilder('LAYOUT: layout_render')
351+
->spanBuilder('view.render.layout')
352352
->setAttribute(CodeAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
353353
->setAttribute(CodeAttributes::CODE_FILE_PATH, $filename)
354354
->setAttribute(CodeAttributes::CODE_LINE_NUMBER, $lineno)

src/Instrumentation/Magento2/tests/Unit/ActionInterfaceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function test_execute_records_span_and_code_attributes(): void
131131

132132
/** @var ImmutableSpan $span */
133133
$span = $this->storage[0];
134-
$this->assertSame('ActionInterface.execute', $span->getName());
134+
$this->assertSame('actionInterface.execute', $span->getName());
135135

136136
$attributes = $span->getAttributes()->toArray();
137137
$this->assertArrayHasKey(CodeAttributes::CODE_FUNCTION_NAME, $attributes);
@@ -178,7 +178,7 @@ public function test_execute_records_exception_event(): void
178178

179179
/** @var ImmutableSpan $span */
180180
$span = $this->storage[0];
181-
$this->assertSame('ActionInterface.execute', $span->getName());
181+
$this->assertSame('actionInterface.execute', $span->getName());
182182

183183
$events = $span->getEvents();
184184
$this->assertCount(1, $events);

src/Instrumentation/Magento2/tests/Unit/ActionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function test_dispatch_span_name_uses_full_action_name(): void
162162

163163
$this->action->dispatch($this->httpRequest);
164164

165-
$this->assertSame('catalog_product_view', $this->getSingleSpan()->getName());
165+
$this->assertSame('action.dispatch catalog_product_view', $this->getSingleSpan()->getName());
166166
}
167167

168168
/**
@@ -178,7 +178,7 @@ public function test_dispatch_span_name_falls_back_to_unknown_when_null(): void
178178

179179
$this->action->dispatch($this->httpRequest);
180180

181-
$this->assertSame('unknown', $this->getSingleSpan()->getName());
181+
$this->assertSame('action.dispatch unknown', $this->getSingleSpan()->getName());
182182
}
183183

184184
/**

src/Instrumentation/Magento2/tests/Unit/BootstrapTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function test_terminate_records_span_and_exception_attributes(): void
208208
$this->assertInstanceOf(ImmutableSpan::class, $this->storage[0]);
209209
/** @var ImmutableSpan $span */
210210
$span = $this->storage[0];
211-
$this->assertSame('Bootstrap::terminate', $span->getName());
211+
$this->assertSame('bootstrap.terminate', $span->getName());
212212

213213
$attributes = $span->getAttributes()->toArray();
214214
$this->assertArrayHasKey(CodeAttributes::CODE_FUNCTION_NAME, $attributes);

src/Instrumentation/Magento2/tests/Unit/FrontControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function testDispatchThrowException(): void
183183
$this->assertInstanceOf(ImmutableSpan::class, $this->storage[0]);
184184
/** @var ImmutableSpan $span */
185185
$span = $this->storage[0];
186-
$this->assertSame('FrontController.dispatch', $span->getName());
186+
$this->assertSame('frontController.dispatch', $span->getName());
187187

188188
$attributes = $span->getAttributes()->toArray();
189189
$this->assertArrayHasKey(CodeAttributes::CODE_FUNCTION_NAME, $attributes);
@@ -280,7 +280,7 @@ function (string $arg1): ?AreaInterface {
280280

281281
// FrontController.dispatch + ActionInterface.execute
282282
$this->assertCount(2, $this->storage);
283-
$frontControllerSpan = $this->findSpanByName('FrontController.dispatch');
283+
$frontControllerSpan = $this->findSpanByName('frontController.dispatch');
284284
$this->assertNotNull($frontControllerSpan);
285285

286286
$attributes = $frontControllerSpan->getAttributes()->toArray();

src/Instrumentation/Magento2/tests/Unit/InvokerInterfaceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function test_dispatch_records_observer_span_name_and_code_attributes():
6464
$this->assertInstanceOf(ImmutableSpan::class, $this->storage[0]);
6565
/** @var ImmutableSpan $span */
6666
$span = $this->storage[0];
67-
$this->assertSame('OBSERVER: checkout_cart_product_add_after', $span->getName());
67+
$this->assertSame('observer checkout_cart_product_add_after', $span->getName());
6868

6969
$attrs = $span->getAttributes()->toArray();
7070
$this->assertArrayHasKey(CodeAttributes::CODE_FUNCTION_NAME, $attrs);
@@ -90,6 +90,6 @@ public function test_dispatch_uses_unknown_name_when_configuration_name_is_missi
9090
$this->assertInstanceOf(ImmutableSpan::class, $this->storage[0]);
9191
/** @var ImmutableSpan $span */
9292
$span = $this->storage[0];
93-
$this->assertSame('OBSERVER: unknown', $span->getName());
93+
$this->assertSame('observer unknown', $span->getName());
9494
}
9595
}

src/Instrumentation/Magento2/tests/Unit/ManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function test_dispatch_records_event_span_name_and_code_attributes(): voi
6363
$this->assertInstanceOf(ImmutableSpan::class, $this->storage[0]);
6464
/** @var ImmutableSpan $span */
6565
$span = $this->storage[0];
66-
$this->assertSame('EVENT: catalog_controller_product_view', $span->getName());
66+
$this->assertSame('event.dispatch catalog_controller_product_view', $span->getName());
6767

6868
$attrs = $span->getAttributes()->toArray();
6969
$this->assertArrayHasKey(CodeAttributes::CODE_FUNCTION_NAME, $attrs);

src/Instrumentation/Magento2/tests/Unit/TemplateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function test_fetch_view_records_template_span_and_code_attributes(): voi
6868
$this->assertInstanceOf(ImmutableSpan::class, $this->storage[0]);
6969
/** @var ImmutableSpan $span */
7070
$span = $this->storage[0];
71-
$this->assertSame('TEMPLATE: ' . $templateFile, $span->getName());
71+
$this->assertSame('template ' . $templateFile, $span->getName());
7272
$this->assertCount(0, $span->getEvents());
7373

7474
$attrs = $span->getAttributes()->toArray();

src/Instrumentation/Magento2/tests/Unit/ViewTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function test_render_layout_records_layout_span_and_code_attributes(): vo
6666
$this->assertInstanceOf(ImmutableSpan::class, $this->storage[0]);
6767
/** @var ImmutableSpan $span */
6868
$span = $this->storage[0];
69-
$this->assertSame('LAYOUT: layout_render', $span->getName());
69+
$this->assertSame('view.render.layout', $span->getName());
7070
$this->assertCount(0, $span->getEvents());
7171

7272
$attrs = $span->getAttributes()->toArray();

0 commit comments

Comments
 (0)