Skip to content

Commit 4231acd

Browse files
Merge remote-tracking branch 'upstream/main' into spi/laravel
2 parents ea2e4bb + b10cb8d commit 4231acd

File tree

68 files changed

+2753
-290
lines changed

Some content is hidden

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

68 files changed

+2753
-290
lines changed

.github/workflows/php.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
'Aws',
2424
'Context/Swoole',
2525
'Instrumentation/ExtAmqp',
26+
'Instrumentation/ExtRdKafka',
2627
'Instrumentation/Guzzle',
2728
'Instrumentation/HttpAsyncClient',
2829
'Instrumentation/Slim',
@@ -94,6 +95,12 @@ jobs:
9495
php-version: 8.0
9596
- project: 'Instrumentation/ExtAmqp'
9697
php-version: 8.1
98+
- project: 'Instrumentation/ExtRdKafka'
99+
php-version: 7.4
100+
- project: 'Instrumentation/ExtRdKafka'
101+
php-version: 8.0
102+
- project: 'Instrumentation/ExtRdKafka'
103+
php-version: 8.1
97104
- project: 'Instrumentation/OpenAIPHP'
98105
php-version: 7.4
99106
- project: 'Instrumentation/OpenAIPHP'
@@ -112,7 +119,7 @@ jobs:
112119
with:
113120
php-version: ${{ matrix.php-version }}
114121
coverage: xdebug
115-
extensions: ast, amqp, grpc, opentelemetry
122+
extensions: ast, amqp, grpc, opentelemetry, rdkafka
116123

117124
- name: Validate composer.json and composer.lock
118125
run: composer validate
@@ -167,6 +174,11 @@ jobs:
167174
run: |
168175
docker compose up rabbitmq -d --wait
169176
177+
- name: Start Kafka
178+
if: ${{ matrix.project == 'Instrumentation/ExtRdKafka' }}
179+
run: |
180+
KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092 docker compose up kafka -d --wait
181+
170182
- name: Run PHPUnit
171183
working-directory: src/${{ matrix.project }}
172184
run: vendor/bin/phpunit
@@ -177,9 +189,11 @@ jobs:
177189

178190
- name: Code Coverage
179191
uses: codecov/codecov-action@v4
192+
# only generate coverage against the latest PHP version
193+
if: ${{ matrix.php-version == '8.3' }}
180194
with:
181195
token: ${{ secrets.CODECOV_TOKEN }}
182196
directory: src/${{ matrix.project }}
183197
files: ./coverage.clover
184-
flags: ${{ matrix.project }}:${{ matrix.php-version }}
198+
flags: ${{ matrix.project }}
185199
verbose: false

.gitsplit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ splits:
1616
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-codeigniter.git"
1717
- prefix: "src/Instrumentation/ExtAmqp"
1818
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-ext-amqp.git"
19+
- prefix: "src/Instrumentation/ExtRdKafka"
20+
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-ext-rdkafka.git"
1921
- prefix: "src/Instrumentation/Guzzle"
2022
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-guzzle.git"
2123
- prefix: "src/Instrumentation/HttpAsyncClient"

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"OpenTelemetry\\Contrib\\Aws\\": "src/Aws/src",
1919
"OpenTelemetry\\Contrib\\Context\\Swoole\\": "src/Context/Swoole/src",
2020
"OpenTelemetry\\Contrib\\Instrumentation\\ExtAmqp\\": "src/Instrumentation/ExtAmqp/src",
21+
"OpenTelemetry\\Contrib\\Instrumentation\\ExtRdKafka\\": "src/Instrumentation/ExtRdKafka/src",
2122
"OpenTelemetry\\Contrib\\Instrumentation\\Laravel\\": "src/Instrumentation/Laravel/src",
2223
"OpenTelemetry\\Contrib\\Instrumentation\\HttpAsyncClient\\": "src/Instrumentation/HttpAsyncClient/src",
2324
"OpenTelemetry\\Contrib\\Instrumentation\\IO\\": "src/Instrumentation/IO/src",
@@ -39,6 +40,7 @@
3940
},
4041
"files": [
4142
"src/Instrumentation/ExtAmqp/_register.php",
43+
"src/Instrumentation/ExtRdKafka/_register.php",
4244
"src/Instrumentation/HttpAsyncClient/_register.php",
4345
"src/Instrumentation/IO/_register.php",
4446
"src/Instrumentation/Laravel/_register.php",

docker-compose.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
XDEBUG_CONFIG: ${XDEBUG_CONFIG:-''}
1414
PHP_IDE_CONFIG: ${PHP_IDE_CONFIG:-''}
1515
RABBIT_HOST: ${RABBIT_HOST:-rabbitmq}
16+
KAFKA_HOST: ${KAFKA_HOST:-kafka}
1617

1718
zipkin:
1819
image: openzipkin/zipkin-slim
@@ -42,3 +43,22 @@ services:
4243
retries: 3
4344
ports:
4445
- "5672:5672/tcp"
46+
kafka:
47+
image: confluentinc/cp-kafka:7.2.1
48+
hostname: kafka
49+
ports:
50+
- "9092:9092/tcp"
51+
environment:
52+
KAFKA_PROCESS_ROLES: 'broker,controller'
53+
KAFKA_NODE_ID: 1
54+
KAFKA_ADVERTISED_LISTENERS: ${KAFKA_ADVERTISED_LISTENERS:-PLAINTEXT://kafka:29092,PLAINTEXT_HOST://kafka:9092}
55+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
56+
KAFKA_LISTENERS: 'PLAINTEXT://kafka:29092,CONTROLLER://kafka:29093,PLAINTEXT_HOST://0.0.0.0:9092'
57+
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
58+
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka:29093'
59+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
60+
command: "bash -c '/tmp/update_run.sh && /etc/confluent/docker/run'"
61+
volumes:
62+
- ./docker/kafka/update_run.sh:/tmp/update_run.sh
63+
64+

docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ USER root
66
RUN install-php-extensions \
77
opentelemetry \
88
mongodb \
9-
amqp
9+
amqp \
10+
rdkafka
1011

1112
USER php

docker/kafka/update_run.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This script is required to run kafka cluster (without zookeeper)
2+
#!/bin/sh
3+
4+
# Docker workaround: Remove check for KAFKA_ZOOKEEPER_CONNECT parameter
5+
sed -i '/KAFKA_ZOOKEEPER_CONNECT/d' /etc/confluent/docker/configure
6+
7+
# Docker workaround: Ignore cub zk-ready
8+
sed -i 's/cub zk-ready/echo ignore zk-ready/' /etc/confluent/docker/ensure
9+
10+
# KRaft required step: Format the storage directory with a new cluster ID
11+
echo "kafka-storage format --ignore-formatted -t $(kafka-storage random-uuid) -c /etc/kafka/kafka.properties" >> /etc/confluent/docker/ensure

src/Aws/src/Xray/Propagator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function fields(): array
7373
* X-Amzn-Trace-Id: Root={traceId};Parent={parentId};Sampled={samplingFlag}
7474
* X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1
7575
*/
76-
public function inject(&$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void
76+
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
7777
{
7878
$setter = $setter ?? ArrayAccessGetterSetter::getInstance();
7979
$context = $context ?? Context::getCurrent();
@@ -102,7 +102,7 @@ public function inject(&$carrier, PropagationSetterInterface $setter = null, Con
102102
* This function will parse all parts of the header and validate that it is
103103
* formatted properly to AWS X-ray standards
104104
*/
105-
public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface
105+
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface
106106
{
107107
$getter = $getter ?? ArrayAccessGetterSetter::getInstance();
108108
$context = $context ?? Context::getCurrent();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/vendor/
2+
/tests/Integration/App/tmp/

src/Instrumentation/CakePHP/composer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@
2525
"phpstan/phpstan-phpunit": "^1.0",
2626
"psalm/plugin-phpunit": "^0.18.4",
2727
"open-telemetry/sdk": "^1.0",
28-
"phpunit/phpunit": "^9.5",
28+
"phpunit/phpunit": "^9.5|^10.5",
2929
"vimeo/psalm": "^5.24",
3030
"symfony/http-client": "^6 || ^7"
3131
},
32+
"suggest": {
33+
"open-telemetry/opentelemetry-auto-psr3": "OpenTelemetry auto-instrumentation for PSR-3 (Logger Interface)",
34+
"open-telemetry/opentelemetry-auto-psr18": "OpenTelemetry auto-instrumentation for PSR-18 (HTTP Client)",
35+
"open-telemetry/opentelemetry-auto-psr15": "OpenTelemetry auto-instrumentation for PSR-15 (HTTP Server Request Handlers)",
36+
"open-telemetry/opentelemetry-auto-pdo": "OpenTelemetry auto-instrumentation for PDO"
37+
},
3238
"autoload": {
3339
"psr-4": {
3440
"OpenTelemetry\\Contrib\\Instrumentation\\CakePHP\\": "src/"
@@ -48,4 +54,4 @@
4854
"php-http/discovery": true
4955
}
5056
}
51-
}
57+
}
Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
6-
backupGlobals="false"
7-
backupStaticAttributes="false"
8-
cacheResult="false"
9-
colors="false"
10-
convertErrorsToExceptions="true"
11-
convertNoticesToExceptions="true"
12-
convertWarningsToExceptions="true"
13-
forceCoversAnnotation="false"
14-
processIsolation="false"
15-
stopOnError="false"
16-
stopOnFailure="false"
17-
stopOnIncomplete="false"
18-
stopOnSkipped="false"
19-
stopOnRisky="false"
20-
timeoutForSmallTests="1"
21-
timeoutForMediumTests="10"
22-
timeoutForLargeTests="60"
23-
verbose="true">
24-
25-
<coverage processUncoveredFiles="true" disableCodeCoverageIgnore="false">
26-
<include>
27-
<directory>src</directory>
28-
</include>
29-
</coverage>
30-
31-
<php>
32-
<ini name="date.timezone" value="UTC" />
33-
<ini name="display_errors" value="On" />
34-
<ini name="display_startup_errors" value="On" />
35-
<ini name="error_reporting" value="E_ALL" />
36-
</php>
37-
38-
<testsuites>
39-
<testsuite name="unit">
40-
<directory>tests/Unit</directory>
41-
</testsuite>
42-
<testsuite name="integration">
43-
<directory>tests/Integration</directory>
44-
</testsuite>
45-
</testsuites>
46-
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="tests/bootstrap.php" cacheResult="false" colors="false" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" stopOnRisky="false" timeoutForSmallTests="1" timeoutForMediumTests="10" timeoutForLargeTests="60" cacheDirectory=".phpunit.cache" backupStaticProperties="false" requireCoverageMetadata="false">
3+
<php>
4+
<ini name="date.timezone" value="UTC"/>
5+
<ini name="display_errors" value="On"/>
6+
<ini name="display_startup_errors" value="On"/>
7+
<ini name="error_reporting" value="E_ALL"/>
8+
</php>
9+
<testsuites>
10+
<testsuite name="unit">
11+
<directory>tests/Unit</directory>
12+
</testsuite>
13+
<testsuite name="integration">
14+
<directory>tests/Integration</directory>
15+
</testsuite>
16+
</testsuites>
17+
<source>
18+
<include>
19+
<directory>src</directory>
20+
</include>
21+
</source>
4722
</phpunit>

0 commit comments

Comments
 (0)