Skip to content

Commit b62e7ef

Browse files
Merge branch 'main' into feature/add-opcache-instrumentation
2 parents bfdb728 + c876789 commit b62e7ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3001
-7
lines changed

.github/workflows/fossa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fossa:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1616

1717
- uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0
1818
with:

.github/workflows/ossf-scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
# Needed for GitHub OIDC token if publish_results is true
2020
id-token: write
2121
steps:
22-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2323
with:
2424
persist-credentials: false
2525

@@ -45,6 +45,6 @@ jobs:
4545
# Upload the results to GitHub's code scanning dashboard (optional).
4646
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
4747
- name: "Upload to code-scanning"
48-
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
48+
uses: github/codeql-action/upload-sarif@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.5
4949
with:
5050
sarif_file: results.sarif

.github/workflows/php.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
'Instrumentation/Psr16',
5252
'Instrumentation/Psr18',
5353
'Instrumentation/ReactPHP',
54+
'Instrumentation/Session',
5455
'Instrumentation/Slim',
5556
'Instrumentation/Symfony',
5657
'Instrumentation/Yii',
@@ -63,6 +64,7 @@ jobs:
6364
'ResourceDetectors/Container',
6465
'ResourceDetectors/DigitalOcean',
6566
'Sampler/RuleBased',
67+
'Sampler/Xray',
6668
'Shims/OpenTracing',
6769
'Symfony',
6870
'Utils/Test'
@@ -84,9 +86,10 @@ jobs:
8486
- project: 'Instrumentation/PostgreSql'
8587
php-version: 8.1
8688
- project: 'Instrumentation/PhpOpcache'
89+
- project: 'Instrumentation/Session'
8790
php-version: 8.1
8891
steps:
89-
- uses: actions/checkout@v4
92+
- uses: actions/checkout@v5
9093

9194
- name: Setup PHP
9295
uses: shivammathur/setup-php@v2

.github/workflows/update-dependabot-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Checkout code
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2222

2323
- name: Set up PHP
2424
uses: shivammathur/setup-php@v2

.gitsplit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ splits:
6262
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-psr18.git"
6363
- prefix: "src/Instrumentation/ReactPHP"
6464
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-reactphp.git"
65+
- prefix: "src/Instrumentation/Session"
66+
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-session.git"
6567
- prefix: "src/Instrumentation/Slim"
6668
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-slim.git"
6769
- prefix: "src/Instrumentation/Symfony"
@@ -90,6 +92,8 @@ splits:
9092
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-detector-digitalocean.git"
9193
- prefix: "src/Sampler/RuleBased"
9294
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-sampler-rulebased.git"
95+
- prefix: "src/Sampler/Xray"
96+
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-sampler-aws-xray.git"
9397
- prefix: "src/Shims/OpenTracing"
9498
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-shim-opentracing.git"
9599
- prefix: "src/Symfony"

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"OpenTelemetry\\Contrib\\Instrumentation\\Psr16\\": "src/Instrumentation/Psr16/src",
4242
"OpenTelemetry\\Contrib\\Instrumentation\\Psr18\\": "src/Instrumentation/Psr18/src",
4343
"OpenTelemetry\\Contrib\\Instrumentation\\ReactPHP\\": "src/Instrumentation/ReactPHP/src",
44+
"OpenTelemetry\\Contrib\\Instrumentation\\Session\\": "src/Instrumentation/Session/src",
4445
"OpenTelemetry\\Contrib\\Instrumentation\\Slim\\": "src/Instrumentation/Slim/src",
4546
"OpenTelemetry\\Contrib\\Instrumentation\\Symfony\\": "src/Instrumentation/Symfony/src",
4647
"OpenTelemetry\\Contrib\\Instrumentation\\Wordpress\\": "src/Instrumentation/Wordpress/src",
@@ -83,6 +84,7 @@
8384
"src/Instrumentation/Psr16/_register.php",
8485
"src/Instrumentation/Psr18/_register.php",
8586
"src/Instrumentation/ReactPHP/_register.php",
87+
"src/Instrumentation/Session/_register.php",
8688
"src/Instrumentation/Slim/_register.php",
8789
"src/Instrumentation/Symfony/_register.php",
8890
"src/Instrumentation/Wordpress/_register.php",
@@ -118,6 +120,7 @@
118120
"OpenTelemetry\\Instrumentation\\Psr14\\Tests\\": "src/Instrumentation/Psr14/tests",
119121
"OpenTelemetry\\Tests\\Instrumentation\\Psr16\\": "src/Instrumentation/Psr16/tests",
120122
"OpenTelemetry\\Tests\\Instrumentation\\ReactPHP\\": "src/Instrumentation/ReactPHP/tests",
123+
"OpenTelemetry\\Tests\\Instrumentation\\Session\\": "src/Instrumentation/Session/tests",
121124
"OpenTelemetry\\Tests\\Instrumentation\\Slim\\": "src/Instrumentation/Slim/tests",
122125
"OpenTelemetry\\Tests\\Instrumentation\\Symfony\\tests\\": "src/Instrumentation/Symfony/tests",
123126
"OpenTelemetry\\Tests\\Instrumentation\\Wordpress\\": "src/Instrumentation/Wordpress/tests",
@@ -160,6 +163,7 @@
160163
"open-telemetry/opentelemetry-auto-psr16": "self.version",
161164
"open-telemetry/opentelemetry-auto-psr18": "self.version",
162165
"open-telemetry/opentelemetry-auto-reactphp": "self.version",
166+
"open-telemetry/opentelemetry-auto-php-session": "self.version",
163167
"open-telemetry/opentelemetry-auto-slim": "self.version",
164168
"open-telemetry/opentelemetry-auto-symfony": "self.version",
165169
"open-telemetry/opentelemetry-auto-wordpress": "self.version",

