Skip to content

Commit

Permalink
Merge branch 'dev' into feat/sqs_instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zsistla authored Jan 17, 2025
2 parents 024ed47 + 996dcc9 commit dfda103
Show file tree
Hide file tree
Showing 177 changed files with 8,755 additions and 284 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code-coverage-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
matrix:
platform: [gnu, musl]
arch: [amd64]
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
include:
- codecov: 0
- platform: gnu
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
matrix:
platform: [gnu, musl]
arch: [amd64]
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
include:
- codecov: 0
- platform: gnu
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
matrix:
platform: [gnu, musl]
php: ['8.0', '8.1', '8.2', '8.3']
php: ['8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
fail-fast: true
matrix:
platform: [gnu, musl]
php: ['8.0', '8.1', '8.2', '8.3']
php: ['8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- name: Checkout integration tests
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ jobs:
if: ${{ github.event_name == 'schedule' }}
uses: github/codeql-action/upload-sarif@v3
with:
checkout_path: ./php-agent
sarif_file: trivy-results.sarif
37 changes: 35 additions & 2 deletions .github/workflows/test-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,39 @@ jobs:
echo "$GOFMT_REPORTED_FILES" >> $GITHUB_STEP_SUMMARY
exit 1
fi
govet:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout newrelic-php-agent code
uses: actions/checkout@v4
with:
path: php-agent
- name: Get go version
id: get-go-version
run: |
echo "go toolchain version required to build the daemon:"
toolchain="$(awk '/^toolchain */ {gsub(/^go/, "", $2); print $2}' ./php-agent/daemon/go.mod)"
echo "[${toolchain}]"
echo "go-toolchain-version=${toolchain}" >> $GITHUB_OUTPUT
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ steps.get-go-version.outputs.go-toolchain-version }}
cache-dependency-path: "**/*.sum"
- name: Verify go version
run: |
echo "Verify correct go toolchain version is used"
actual="$(go version)"
echo "Actual: [$actual]"
expected="go version go${{ steps.get-go-version.outputs.go-toolchain-version }} linux/amd64"
echo "Expected: [$expected]"
if [ "$actual" != "$expected" ]; then
exit 1
fi
- name: Run go vet
run: go vet -C ./php-agent/daemon ./...
shell: bash
daemon-unit-tests:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -97,7 +130,7 @@ jobs:
matrix:
platform: [gnu, musl]
arch: [amd64, arm64]
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
exclude:
- arch: arm64
php: '7.2'
Expand Down Expand Up @@ -203,7 +236,7 @@ jobs:
matrix:
platform: [gnu, musl]
arch: [amd64, arm64]
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
exclude:
- arch: arm64
php: '7.2'
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.5.0
11.6.0
5 changes: 4 additions & 1 deletion agent/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,16 @@ if test "$PHP_NEWRELIC" = "yes"; then
lib_guzzle4.c lib_guzzle6.c lib_guzzle_common.c \
lib_mongodb.c lib_phpunit.c lib_predis.c lib_zend_http.c \
lib_composer.c"
PHP_NEW_EXTENSION(newrelic, $FRAMEWORKS $LIBRARIES $NEWRELIC_AGENT, $ext_shared,, \\$(NEWRELIC_CFLAGS))
PHP_NEW_EXTENSION(newrelic, $FRAMEWORKS $LIBRARIES $NEWRELIC_AGENT, $ext_shared,, $(NEWRELIC_CFLAGS))

PHP_SUBST(NEWRELIC_CFLAGS)

dnl Define $(PHP_CONFIG) so we can call it when building tests.
PHP_SUBST(PHP_CONFIG)

dnl Make sure we include the source directory in the include search path.
PHP_ADD_INCLUDE([$abs_srcdir], [1])

