-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agent): Adds supportability metrics for PHP and agent version (#947
) Adds supportability metrics for the agent and PHP version. I did clean up some ZTS macros as well but I think it is obvious what is a real change and what isnt. --------- Co-authored-by: Michal Nowacki <[email protected]>
- Loading branch information
Showing
9 changed files
with
290 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Copyright 2020 New Relic Corporation. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
) | ||
|
||
func GetPHPVersion() string { | ||
cmd := exec.Command("php", "-r", "echo PHP_VERSION;") | ||
|
||
output, err := cmd.Output() | ||
if err != nil { | ||
fmt.Printf("Failed to get PHP version: %v\n", err) | ||
return "failed" | ||
} | ||
|
||
return string(output) | ||
} | ||
|
||
func GetAgentVersion(agent_extension string) string { | ||
cmd := exec.Command("php", "-d", "extension="+agent_extension, "-r", "echo phpversion('newrelic');") | ||
|
||
output, err := cmd.Output() | ||
if err != nil { | ||
return fmt.Errorf("Failed to get agent version: %v", err).Error() | ||
} | ||
return string(output) | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/integration/supportability/test_php_and_agent_version_metrics.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
Verify the PHP version and agent version metrics are created properly. | ||
*/ | ||
|
||
/*EXPECT_METRICS_EXIST | ||
Supportability/PHP/Version/ENV[PHP_VERSION], 1 | ||
Supportability/PHP/AgentVersion/ENV[AGENT_VERSION], 1 | ||
*/ | ||
|
||
/*EXPECT_TRACED_ERRORS | ||
null | ||
*/ | ||
|
||
if (!extension_loaded('newrelic')) { | ||
die("fail: New Relic PHP extension is not loaded. Exiting...\n"); | ||
exit; | ||
} | ||
|
||
echo "PHP Version: " . phpversion() . "\n"; | ||
echo "Agent Version: " . phpversion('newrelic') . "\n"; |