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

FRW-8618 Init commit #1

Merged
merged 8 commits into from
Aug 27, 2024

Conversation

dimitriyTsemma
Copy link
Contributor

@dimitriyTsemma dimitriyTsemma commented Aug 21, 2024

Release Table

Package Release Type Constraint Updates
OtelRabbitMqInstrumentation minor (new)

Package OtelRabbitMqInstrumentation

Change log

Initial Release

  • Introduced the functionality to auto-instrument RabbitMq calls in the Spryker application.

@dimitriyTsemma dimitriyTsemma added the enhancement New feature or request label Aug 21, 2024
composer.json Outdated
"open-telemetry/context": "^1.0",
"open-telemetry/sem-conv": "^1.0",
"php": ">=8.1",
"spryker/rabbit-mq": "dev-master",
Copy link
Contributor

Choose a reason for hiding this comment

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

why maste?

->setAttribute(static::ATTRIBUTE_QUEUE_NAME, $params[0]);

if (static::isValidMessage($params)) {
$array = json_decode($params[1][0]->getBody(), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please name variables in more descriptive name. Array is quite generic name

->startSpan()
->activate();
},
post: function ($instance, array $params, $response, ?Throwable $exception): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

can be typehinted

$span->recordException($exception);
$span->setStatus(StatusCode::STATUS_ERROR);
} else {

Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this empty line

}

$endTime = microtime(true);
$duration = $endTime - $span->getAttribute(static::START_TIME);
Copy link
Contributor

Choose a reason for hiding this comment

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

After some consideration, not sure if needed.
First of all span has getDuration method.
And also it's auto added to the span

*/
protected static function isValidMessage(array $params): bool
{
return array_key_exists(1, $params)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return array_key_exists(1, $params)
$PLEASE_RENAME_TO_SMTH_DESCRIPTIVE = $params[1][0] ?? null;
if (!$PLEASE_RENAME_TO_SMTH_DESCRIPTIVE) {
return false;
}
return $PLEASE_RENAME_TO_SMTH_DESCRIPTIVE instanceof QueueSendMessageTransfer && is_string($PLEASE_RENAME_TO_SMTH_DESCRIPTIVE->getBody());

Copy link
Contributor

@gechetspr gechetspr left a comment

Choose a reason for hiding this comment

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

one small thing. Also, could you please add changelogs into a PR description. I'll use it to release this PRs later

composer.json Outdated
"open-telemetry/context": "^1.0",
"open-telemetry/sem-conv": "^1.0",
"php": ">=8.1",
"spryker/rabbit-mq": "^2.19.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say we need a version, but we should not force people to update to the latest one. I would say ^2.0.0 is more then enough

@dimitriyTsemma dimitriyTsemma merged commit 90b4950 into master Aug 27, 2024
0 of 3 checks passed
@dimitriyTsemma dimitriyTsemma deleted the feature/frw-8618/master-open-telemetry branch August 29, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants