@@ -1538,21 +1538,14 @@ NR_INNER_WRAPPER(memcached_add_server) {
1538
1538
nr_string_len_t host_len = 0 ;
1539
1539
zend_long port = 0 ;
1540
1540
zend_long weight = 0 ;
1541
- nr_datastore_instance_t * instance = NULL ;
1542
- char * instance_metric = NULL ;
1543
1541
int zcaught = 0 ;
1544
1542
1545
1543
if (SUCCESS
1546
1544
== zend_parse_parameters_ex (
1547
1545
ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "s|ll" , & host ,
1548
1546
& host_len , & port , & weight ) &&
1549
1547
NULL != host ) {
1550
- instance = nr_php_memcached_create_datastore_instance (host , port );
1551
- instance_metric = nr_formatf ("Datastore/instance/Memcached/%s/%s" ,
1552
- instance -> host , instance -> port_path_or_id );
1553
- nrm_force_add (NRPRG (txn )-> unscoped_metrics , instance_metric , 0 );
1554
- nr_datastore_instance_destroy (& instance );
1555
- nr_free (instance_metric );
1548
+ nr_php_memcached_create_instance_metric (host , port );
1556
1549
}
1557
1550
zcaught = nr_zend_call_old_handler (nr_wrapper -> oldhandler ,
1558
1551
INTERNAL_FUNCTION_PARAM_PASSTHRU );
@@ -1565,8 +1558,6 @@ NR_INNER_WRAPPER(memcached_add_server) {
1565
1558
NR_INNER_WRAPPER (memcached_add_servers ) {
1566
1559
zval * servers = NULL ;
1567
1560
zval * server = NULL ;
1568
- nr_datastore_instance_t * instance = NULL ;
1569
- char * instance_metric = NULL ;
1570
1561
int zcaught = 0 ;
1571
1562
1572
1563
if (SUCCESS
@@ -1576,14 +1567,9 @@ NR_INNER_WRAPPER(memcached_add_servers) {
1576
1567
ZEND_HASH_FOREACH_VAL (Z_ARRVAL_P (servers ), server ) {
1577
1568
zval * host = nr_php_zend_hash_index_find (Z_ARRVAL_P (server ), 0 );
1578
1569
zval * port = nr_php_zend_hash_index_find (Z_ARRVAL_P (server ), 1 );
1579
- if (NULL != host && NULL != port &&
1580
- Z_TYPE_P (host ) == IS_STRING && Z_TYPE_P (port ) == IS_LONG ) {
1581
- instance = nr_php_memcached_create_datastore_instance (Z_STRVAL_P (host ), Z_LVAL_P (port ));
1582
- instance_metric = nr_formatf ("Datastore/instance/Memcached/%s/%s" ,
1583
- instance -> host , instance -> port_path_or_id );
1584
- nrm_force_add (NRPRG (txn )-> unscoped_metrics , instance_metric , 0 );
1585
- nr_datastore_instance_destroy (& instance );
1586
- nr_free (instance_metric );
1570
+ if (nr_php_is_zval_valid_string (host ) &&
1571
+ nr_php_is_zval_valid_integer (port )) {
1572
+ nr_php_memcached_create_instance_metric (Z_STRVAL_P (host ), Z_LVAL_P (port ));
1587
1573
}
1588
1574
}
1589
1575
ZEND_HASH_FOREACH_END ();
0 commit comments