@@ -34,7 +34,8 @@ typedef struct _nrtxn_t nrtxn_t;
34
34
typedef enum _nr_segment_type_t {
35
35
NR_SEGMENT_CUSTOM ,
36
36
NR_SEGMENT_DATASTORE ,
37
- NR_SEGMENT_EXTERNAL
37
+ NR_SEGMENT_EXTERNAL ,
38
+ NR_SEGMENT_MESSAGE
38
39
} nr_segment_type_t ;
39
40
40
41
/*
@@ -109,6 +110,48 @@ typedef struct _nr_segment_external_t {
109
110
uint64_t status ;
110
111
} nr_segment_external_t ;
111
112
113
+ typedef struct _nr_segment_message_t {
114
+ /*
115
+ * Attributes needed for entity relationship building.
116
+ * Compare to OTEL attributes:
117
+ * https://opentelemetry.io/docs/specs/semconv/attributes-registry/cloud/
118
+ * cloud.account.id, cloud.region, messaging.system and server.address are
119
+ * used to create relationships between APM and cloud services. It may not
120
+ * make sense to add these attributes unless they are used for creating one of
121
+ * the relationships in Entity Relationships.
122
+ */
123
+
124
+ nr_span_spankind_t
125
+ message_action ; /*The action of the message, e.g.,Produce/Consume.*/
126
+ char * destination_name ; /*The name of the Queue, Topic, or Exchange;
127
+ otherwise, Temp. Needed for SQS relationship.*/
128
+ char * messaging_system ; /* for ex: aws_sqs. Needed for SQS relationship.*/
129
+ char * server_address ; /*The server domain name or IP address. Needed for
130
+ MQBROKER relationship.*/
131
+ } nr_segment_message_t ;
132
+
133
+ typedef struct _nr_segment_cloud_attrs_t {
134
+ /*
135
+ * Attributes needed for entity relationship building.
136
+ * Compare to OTEL attributes:
137
+ * https://opentelemetry.io/docs/specs/semconv/attributes-registry/cloud/
138
+ * cloud.account.id, cloud.region, messaging.system and server.address are
139
+ * used to create relationships between APM and cloud services. It may not
140
+ * make sense to add these attributes unless they are used for creating one of
141
+ * the relationships in Entity Relationships.
142
+ * These attributes aren't specific to a segment category so don't belong as
143
+ * typed attributes and can be added whenever they are available.
144
+ */
145
+ char * cloud_region ; /*Targeted region; ex:us-east-1*. Needed for SQS
146
+ relationship.*/
147
+ char * cloud_account_id ; /*The cloud provider account ID. Needed for SQS
148
+ relationship.*/
149
+ char * cloud_resource_id ; /*Unique cloud provider identifier. For AWS, this is
150
+ the ARN of the AWS resource being accessed.*/
151
+ char * aws_operation ; /*AWS specific operation name.*/
152
+
153
+ } nr_segment_cloud_attrs_t ;
154
+
112
155
typedef struct _nr_segment_metric_t {
113
156
char * name ;
114
157
bool scoped ;
@@ -132,6 +175,7 @@ typedef struct _nr_segment_error_t {
132
175
typedef union {
133
176
nr_segment_datastore_t datastore ;
134
177
nr_segment_external_t external ;
178
+ nr_segment_message_t message ;
135
179
} nr_segment_typed_attributes_t ;
136
180
137
181
typedef struct _nr_segment_t {
@@ -179,8 +223,8 @@ typedef struct _nr_segment_t {
179
223
int priority ; /* Used to determine which segments are preferred for span event
180
224
creation */
181
225
nr_segment_typed_attributes_t * typed_attributes ; /* Attributes specific to
182
- external or datastore
183
- segments. */
226
+ external, datastore,
227
+ or message segments. */
184
228
nr_segment_error_t * error ; /* segment error attributes */
185
229
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
186
230
&& !defined OVERWRITE_ZEND_EXECUTE_DATA /* PHP 8.0+ and OAPI */
@@ -314,6 +358,17 @@ extern bool nr_segment_set_datastore(nr_segment_t* segment,
314
358
*/
315
359
extern bool nr_segment_set_external (nr_segment_t * segment ,
316
360
const nr_segment_external_t * external );
361
+
362
+ /*
363
+ * Purpose : Mark the segment as being a message segment.
364
+ *
365
+ * Params : 1. The pointer to the segment.
366
+ * 2. The message attributes, which will be copied into the segment.
367
+ *
368
+ * Returns : true if successful, false otherwise.
369
+ */
370
+ extern bool nr_segment_set_message (nr_segment_t * segment ,
371
+ const nr_segment_message_t * message );
317
372
/*
318
373
* Purpose : Add a child to a segment.
319
374
*
0 commit comments