Skip to content

Make DB connection name configurable #14

@ravage84

Description

@ravage84

Currently, we hardcoded the DB connectoin name to default which makes sense in 99 % of the cases for most applications.
But we should make the DB connection name configurable through a config setting, so we can a) check connectons other than default and b) re-use the sensor for checking multiple connections (where available).

For this, I propose a new sensor config sub key called config or settings for providing sensor classes with such dynamic data.

This can then be used like this to check muliple DB connections in the same application:

$config['App']['Heartbeat'] = [
    'name' => 'My App',
    'layout' => 'heartbeat',
    'Sensors' => [
        'Default DB Connection' => [
            'enabled' => true,
            'severity' => 3,
            'class' => OrcaServices\Heartbeat\Heartbeat\Sensor\DBConnection::class,
            'cached' => true,
            'config' => [
                'connection_name' => 'default',
            ],
        ],
        'ORACLE DB Connection' => [
            'enabled' => true,
            'severity' => 2,
            'class' => OrcaServices\Heartbeat\Heartbeat\Sensor\DBConnection::class,
            'cached' => true,
            'config' => [
                'connection_name' => 'oracle',
            ],
        ],
        'Some Other DB Connection' => [
            'enabled' => true,
            'severity' => 2,
            'class' => OrcaServices\Heartbeat\Heartbeat\Sensor\DBConnection::class,
            'cached' => false,
            'config' => [
                'connection_name' => 'some_other',
            ],
        ],
    ],
];

@orca-services/developers what do you think of this enhancement?

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions