Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
'Instrumentation/MySqli',
'Instrumentation/OpenAIPHP',
'Instrumentation/PDO',
'Instrumentation/PostgreSql',
# Sort PSRs numerically.
'Instrumentation/Psr3',
'Instrumentation/Psr6',
Expand Down Expand Up @@ -78,6 +79,8 @@ jobs:
php-version: 8.1
- project: 'Instrumentation/PDO'
php-version: 8.1
- project: 'Instrumentation/PostgreSql'
php-version: 8.1
steps:
- uses: actions/checkout@v4

Expand All @@ -86,7 +89,7 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug
extensions: ast, amqp, grpc, opentelemetry, rdkafka, mysqli
extensions: ast, amqp, grpc, opentelemetry, rdkafka, mysqli, pgsql

- name: Validate composer.json and composer.lock
run: composer validate
Expand Down Expand Up @@ -151,6 +154,11 @@ jobs:
run: |
docker compose up mysql -d --wait

- name: Start PostgreSql
if: ${{ matrix.project == 'Instrumentation/PostgreSql' }}
run: |
docker compose up postgresql -d --wait

- name: Run PHPUnit
working-directory: src/${{ matrix.project }}
run: vendor/bin/phpunit
Expand Down
2 changes: 2 additions & 0 deletions .gitsplit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ splits:
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-openai.git"
- prefix: "src/Instrumentation/PDO"
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-pdo.git"
- prefix: "src/Instrumentation/PostgreSql"
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-postgresql.git"
- prefix: "src/Instrumentation/Psr3"
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/contrib-auto-psr3.git"
- prefix: "src/Instrumentation/Psr6"
Expand Down
18 changes: 18 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
MONGODB_HOST: ${MONGODB_HOST:-mongodb}
MONGODB_PORT: ${MONGODB_PORT:-27017}
MYSQL_HOST: ${MYSQL_HOST:-mysql}
POSTGRESQL_HOST: ${POSTGRESQL_HOST:-postgresql}

zipkin:
image: openzipkin/zipkin-slim
Expand Down Expand Up @@ -88,3 +89,20 @@ services:
retries: 3
volumes:
- ./docker/mysql/init.sql:/docker-entrypoint-initdb.d/init.sql

postgresql:
image: postgres:17.5
hostname: postgresql
ports:
- "5432:5432/tcp"
environment:
POSTGRES_DB: otel_db
POSTGRES_USER: otel_user
POSTGRES_PASSWORD: otel_passwd
healthcheck:
test: ["CMD-SHELL", "PGPASSWORD=otel_passwd psql -U otel_user -d otel_db -h 127.0.0.1 -c 'SELECT 1'"]
interval: 30s
timeout: 90s
retries: 3
volumes:
- ./docker/postgresql/init.sql:/docker-entrypoint-initdb.d/init.sql
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN install-php-extensions \
mongodb \
amqp \
rdkafka \
mysqli
mysqli \
pgsql

USER php
34 changes: 34 additions & 0 deletions docker/postgresql/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

CREATE DATABASE otel_db2;

\connect otel_db2;

CREATE USER otel_user2 WITH PASSWORD 'otel_passwd';

GRANT ALL PRIVILEGES ON DATABASE otel_db2 TO otel_user2;

\connect otel_db;

CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO users (name, email) VALUES
('John Doe', 'john.doe@example.com'),
('Jane Smith', 'jane.smith@example.com'),
('Bob Johnson', 'bob.johnson@example.com');

CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
price NUMERIC(10, 2) NOT NULL,
stock INT NOT NULL DEFAULT 0
);

INSERT INTO products (name, price, stock) VALUES
('Laptop', 999.99, 10),
('Smartphone', 499.99, 25),
('Headphones', 49.99, 50);
12 changes: 12 additions & 0 deletions src/Instrumentation/PostgreSql/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
* text=auto

*.md diff=markdown
*.php diff=php

/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/tests export-ignore
1 change: 1 addition & 0 deletions src/Instrumentation/PostgreSql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
Loading
Loading