@@ -197,6 +197,35 @@ static void test_create_metrics_no_table_no_operation(void) {
197
197
nr_txn_destroy (& txn );
198
198
}
199
199
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
+
200
229
static void test_instance_info_reporting_disabled (void ) {
201
230
nrtxn_t * txn = new_txn (0 );
202
231
nrtime_t duration = 4 * NR_TIME_DIVISOR ;
@@ -1127,6 +1156,7 @@ tlib_parallel_info_t parallel_info = {.suggested_nthreads = 2, .state_size = 0};
1127
1156
void test_main (void * p NRUNUSED ) {
1128
1157
test_bad_parameters ();
1129
1158
test_create_metrics ();
1159
+ test_create_metrics_instance_only ();
1130
1160
test_create_metrics_no_table ();
1131
1161
test_create_metrics_no_table_no_operation ();
1132
1162
test_instance_info_reporting_disabled ();
0 commit comments