Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(agent): Add aws-sdk-php SQS instrumentation #1003

Merged
merged 104 commits into from
Jan 22, 2025
Merged

Conversation

zsistla
Copy link
Contributor

@zsistla zsistla commented Dec 30, 2024

Uses message segments to create SQS instrumentation.

Added unit tests and multiverse tests.

zsistla and others added 30 commits October 23, 2024 14:24
Set segment type enum
Create nr_segment_message_t struct
Add to the nr_segment_typed_attributes_t union
* Create enums for message attributes attributes
* Add MESSAGE enum to nr_span_category_t span category
* create nr_span_event_set_message
create `nr_span_event_set_spankind`

for generic,http,datastore the logic of nr_span_event_set_category is overloaded because according agent-specs/Span-Events.md, span.kind could only ever be “client” for datastore and http spans  and empty for generic spans.  I debated extracting all the logic and making nr_span_event_set_spankind calls for those categories in nr_segment.c; however, since the span.kind values are always the same for those span categories, I left it in for now.  Message spans however, will call nr_span_event_set_spankind separately and nr_span_event_set_category will only be used to set the category.
add message_type to nr_segment_message_t to inform the spankind

since message_type is on nr_segment_message_t, give a default in case the message span is created but the nr_segment_message_t is not accessible

added function nr_populate_message_spans

added function nr_segment_set_message

added message segment handling to nr_segment_to_span_event
Add the message_tracer_segment_parameters_enabled value to opts for use in axiom.
Includes creating metrics and ending the message segment.
* test get/set spankind
* test get/set message span members
Sorry clang-format added some unrelated formatting.
Rollups happen in 2 places in nr_txn.c
nr_error_to_event
And
nr_txn_event_intrinsics
* fixed externalCallCount was getting set in nr_error_to_event  but not in nr_txn_event_intrinsics
* Added messageCallCount/messageDuration to both functions
Handle NULL/empty str and provide the `<unknown>` string.
Set segment type enum
Create nr_segment_message_t struct
Add to the nr_segment_typed_attributes_t union
Use a macro to determine class.
Remove all previously defined strings and lengths.
#define COMMAND_NAME_LEN_FOR_TEST sizeof(COMMAND_NAME_FOR_TEST) - 1
#define ARG_TO_FIND_FOR_TEST AWS_SDK_PHP_SQSCLIENT_QUEUEURL_ARG

/* These wrappers are used so we don't have to mock up zend_execute_data. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I really like this idea!


/* Add cloud attributes, if available. */

nr_segment_traces_add_cloud_attributes(segment, &cloud_attrs);
Copy link
Member

@lavarou lavarou Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for posterity (because it took me a moment to figure this out) - no char * pointers in could_attrs need to be freed because they're either pointers into command_arg_value which is freed before returning from this function or it is a pointer to command_name_string which is also freed.

agent/lib_aws_sdk_php.c Outdated Show resolved Hide resolved
lavarou
lavarou previously approved these changes Jan 17, 2025
Base automatically changed from feat/message_segment to dev January 17, 2025 16:12
@zsistla zsistla dismissed lavarou’s stale review January 17, 2025 16:12

The base branch was changed.

mfulb
mfulb previously approved these changes Jan 17, 2025
Copy link
Contributor

@mfulb mfulb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Amber!

@lavarou lavarou added this to the next-release milestone Jan 22, 2025
axiom/nr_segment_message.c Outdated Show resolved Hide resolved
agent/lib_aws_sdk_php.h Outdated Show resolved Hide resolved
agent/lib_aws_sdk_php.c Outdated Show resolved Hide resolved
agent/lib_aws_sdk_php.c Outdated Show resolved Hide resolved
Co-authored-by: Michal Nowacki <[email protected]>
@zsistla zsistla merged commit 3d71d47 into dev Jan 22, 2025
65 checks passed
@zsistla zsistla deleted the feat/sqs_instrumentation branch January 22, 2025 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants