markTestSkipped('The OpenTelemetry API is not installed.'); } } /** * @group disconnected */ public function testBuildAttributesAddsBaseAttributes(): void { $collector = new MetricsCollector($this->createMock(MeterInterface::class), new MetricsConfig()); $this->assertSame( ['db.namespace' => '0', 'db.system.name' => 'redis', 'redis.client.library' => 'predis:' . Client::VERSION], $collector->buildAttributes(['db.namespace' => '0']) ); } /** * @group disconnected */ public function testCustomAttributesWinOverBuiltInOnes(): void { $config = new MetricsConfig(['custom_attributes' => ['env' => 'test', 'db.system.name' => 'other']]); $collector = new MetricsCollector($this->createMock(MeterInterface::class), $config); $attributes = $collector->buildAttributes(['db.namespace' => '0']); $this->assertSame('test', $attributes['env']); $this->assertSame('other', $attributes['db.system.name']); $this->assertSame('0', $attributes['db.namespace']); $this->assertSame('predis:' . Client::VERSION, $attributes['redis.client.library']); } }