Skip to content

Commit 0a401c2

Browse files
authored
Enable zend observer by default for PHP 8+ (#138)
1 parent a7c94f1 commit 0a401c2

5 files changed

Lines changed: 6 additions & 31 deletions

File tree

.github/workflows/rust.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,55 +57,33 @@ jobs:
5757
# Many composer dependencies need PHP 7.2+
5858
- php_version: "7.2"
5959
swoole_version: "4.6.7"
60-
enable_zend_observer: "Off"
6160
cargo_features: ""
6261
- php_version: "7.3"
6362
swoole_version: "4.7.1"
64-
enable_zend_observer: "Off"
6563
cargo_features: ""
6664
- php_version: "7.4"
6765
swoole_version: "4.8.10"
68-
enable_zend_observer: "Off"
6966
cargo_features: ""
7067
- php_version: "8.0"
7168
swoole_version: "5.0.0"
72-
enable_zend_observer: "Off"
73-
cargo_features: ""
74-
- php_version: "8.0"
75-
swoole_version: "5.0.0"
76-
enable_zend_observer: "On"
7769
cargo_features: ""
7870
- php_version: "8.1"
7971
swoole_version: "5.1.1"
80-
enable_zend_observer: "Off"
81-
cargo_features: ""
82-
- php_version: "8.1"
83-
swoole_version: "5.1.1"
84-
enable_zend_observer: "On"
85-
cargo_features: ""
86-
- php_version: "8.2"
87-
swoole_version: "5.1.1"
88-
enable_zend_observer: "Off"
8972
cargo_features: ""
9073
- php_version: "8.2"
9174
swoole_version: "5.1.1"
92-
enable_zend_observer: "On"
9375
cargo_features: ""
9476
- php_version: "8.2"
9577
swoole_version: "5.1.1"
96-
enable_zend_observer: "On"
9778
cargo_features: "--features kafka-reporter"
9879
- php_version: "8.3"
9980
swoole_version: "5.1.1"
100-
enable_zend_observer: "Off"
10181
cargo_features: ""
10282
- php_version: "8.4"
10383
swoole_version: "5.1.1"
104-
enable_zend_observer: "Off"
10584
cargo_features: ""
10685
- php_version: "8.5"
107-
swoole_version: "6.1.4"
108-
enable_zend_observer: "Off"
86+
swoole_version: "6.2.0"
10987
cargo_features: ""
11088

11189
runs-on: ${{ matrix.os }}
@@ -201,8 +179,6 @@ jobs:
201179
id: cargo-test-step
202180
run: |
203181
cargo test --release --workspace ${{ matrix.flag.cargo_features }}
204-
env:
205-
ENABLE_ZEND_OBSERVER: ${{ matrix.flag.enable_zend_observer }}
206182
continue-on-error: true
207183

208184
# Rebuild the mixture when cargo test failed.
@@ -222,8 +198,6 @@ jobs:
222198
if: steps.cargo-test-step.outcome != 'success'
223199
run: |
224200
cargo test --release --workspace
225-
env:
226-
ENABLE_ZEND_OBSERVER: ${{ matrix.flag.enable_zend_observer }}
227201
228202
- name: View logs
229203
if: always()

docs/en/configuration/ini-settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This is the configuration list supported in `php.ini`.
1919
| skywalking_agent.ssl_cert_chain_path | The certificate file. Enable mTLS when `ssl_key_path` and `ssl_cert_chain_path` exist. Only available when `reporter_type` is `grpc`. | |
2020
| skywalking_agent.heartbeat_period | Agent heartbeat report period. Unit, second. | 30 |
2121
| skywalking_agent.properties_report_period_factor | The agent sends the instance properties to the backend every heartbeat_period * properties_report_period_factor seconds. | 10 |
22-
| skywalking_agent.enable_zend_observer | Whether to use `zend observer` instead of `zend_execute_ex` to hook the functions, this feature is only available for PHP8+. | Off |
22+
| skywalking_agent.enable_zend_observer | Whether to use `zend observer` instead of `zend_execute_ex` to hook the functions, this feature is only available for PHP8+. | On |
2323
| skywalking_agent.reporter_type | Reporter type, optional values are `grpc`, `kafka` and `standalone`. | grpc |
2424
| skywalking_agent.kafka_bootstrap_servers | A list of host/port pairs to use for connect to the Kafka cluster. Only available when `reporter_type` is `kafka`. | |
2525
| skywalking_agent.kafka_producer_config | Configure Kafka Producer configuration in JSON format `{"key": "value}`. Only available when `reporter_type` is `kafka`. | {} |

docs/en/configuration/zend-observer.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Refer to: <https://www.datadoghq.com/blog/engineering/php-8-observability-baked-right-in/#the-observability-landscape-before-php-8>
44
5-
By default, skywalking-php hooks the `zend_execute_internal` and `zend_execute_ex` functions to implement auto instrumentation.
5+
On PHP 7, skywalking-php hooks the `zend_execute_internal` and `zend_execute_ex` functions to implement auto instrumentation.
66

77
But there are some drawbacks:
88

@@ -28,5 +28,6 @@ opcache.jit = tracing
2828
[skywalking_agent]
2929
extension = skywalking_agent.so
3030
; Switch to use zend observer api to implement auto instrumentation.
31+
; Default is On for PHP 8+.
3132
skywalking_agent.enable_zend_observer = On
3233
```

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub fn get_module() -> Module {
187187
10i64,
188188
Policy::System,
189189
);
190-
module.add_ini(SKYWALKING_AGENT_ENABLE_ZEND_OBSERVER, false, Policy::System);
190+
module.add_ini(SKYWALKING_AGENT_ENABLE_ZEND_OBSERVER, true, Policy::System);
191191
module.add_ini(
192192
SKYWALKING_AGENT_REPORTER_TYPE,
193193
"grpc".to_string(),

tests/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub const EXT: &str = if cfg!(target_os = "linux") {
7070
};
7171

7272
pub static ENABLE_ZEND_OBSERVER: Lazy<String> =
73-
Lazy::new(|| env::var("ENABLE_ZEND_OBSERVER").unwrap_or_else(|_| "Off".to_owned()));
73+
Lazy::new(|| env::var("ENABLE_ZEND_OBSERVER").unwrap_or_else(|_| "On".to_owned()));
7474

7575
pub static HTTP_CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new);
7676

0 commit comments

Comments
 (0)