Skip to content

Commit 5ca4df6

Browse files
committed
remove old code
1 parent 8c07bd8 commit 5ca4df6

File tree

4 files changed

+31
-80
lines changed

4 files changed

+31
-80
lines changed

agent/php_internal_instrument.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@ static void nr_php_instrument_datastore_operation_call(
770770
nr_datastore_t datastore,
771771
const char* operation,
772772
nr_datastore_instance_t* instance,
773-
bool instance_only,
774773
INTERNAL_FUNCTION_PARAMETERS) {
775774
int zcaught = 0;
776775
nr_segment_t* segment = NULL;
@@ -780,7 +779,6 @@ static void nr_php_instrument_datastore_operation_call(
780779
},
781780
.operation = nr_strdup(operation),
782781
.instance = instance,
783-
.instance_only = instance_only,
784782
.callbacks = {
785783
.backtrace = nr_php_backtrace_callback,
786784
},
@@ -836,7 +834,7 @@ NR_INNER_WRAPPER(mysqli_commit) {
836834
}
837835

838836
nr_php_instrument_datastore_operation_call(nr_wrapper, NR_DATASTORE_MYSQL,
839-
"commit", instance, false,
837+
"commit", instance,
840838
INTERNAL_FUNCTION_PARAM_PASSTHRU);
841839
}
842840

@@ -1531,7 +1529,7 @@ NR_INNER_WRAPPER(mysqli_stmt_prepare) {
15311529
*/
15321530
NR_INNER_WRAPPER(memcache_function) {
15331531
nr_php_instrument_datastore_operation_call(nr_wrapper, NR_DATASTORE_MEMCACHE,
1534-
nr_wrapper->extra, NULL, false,
1532+
nr_wrapper->extra, NULL,
15351533
INTERNAL_FUNCTION_PARAM_PASSTHRU);
15361534
}
15371535

@@ -1627,7 +1625,7 @@ NR_INNER_WRAPPER(redis_connect) {
16271625
}
16281626

16291627
nr_php_instrument_datastore_operation_call(nr_wrapper, NR_DATASTORE_REDIS,
1630-
nr_wrapper->extra, instance, false,
1628+
nr_wrapper->extra, instance,
16311629
INTERNAL_FUNCTION_PARAM_PASSTHRU);
16321630
}
16331631

@@ -1686,7 +1684,7 @@ NR_INNER_WRAPPER(redis_function) {
16861684
instance = nr_php_redis_retrieve_datastore_instance(this_obj TSRMLS_CC);
16871685

16881686
nr_php_instrument_datastore_operation_call(nr_wrapper, NR_DATASTORE_REDIS,
1689-
nr_wrapper->extra, instance, false,
1687+
nr_wrapper->extra, instance,
16901688
INTERNAL_FUNCTION_PARAM_PASSTHRU);
16911689
}
16921690