dnl Include the Makefile.frag, which we use to handle build time
dnl dependencies.
PHP_ADD_MAKEFILE_FRAGMENT
Expand Down
15 changes: 12 additions & 3 deletions agent/newrelic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ for pmv in "20170718" "20180731" "20190902"; do
done
fi
# Currently supported versions:
# (8.0, 8.1, 8.2, 8.3)
# (8.0, 8.1, 8.2, 8.3, 8.4)
# for x64 and aarch64
if [ ${arch} = x64 ] || [ ${arch} = aarch64 ]; then
for pmv in "20200930" "20210902" "20220829" "20230831"; do
for pmv in "20200930" "20210902" "20220829" "20230831" "20240924"; do
check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so"
done
fi
Expand Down Expand Up @@ -542,6 +542,7 @@ add_to_path /usr/local/php-8.0/bin
add_to_path /usr/local/php-8.1/bin
add_to_path /usr/local/php-8.2/bin
add_to_path /usr/local/php-8.3/bin
add_to_path /usr/local/php-8.4/bin

add_to_path /opt/local/bin
add_to_path /usr/php/bin
Expand All @@ -553,6 +554,7 @@ add_to_path /usr/php-8.0/bin
add_to_path /usr/php-8.1/bin
add_to_path /usr/php-8.2/bin
add_to_path /usr/php-8.3/bin
add_to_path /usr/php-8.4/bin

add_to_path /usr/php/7.2/bin
add_to_path /usr/php/7.3/bin
Expand All @@ -561,6 +563,7 @@ add_to_path /usr/php/8.0/bin
add_to_path /usr/php/8.1/bin
add_to_path /usr/php/8.2/bin
add_to_path /usr/php/8.3/bin
add_to_path /usr/php/8.4/bin

add_to_path /opt/php/bin
add_to_path /opt/zend/bin
Expand All @@ -572,6 +575,7 @@ add_to_path /opt/php-8.0/bin
add_to_path /opt/php-8.1/bin
add_to_path /opt/php-8.2/bin
add_to_path /opt/php-8.3/bin
add_to_path /opt/php-8.4/bin

if [ -n "${NR_INSTALL_PATH}" ]; then
oIFS="${IFS}"
Expand Down Expand Up @@ -1052,7 +1056,11 @@ for this copy of PHP. We apologize for the inconvenience.

8.3.*)
pi_php8="yes"
;;
;;

8.4.*)
pi_php8="yes"
;;

*)
error "unsupported version '${pi_ver}' of PHP found at:
Expand Down Expand Up @@ -1232,6 +1240,7 @@ does not exist. This particular instance of PHP will be skipped.
8.1.*) pi_modver="20210902" ;;
8.2.*) pi_modver="20220829" ;;
8.3.*) pi_modver="20230831" ;;
8.4.*) pi_modver="20240924" ;;
esac
log "${pdir}: pi_modver=${pi_modver}"

Expand Down
1 change: 1 addition & 0 deletions agent/php_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#define ZEND_8_1_X_API_NO 20210902
#define ZEND_8_2_X_API_NO 20220829
#define ZEND_8_3_X_API_NO 20230831
#define ZEND_8_4_X_API_NO 20240924

