Skip to content

Commit

Permalink
fix(agent): If segment is already named, use the name to create the m…
Browse files Browse the repository at this point in the history
…etric.
  • Loading branch information
zsistla committed Jan 17, 2025
1 parent 1523be8 commit 024ed47
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions agent/php_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,14 +1255,26 @@ static inline void nr_php_execute_segment_add_metric(
bool create_metric) {
char buf[METRIC_NAME_MAX_LEN];

nr_php_execute_metadata_metric(metadata, buf, sizeof(buf));

if (create_metric) {
nr_segment_add_metric(segment, buf, true);
}
/*
* If the name is not already set, use the metadata to get the class and
* function name to name the metric and the segment.
*
* If the segment name is already set, use that to name the metric.
*/
if (!segment->name) {
/* Only set the segment name if it is not already set. */
nr_php_execute_metadata_metric(metadata, buf, sizeof(buf));

if (create_metric) {
nr_segment_add_metric(segment, buf, true);
}
nr_segment_set_name(segment, buf);
} else {
/* Segment already named, so only create the metric with the name. */
if (create_metric) {
nr_segment_add_metric(
segment, nr_string_get(segment->txn->trace_strings, segment->name),
true);
}
}
}

Expand Down

0 comments on commit 024ed47

Please sign in to comment.