@@ -2679,7 +2677,7 @@ NR_INNER_WRAPPER(ob_flush_common) {
26792677
*/
26802678
NR_INNER_WRAPPER(mongodb_execute) {
26812679
nr_php_instrument_datastore_operation_call(nr_wrapper, NR_DATASTORE_MONGODB,
2682-
"execute", NULL, false,
2680+
"execute", NULL,
26832681
INTERNAL_FUNCTION_PARAM_PASSTHRU);
26842682
}
26852683

axiom/nr_segment_datastore.c

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,6 @@
1212
#include "util_sql.h"
1313
#include "util_logging.h"
1414

15-
static nr_status_t create_instance_metric(nr_segment_t* segment,
16-
const char* product,
17-
nr_segment_datastore_t* datastore,
18-
const nr_datastore_instance_t* instance) {
19-
/*
20-
* If a datastore instance was provided, we need to add the relevant data to
21-
* the segment and the relavant metrics.
22-
*/
23-
nrtxn_t* txn = segment->txn;
24-
char* instance_metric = NULL;
25-
if (NULL == instance || 0 == txn->options.instance_reporting_enabled) {
26-
return NR_FAILURE;
27-
}
28-
29-
if (txn->options.database_name_reporting_enabled) {
30-
nr_datastore_instance_set_database_name(&datastore->instance,
31-
instance->database_name);
32-
}
33-
34-
instance_metric = nr_formatf("Datastore/instance/%s/%s/%s", product,
35-
instance->host, instance->port_path_or_id);
36-
nr_segment_add_metric(segment, instance_metric, false);
37-
38-
nr_free(instance_metric);
39-
return NR_SUCCESS;
40-
}
41-
4215
static char* create_metrics(nr_segment_t* segment,
4316
nrtime_t duration,
4417
const char* product,
@@ -51,6 +24,7 @@ static char* create_metrics(nr_segment_t* segment,
5124
char* rollup_metric = NULL;
5225
char* scoped_metric = NULL;
5326
char* statement_metric = NULL;
27+
char* instance_metric = NULL;
5428

5529
nrm_force_add(txn->unscoped_metrics, "Datastore/all", duration);
5630

@@ -76,12 +50,28 @@ static char* create_metrics(nr_segment_t* segment,
7650
nr_free(operation_metric);
7751
nr_free(statement_metric);
7852

79-
create_instance_metric(segment, product, datastore, instance);
80-
if (NULL != instance && 0 != txn->options.instance_reporting_enabled) {
81-
nr_datastore_instance_set_host(&datastore->instance, instance->host);
82-
nr_datastore_instance_set_port_path_or_id(&datastore->instance,
83-
instance->port_path_or_id);
53+
/*
54+
* If a datastore instance was provided, we need to add the relevant data to
55+
* the segment and the relavant metrics.
56+
*/
57+
if (NULL == instance || 0 == txn->options.instance_reporting_enabled) {
58+
return scoped_metric;
59+
}
60+
61+
if (txn->options.database_name_reporting_enabled) {
62+
nr_datastore_instance_set_database_name(&datastore->instance,
63+
instance->database_name);
8464
}
65+
66+
instance_metric = nr_formatf("Datastore/instance/%s/%s/%s", product,
67+
instance->host, instance->port_path_or_id);
68+
nr_segment_add_metric(segment, instance_metric, false);
69+
nr_datastore_instance_set_host(&datastore->instance, instance->host);
70+
nr_datastore_instance_set_port_path_or_id(&datastore->instance,
71+
instance->port_path_or_id);
72+
73+
nr_free(instance_metric);
74+
8575
return scoped_metric;
8676
}
8777

@@ -218,14 +208,10 @@ bool nr_segment_datastore_end(nr_segment_t** segment_ptr,
218208
* The allWeb and allOther rollup metrics are created at the end of the
219209
* transaction since the background status may change.
220210
*/
221-
if (!params->instance_only) {
222-
scoped_metric
223-
= create_metrics(segment, duration, datastore_string, collection,
224-
operation, &datastore, params->instance);
225-
nr_segment_set_name(segment, scoped_metric);
226-
} else {
227-
create_instance_metric(segment, datastore_string, &datastore, params->instance);
228-
}
211+
scoped_metric
212+
= create_metrics(segment, duration, datastore_string, collection,
213+
operation, &datastore, params->instance);
214+
nr_segment_set_name(segment, scoped_metric);
229215

230216
/*
231217
* Add the explain plan, if we have one.

axiom/nr_segment_datastore.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ typedef struct _nr_segment_datastore_params_t {
2424
extracted from the SQL for SQL segments. */
2525
nr_datastore_instance_t*
2626
instance; /* Any instance information that was collected. */
27-
bool instance_only; /* true if only the instance metric is wanted,
28-
collection and operation fields will not be
29-
used or extracted from the SQL */
3027

3128
/*
3229
* Datastore type fields.

axiom/tests/test_segment_datastore.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -197,35 +197,6 @@ static void test_create_metrics_no_table_no_operation(void) {
197197
nr_txn_destroy(&txn);
198198
}
199199

200-
static void test_create_metrics_instance_only(void) {
201-
nrtxn_t* txn = new_txn(0);
202-
nrtime_t duration = 4 * NR_TIME_DIVISOR;
203-
nr_segment_datastore_params_t params = sample_segment_datastore_params();
204-
nr_datastore_instance_t instance = {.host = "hostname",
205-
.port_path_or_id = "123",
206-
.database_name = "my database"};
207-
nr_segment_t* segment = NULL;
208-
char* tname = "create metrics";
209-
210-
params.instance = &instance;
211-
params.instance_only = true;
212-
segment = nr_segment_start(txn, NULL, NULL);
213-
segment->start_time = 1 * NR_TIME_DIVISOR;
214-
segment->stop_time = 1 * NR_TIME_DIVISOR + duration;
215-
216-
test_segment_datastore_end_and_keep(&segment, &params);
217-
218-
/*
219-
* Test : Create only the instance metric
220-
*/
221-
test_metric_vector_size(segment->metrics, 1);
222-
test_segment_metric_created(tname, segment->metrics,
223-
"Datastore/instance/MongoDB/hostname/123",
224-
false);
225-
226-
nr_txn_destroy(&txn);
227-
}
228-
229200
static void test_instance_info_reporting_disabled(void) {
230201
nrtxn_t* txn = new_txn(0);
231202
nrtime_t duration = 4 * NR_TIME_DIVISOR;
@@ -1156,7 +1127,6 @@ tlib_parallel_info_t parallel_info = {.suggested_nthreads = 2, .state_size = 0};
11561127
void test_main(void* p NRUNUSED) {
11571128
test_bad_parameters();
11581129
test_create_metrics();
1159-
test_create_metrics_instance_only();
11601130
test_create_metrics_no_table();
11611131
test_create_metrics_no_table_no_operation();
11621132
test_instance_info_reporting_disabled();

0 commit comments

Comments
 (0)