#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO /* PHP8+ */
#include "Zend/zend_observer.h"
Expand Down
28 changes: 28 additions & 0 deletions agent/php_internal_instrument.c
Original file line number Diff line number Diff line change
Expand Up @@ -3840,9 +3840,37 @@ void nr_php_generate_internal_wrap_records(void) {
NR_INTERNAL_WRAPREC("sqlite3::exec", sqlite3_exec, sqlite3, 0, 0)

NR_INTERNAL_WRAPREC("pdo::__construct", pdo_construct, pdo_construct, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::__construct", pdo_construct, pdo_construct, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdo::query", pdo_query, pdo_query, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::query", pdo_query, pdo_query, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdo::exec", pdo_exec, pdo_exec, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::exec", pdo_exec, pdo_exec, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdo::prepare", pdo_prepare, pdo_prepare, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::prepare", pdo_prepare, pdo_prepare, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdostatement::execute", pdostmt_execute,
pdostatement_execute, 0, 0)

Expand Down
4 changes: 4 additions & 0 deletions agent/tests/test_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ static void test_function_debug_name(TSRMLS_D) {
func = nr_php_zval_to_function(closure TSRMLS_CC);
name = nr_php_function_debug_name(func);

#if ZEND_MODULE_API_NO < ZEND_8_4_X_API_NO
tlib_pass_if_str_equal("closure", "{closure} declared at -:1", name);
#else
tlib_pass_if_str_equal("closure", "{closure:-:1} declared at -:1", name);
#endif

nr_php_zval_free(&closure);
nr_free(name);
Expand Down
3 changes: 2 additions & 1 deletion axiom/nr_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
* bowenite 30Sep2024 (11.2)
* corundum 21Oct2024 (11.3)
* diamond 09Dec2024 (11.4)
* emerald 13Jan2025 (11.5)
*/
#define NR_CODENAME "emerald"
#define NR_CODENAME "fluorite"

const char* nr_version(void) {
return NR_STR2(NR_VERSION);
Expand Down
25 changes: 24 additions & 1 deletion axiom/tests/test_segment_private.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,23 @@ static void test_destroy_typed_attributes(void) {
*/
nr_segment_destroy_typed_attributes(NR_SEGMENT_EXTERNAL, NULL);
nr_segment_destroy_typed_attributes(NR_SEGMENT_EXTERNAL, &s.typed_attributes);
tlib_pass_if_null(
"Even with bad parameters, nr_segment_destroy_typed_attributes should "
"not crash and s.typed_attributes should be NULL",
s.typed_attributes);
nr_segment_destroy_typed_attributes(NR_SEGMENT_DATASTORE, NULL);
nr_segment_destroy_typed_attributes(NR_SEGMENT_DATASTORE,
&s.typed_attributes);
tlib_pass_if_null(
"Even with bad parameters, nr_segment_destroy_typed_attributes should "
"not crash and s.typed_attributes should be NULL",
s.typed_attributes);
nr_segment_destroy_typed_attributes(NR_SEGMENT_MESSAGE, NULL);
nr_segment_destroy_typed_attributes(NR_SEGMENT_MESSAGE, &s.typed_attributes);
tlib_pass_if_null(
"Even with bad parameters, nr_segment_destroy_typed_attributes should "
"not crash and s.typed_attributes should be NULL",
s.typed_attributes);

/*
* Test : Clean up typed attributes for a message segment
Expand All @@ -386,7 +398,10 @@ static void test_destroy_typed_attributes(void) {
* Valgrind shall affirm that the attributes were cleaned up.
*/
nr_segment_destroy_typed_attributes(NR_SEGMENT_MESSAGE, &s.typed_attributes);

tlib_pass_if_null(
"After nr_segment_destroy_typed_attributes, s.typed_attributes should be "
"NULL",
s.typed_attributes);
/*
* Test : Clean up typed attributes for an external segment
*/
Expand All @@ -402,6 +417,10 @@ static void test_destroy_typed_attributes(void) {
* Valgrind shall affirm that the attributes were cleaned up.
*/
nr_segment_destroy_typed_attributes(NR_SEGMENT_EXTERNAL, &s.typed_attributes);
tlib_pass_if_null(
"After nr_segment_destroy_typed_attributes, s.typed_attributes should be "
"NULL",
s.typed_attributes);

/*
* Test : Clean up typed attributes for a datastore segment
Expand All @@ -424,6 +443,10 @@ static void test_destroy_typed_attributes(void) {
*/
nr_segment_destroy_typed_attributes(NR_SEGMENT_DATASTORE,
&s.typed_attributes);
tlib_pass_if_null(
"After nr_segment_destroy_typed_attributes, s.typed_attributes should be "
"NULL",
s.typed_attributes);
}

static void test_destroy_fields(void) {
Expand Down
5 changes: 3 additions & 2 deletions axiom/tests/test_span_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ static void test_span_event_spankind(void) {
nr_span_event_t* event = nr_span_event_create();

// Test : the default is NULL (spankind must be explicitly set)
tlib_pass_if_str_equal("The default spankind is NULL", NULL,
nr_span_event_get_spankind(event));
tlib_pass_if_str_equal(
"When not explicitly set, The default spankind is NULL", NULL,
nr_span_event_get_spankind(event));

// Test : A null event returns NULL
tlib_pass_if_null("nr_span_event_get_spankind(NULL) returns NULL",
Expand Down
4 changes: 3 additions & 1 deletion daemon/cmd/daemon/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func runWorker(cfg *Config) {
hasProgenitor := !(cfg.Foreground || cfg.WatchdogForeground)

ctx, cancel := context.WithCancel(context.Background())
defer cancel() // Ensure that the context is always cancelled when the worker exits, not only when signal is caught.

select {
case <-listenAndServe(ctx, cfg.BindAddr, errorChan, p, hasProgenitor):
Expand All @@ -140,7 +141,8 @@ func runWorker(cfg *Config) {
case caught := <-signalChan:
// Close the listener before sending remaining data. This ensures that the socket
// connection is closed as soon as possible and other processes can start listening
// the socket while remaining data is sent.
// the socket while remaining data is sent. Earlier defer cancel() will be a no-op
// because cancel() is called here explicitly.
cancel()
log.Infof("worker received signal %d - sending remaining data", caught)
p.CleanExit()
Expand Down
2 changes: 1 addition & 1 deletion daemon/internal/newrelic/utilization/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type kubernetes struct {
KubernetesServiceHost string `json:"kubernetes_service_host",omitempty`
KubernetesServiceHost string `json:"kubernetes_service_host,omitempty"`

// Having a custom getter allows the unit tests to mock os.Getenv().
environmentVariableGetter func(key string) string
Expand Down
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ _(most operating systems package these with `-dev` or `-devel` suffixes)_

### PHP

The PHP agent supports PHP versions `7.2`, `7.3`, `7.4`,`8.0`, `8.1`, '8.2', and `8.3`.
The PHP agent supports PHP versions `7.2`, `7.3`, `7.4`,`8.0`, `8.1`, `8.2`, `8.3` and `8.4`.

## Build the PHP Agent

Expand Down
4 changes: 2 additions & 2 deletions files/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

ARG PHP_VER

FROM php:${PHP_VER:-8.3}
FROM php:${PHP_VER:-8.4}

RUN docker-php-source extract

Expand Down Expand Up @@ -89,7 +89,7 @@ COPY --from=composer ["/usr/bin/composer", "/usr/bin/composer"]
# and 8.0 has problems with how the explanation for informational_schema
# work (refer to bug https://bugs.mysql.com/bug.php?id=102536) so to run
# the mysql tests a separate machine running mysql server 5.6 is required.
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-install pdo pdo_mysql pdo_pgsql

# install redis extension required by test_redis:
RUN \
Expand Down
2 changes: 1 addition & 1 deletion make/php_versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# SPDX-License-Identifier: Apache-2.0
#

PHP_VERSION_LIST=$${PHPS:-8.3 8.2 8.1 8.0 7.4 7.3 7.2}
PHP_VERSION_LIST=$${PHPS:-8.4 8.3 8.2 8.1 8.0 7.4 7.3 7.2}
1 change: 1 addition & 0 deletions make/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ release-$1-zts: Makefile agent | releases/$$(RELEASE_OS)/agent/$$(RELEASE_ARCH)/

endef

$(eval $(call RELEASE_AGENT_TARGET,8.4,20240924))
$(eval $(call RELEASE_AGENT_TARGET,8.3,20230831))
$(eval $(call RELEASE_AGENT_TARGET,8.2,20220829))
$(eval $(call RELEASE_AGENT_TARGET,8.1,20210902))
Expand Down
Loading

0 comments on commit dfda103

Please sign in to comment.