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

Add Ability To Separate Frontend / Adminhtml in New Relic #12935

Conversation

mpchadwick
Copy link
Contributor

@mpchadwick mpchadwick commented Dec 31, 2017

Description

Adds a new setting which, when enabled, reports frontend and adminhtml as separate apps to New Relic.

frontend and adminhtml are in addition to the "main" app which includes both (for backwards compatibility). The user needs to set "New Relic Application Name" to use this feature as the area is appended to the appname setting, separated by and underscore.

image

image

Useful as slow transactions in admin activity can cause false positives New Relic alerts / skew average response time metrics. Using this feature allows monitoring and alerting on only frontend traffic by configuring alerts for just the frontend New Relic app.

Manual testing scenarios

  1. Pull in changes to a testing environment with New Relic agent installed
  2. Ensure "Enable New Relic Intergration" is set to yes
  3. Ensure "New Relic Application Name" is set
  4. Turn on "Send Adminhtml and Frontend as Separate Apps Setting"
  5. Navigate the frontend and backend of Magento
  6. Login to New Relic and observe 3 apps ("main" app, "adminhtml" app, and "frontend" app).

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@mpchadwick
Copy link
Contributor Author

mpchadwick commented Dec 31, 2017

Just to document, based on testing done in response to this conversation on Twitter, this will also catch other area codes such as webapi_rest.

image

@ihor-sviziev
Copy link
Contributor

I reopened this PR in order to restart build in travis

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

In general looks good, but here is some small issues. Can you also cover your changes with tests?

* @param string $appName
* @return void
*/
public function setAppName($appName)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to define variable type to "string" there, we're not supporting php 5.6 anymore

try {
$this->newRelicWrapper->setAppName($this->appName($state));
} catch (LocalizedException $e) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Why should we ignore such exception?
  2. Probably we should have return $result here

public function afterSetAreaCode(State $state, $result)
{
if (!$this->shouldSetAppName()) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably we should have return $result here

}
}

private function appName(State $state)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be better to rename it to "setAppName"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a getter. Would you prefer getAppName?

This would happen if for some reason the area code wasn't set
@ihor-sviziev
Copy link
Contributor

Hi @mpchadwick,
Your changes looks good, could you cover them with tests in order to prevent regression in this place?

@mpchadwick
Copy link
Contributor Author

@ihor-sviziev I will add tests. May take a little while. Still trying to get the integration tests to run in my local environment.

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

@mpchadwick please review static test, they are failing currently

@mpchadwick
Copy link
Contributor Author

@ihor-sviziev fixed

@magento-engcom-team magento-engcom-team added this to the Release: 2.2.6 milestone Jun 5, 2018
@magento-engcom-team magento-engcom-team added Partner: Something Digital partners-contribution Pull Request is created by Magento Partner labels Jun 5, 2018
@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-1860 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @mpchadwick. Thank you for your contribution.
Changes from your Pull Request will be available with the upcoming 2.2.6 release.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

@ihor-sviziev
Copy link
Contributor

Hi @mpchadwick,
I don't have enough time for fixing all the issues that appeared in #15947. Could you create own forwardport with requested changes from #15947?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants