Skip to content

Commit 024ed47

Browse files
committed
fix(agent): If segment is already named, use the name to create the metric.
1 parent 1523be8 commit 024ed47

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

agent/php_execute.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,14 +1255,26 @@ static inline void nr_php_execute_segment_add_metric(
12551255
bool create_metric) {
12561256
char buf[METRIC_NAME_MAX_LEN];
12571257

1258-
nr_php_execute_metadata_metric(metadata, buf, sizeof(buf));
1259-
1260-
if (create_metric) {
1261-
nr_segment_add_metric(segment, buf, true);
1262-
}
1258+
/*
1259+
* If the name is not already set, use the metadata to get the class and
1260+
* function name to name the metric and the segment.
1261+
*
1262+
* If the segment name is already set, use that to name the metric.
1263+
*/
12631264
if (!segment->name) {
1264-
/* Only set the segment name if it is not already set. */
1265+
nr_php_execute_metadata_metric(metadata, buf, sizeof(buf));
1266+
1267+
if (create_metric) {
1268+
nr_segment_add_metric(segment, buf, true);
1269+
}
12651270
nr_segment_set_name(segment, buf);
1271+
} else {
1272+
/* Segment already named, so only create the metric with the name. */
1273+
if (create_metric) {
1274+
nr_segment_add_metric(
1275+
segment, nr_string_get(segment->txn->trace_strings, segment->name),
1276+
true);
1277+
}
12661278
}
12671279
}
12681280

0 commit comments

Comments
 (0)