src/Instrumentation/IO/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ following functions:
2222
- `file_put_contents`
2323
- `curl_init`
2424
- `curl_exec`
25+
- `ob_start`
26+
- `ob_clean`
27+
- `ob_flush`
28+
- `flush`
2529

2630
## Configuration
2731

2832
The extension can be disabled via [runtime configuration](https://opentelemetry.io/docs/instrumentation/php/sdk/#configuration):
2933

3034
```shell
3135
OTEL_PHP_DISABLED_INSTRUMENTATIONS=io
32-
```
36+
```

src/Instrumentation/IO/src/IOInstrumentation.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public static function register(): void
3333
self::_hook($instrumentation, null, 'file_get_contents', 'file_get_contents');
3434
self::_hook($instrumentation, null, 'file_put_contents', 'file_put_contents');
3535

36+
// Output buffer functions
37+
self::_hook($instrumentation, null, 'ob_start', 'ob_start');
38+
self::_hook($instrumentation, null, 'ob_clean', 'ob_clean');
39+
self::_hook($instrumentation, null, 'ob_flush', 'ob_flush');
40+
self::_hook($instrumentation, null, 'flush', 'flush');
41+
3642
self::_hook($instrumentation, null, 'curl_init', 'curl_init');
3743
self::_hook($instrumentation, null, 'curl_exec', 'curl_exec');
3844
}
@@ -109,6 +115,19 @@ private static function addParams(SpanBuilderInterface $builder, string $functio
109115
case 'file_put_contents':
110116
$builder->setAttribute('code.params.filename', $params[0]);
111117

118+
break;
119+
case 'ob_start':
120+
if (isset($params[0]) && is_callable($params[0])) {
121+
// We can't directly serialize the callback, so we'll just note that one was provided
122+
$builder->setAttribute('code.params.has_callback', true);
123+
}
124+
if (isset($params[1])) {
125+
$builder->setAttribute('code.params.chunk_size', $params[1]);
126+
}
127+
if (isset($params[2])) {
128+
$builder->setAttribute('code.params.flags', $params[2]);
129+
}
130+
112131
break;
113132
}
114133
}

src/Instrumentation/IO/tests/Integration/IOInstrumentationTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function setUp(): void
3737
public function tearDown(): void
3838
{
3939
$this->scope->detach();
40+
// Clean up any output buffers that might have been started during tests
41+
while (ob_get_level() > 0) {
42+
ob_end_clean();
43+
}
4044
}
4145

4246
public function test_io_calls(): void
@@ -83,4 +87,44 @@ public function test_io_calls(): void
8387
$this->span = $this->storage->offsetGet(6);
8488
$this->assertSame('curl_exec', $this->span->getName());
8589
}
90+
91+
public function test_output_buffer_calls(): void
92+
{
93+
// Make sure we start with a clean state
94+
while (ob_get_level() > 0) {
95+
ob_end_clean();
96+
}
97+
// Test ob_start with parameters
98+
$callback = function ($buffer) {
99+
return $buffer;
100+
};
101+
ob_start($callback, 4096, PHP_OUTPUT_HANDLER_STDFLAGS);
102+
$this->assertCount(1, $this->storage);
103+
$this->span = $this->storage->offsetGet(0);
104+
$this->assertSame('ob_start', $this->span->getName());
105+
$this->assertTrue($this->span->getAttributes()->get('code.params.has_callback'));
106+
$this->assertSame(4096, $this->span->getAttributes()->get('code.params.chunk_size'));
107+
$this->assertSame(PHP_OUTPUT_HANDLER_STDFLAGS, $this->span->getAttributes()->get('code.params.flags'));
108+
109+
// Test ob_clean
110+
ob_clean();
111+
$this->assertCount(2, $this->storage);
112+
$this->span = $this->storage->offsetGet(1);
113+
$this->assertSame('ob_clean', $this->span->getName());
114+
115+
// Test ob_flush
116+
ob_flush();
117+
$this->assertCount(3, $this->storage);
118+
$this->span = $this->storage->offsetGet(2);
119+
$this->assertSame('ob_flush', $this->span->getName());
120+
121+
// Test flush
122+
flush();
123+
$this->assertCount(4, $this->storage);
124+
$this->span = $this->storage->offsetGet(3);
125+
$this->assertSame('flush', $this->span->getName());
126+
127+
// Clean up
128+
ob_end_clean();
129+
}
86130
}

src/Instrumentation/Laravel/.phan/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//
4343
// Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
4444
// (See `backward_compatibility_checks` for additional options)
45-
'target_php_version' => '8.0',
45+
'target_php_version' => '8.1',
4646

4747
// If enabled, missing properties will be created when
4848
// they are first seen. If false, we'll report an

0 commit comments

Comments
 (0)