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 kafka reporter. #88

Merged
merged 16 commits into from
Aug 19, 2023
17 changes: 10 additions & 7 deletions .github/workflows/pecl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
version:
- php: "8.2"
swoole: "5.0.0"
option:
- 'enable-cargo-debug=\"no\" enable-kafka-reporter=\"no\"'
- 'enable-cargo-debug=\"no\" enable-kafka-reporter=\"yes\"'

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -77,14 +80,14 @@ jobs:

- name: Install Rust Stable Globally
run: |
curl https://sh.rustup.rs -sSf | sudo -E sh -s -- -y --no-modify-path
sudo ln -sf $CARGO_HOME/bin/rustup /usr/local/bin/rustup
sudo ln -sf $CARGO_HOME/bin/rustc /usr/local/bin/rustc
sudo ln -sf $CARGO_HOME/bin/cargo /usr/local/bin/cargo
curl https://sh.rustup.rs -sSf | sudo -E sh -s -- -y --default-toolchain none

- name: PECL install
run: |
sudo -E cargo run -p scripts --release -- create-package-xml --version 0.0.0 --notes "Just for TEST."
cat package.xml
printf "\n" | sudo -E pecl install package.xml
sudo bash -c "\
source /tmp/cargo/env && \
cargo version && \
cargo run -p scripts --release -- create-package-xml --version 0.0.0 --notes 'Just for TEST.' && \
cat package.xml && \
pecl install -D '${{ matrix.option }}' package.xml"
php -d "extension=skywalking_agent" --ri skywalking_agent
77 changes: 45 additions & 32 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,48 @@ jobs:
os:
- ubuntu-20.04
- macos-12
version:
flag:
# Many composer dependencies need PHP 7.2+
- php: "7.2"
swoole: "4.6.7"
- php_version: "7.2"
swoole_version: "4.6.7"
enable_zend_observer: "Off"
- php: "7.3"
swoole: "4.7.1"
cargo_features: ""
- php_version: "7.3"
swoole_version: "4.7.1"
enable_zend_observer: "Off"
- php: "7.4"
swoole: "4.8.10"
cargo_features: ""
- php_version: "7.4"
swoole_version: "4.8.10"
enable_zend_observer: "Off"
- php: "8.0"
swoole: "5.0.0"
cargo_features: ""
- php_version: "8.0"
swoole_version: "5.0.0"
enable_zend_observer: "Off"
- php: "8.0"
swoole: "5.0.0"
cargo_features: ""
- php_version: "8.0"
swoole_version: "5.0.0"
enable_zend_observer: "On"
- php: "8.1"
swoole: "5.0.0"
cargo_features: ""
- php_version: "8.1"
swoole_version: "5.0.0"
enable_zend_observer: "Off"
- php: "8.1"
swoole: "5.0.0"
cargo_features: ""
- php_version: "8.1"
swoole_version: "5.0.0"
enable_zend_observer: "On"
- php: "8.2"
swoole: "5.0.0"
cargo_features: ""
- php_version: "8.2"
swoole_version: "5.0.0"
enable_zend_observer: "Off"
- php: "8.2"
swoole: "5.0.0"
cargo_features: ""
- php_version: "8.2"
swoole_version: "5.0.0"
enable_zend_observer: "On"
cargo_features: ""
- php_version: "8.2"
swoole_version: "5.0.0"
enable_zend_observer: "On"
cargo_features: "--features kafka-reporter"

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -100,19 +113,19 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version.php }}
php-version: ${{ matrix.flag.php_version }}
tools: php-config, composer:v2
extensions: >
bcmath, calendar, ctype, dom, exif, gettext, iconv, intl, json, mbstring,
mysqli, mysqlnd, opcache, pdo, pdo_mysql, phar, posix, readline, redis,
memcached, swoole-${{ matrix.version.swoole }}, xml, xmlreader, xmlwriter,
memcached, swoole-${{ matrix.flag.swoole_version }}, xml, xmlreader, xmlwriter,
yaml, zip, mongodb

- name: Setup php-fpm for Linux
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get install -y php${{ matrix.version.php }}-fpm
sudo ln -sf /usr/sbin/php-fpm${{ matrix.version.php }} /usr/sbin/php-fpm
sudo apt-get install -y php${{ matrix.flag.php_version }}-fpm
sudo ln -sf /usr/sbin/php-fpm${{ matrix.flag.php_version }} /usr/sbin/php-fpm

- name: PHP version
run: |
Expand All @@ -122,9 +135,9 @@ jobs:
php -r 'echo "Swoole version: " . phpversion("swoole") . "\n";'
composer --version

