Skip to content

Commit

Permalink
moved newrelic endpoint to config and used it when posting to api (#3374
Browse files Browse the repository at this point in the history
)

* moved newrelic endpoint to config and used it when posting to api

* ran bin/docgen for the commit

* mentioned the new setting for documentation

Co-authored-by: RobertOS <robert.simionescu@gmail.com>
  • Loading branch information
robertsimionescu and RobertOS authored Jan 8, 2023
1 parent 8888e5b commit dfd89e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions contrib/newrelic.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- `newrelic_app_id` – newrelic's app id
- `newrelic_api_key` – newrelic's api key
- `newrelic_description` – message to send
- `newrelic_endpoint` – newrelic's REST API endpoint
## Usage
Expand All @@ -31,16 +32,18 @@
return runLocally('git log -n 1 --format="%h"');
});

set('newrelic_endpoint', 'api.newrelic.com');

desc('Notifies New Relic of deployment');
task('newrelic:notify', function () {
if (($appId = get('newrelic_app_id')) && ($apiKey = get('newrelic_api_key'))) {
if (($appId = get('newrelic_app_id')) && ($apiKey = get('newrelic_api_key')) && ($endpoint = get('newrelic_endpoint'))) {
$data = [
'user' => get('user'),
'revision' => get('newrelic_revision'),
'description' => get('newrelic_description'),
];

Httpie::post("https://api.newrelic.com/v2/applications/$appId/deployments.json")
Httpie::post("https://$endpoint/v2/applications/$appId/deployments.json")
->header("X-Api-Key", $apiKey)
->query(['deployment' => $data])
->send();
Expand Down
19 changes: 15 additions & 4 deletions docs/contrib/newrelic.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require 'contrib/newrelic.php';
- `newrelic_app_id` – newrelic's app id
- `newrelic_api_key` – newrelic's api key
- `newrelic_description` – message to send
- `newrelic_endpoint` – newrelic's REST API endpoint

## Usage

Expand All @@ -30,7 +31,7 @@ after('deploy', 'newrelic:notify');

## Configuration
### newrelic_app_id
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L22)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L23)


:::info Required
Expand All @@ -41,7 +42,7 @@ Throws exception if not set.


### newrelic_description
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L26)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L27)



Expand All @@ -51,7 +52,7 @@ return runLocally('git log -n 1 --format="%an: %s" | tr \'"\' "\'"');


### newrelic_revision
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L30)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L31)



Expand All @@ -60,11 +61,21 @@ return runLocally('git log -n 1 --format="%h"');
```


### newrelic_endpoint
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L35)



```php title="Default value"
'api.newrelic.com'
```



## Tasks

### newrelic:notify
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L35)
[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L38)

Notifies New Relic of deployment.

Expand Down

0 comments on commit dfd89e2

Please sign in to comment.