[[ `php --version` == PHP\ ${{ matrix.version.php }}.* ]] || exit 1;
[[ `php-fpm --version` == PHP\ ${{ matrix.version.php }}.* ]] || exit 1;
[[ `php-config --version` == ${{ matrix.version.php }}.* ]] || exit 1;
[[ `php --version` == PHP\ ${{ matrix.flag.php_version }}.* ]] || exit 1;
[[ `php-fpm --version` == PHP\ ${{ matrix.flag.php_version }}.* ]] || exit 1;
[[ `php-config --version` == ${{ matrix.flag.php_version }}.* ]] || exit 1;

- name: Install Rust
uses: actions-rs/toolchain@v1
Expand All @@ -142,21 +155,21 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-test-${{ matrix.version.php }}-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.os }}-test-${{ matrix.flag.php_version }}-${{ hashFiles('**/Cargo.lock') }}

- name: Cargo clippy
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: clippy
args: --release --workspace
args: --release --workspace ${{ matrix.flag.cargo_features }}

- name: Cargo build
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: build
args: --release --workspace
args: --release --workspace ${{ matrix.flag.cargo_features }}

- name: Composer install
run: composer install --working-dir=tests/php
Expand All @@ -178,9 +191,9 @@ jobs:
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: test
args: --release --workspace
args: --release --workspace ${{ matrix.flag.cargo_features }}
env:
ENABLE_ZEND_OBSERVER: ${{ matrix.version.enable_zend_observer }}
ENABLE_ZEND_OBSERVER: ${{ matrix.flag.enable_zend_observer }}
continue-on-error: true

# Rebuild the mixture when cargo test failed.
Expand All @@ -207,7 +220,7 @@ jobs:
command: test
args: --release --workspace
env:
ENABLE_ZEND_OBSERVER: ${{ matrix.version.enable_zend_observer }}
ENABLE_ZEND_OBSERVER: ${{ matrix.flag.enable_zend_observer }}

- name: View logs
if: always()
Expand Down
88 changes: 88 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ publish = false
name = "skywalking_agent"
crate-type = ["lib", "cdylib"]

[features]
kafka-reporter = ["skywalking/kafka-reporter"]

[dependencies]
anyhow = { version = "1.0.72", features = ["backtrace"] }
bincode = "1.3.3"
Expand Down
11 changes: 10 additions & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ PHP_ARG_ENABLE([skywalking_agent],
PHP_ARG_ENABLE([cargo_debug], [whether to enable cargo debug mode],
[ --enable-cargo-debug Enable cargo debug], no, no)

PHP_ARG_ENABLE([kafka_reporter], [whether to enable kafka reporter],
[ --enable-kafka-reporter Enable kafka reporter], no, no)

if test "$PHP_THREAD_SAFETY" == "yes"; then
AC_MSG_ERROR([skywalking_agent does not support ZTS])
fi
Expand All @@ -43,19 +46,24 @@ if test "$PHP_SKYWALKING_AGENT" != "no"; then

CARGO_MODE_FLAGS="--release"
CARGO_MODE_DIR="release"
CARGO_FEATURES_FLAGS=""

if test "$PHP_CARGO_DEBUG" != "no"; then
CARGO_MODE_FLAGS=""
CARGO_MODE_DIR="debug"
fi

if test "$PHP_KAFKA_REPORTER" != "no"; then
CARGO_FEATURES_FLAGS="--features kafka-reporter"
fi

cat >>Makefile.objects<< EOF
all: cargo_build

clean: cargo_clean

cargo_build:
PHP_CONFIG=$PHP_PHP_CONFIG cargo build $CARGO_MODE_FLAGS
PHP_CONFIG=$PHP_PHP_CONFIG cargo build $CARGO_MODE_FLAGS $CARGO_FEATURES_FLAGS
if [[ -f ./target/$CARGO_MODE_DIR/libskywalking_agent.dylib ]] ; then \\
cp ./target/$CARGO_MODE_DIR/libskywalking_agent.dylib ./modules/skywalking_agent.so ; fi
if [[ -f ./target/$CARGO_MODE_DIR/libskywalking_agent.so ]] ; then \\
Expand All @@ -73,6 +81,7 @@ EOF
Cargo.toml:Cargo.toml \
build.rs:build.rs \
docker-compose.yml:docker-compose.yml \
rust-toolchain.toml:rust-toolchain.toml \
scripts:scripts \
src:src \
tests:tests \
Expand Down