Skip to content

Commit 552df1f

Browse files
committed
PostgreSQL instrumentation
1 parent 93c363a commit 552df1f

File tree

10 files changed

+722
-0
lines changed

10 files changed

+722
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
* text=auto
2+
3+
*.md diff=markdown
4+
*.php diff=php
5+
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/.php-cs-fixer.php export-ignore
9+
/phpstan.neon.dist export-ignore
10+
/phpunit.xml.dist export-ignore
11+
/psalm.xml.dist export-ignore
12+
/tests export-ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->exclude('vendor')
4+
->exclude('var/cache')
5+
->in(__DIR__);
6+
7+
$config = new PhpCsFixer\Config();
8+
return $config->setRules([
9+
'concat_space' => ['spacing' => 'one'],
10+
'declare_equal_normalize' => ['space' => 'none'],
11+
'is_null' => true,
12+
'modernize_types_casting' => true,
13+
'ordered_imports' => true,
14+
'php_unit_construct' => true,
15+
'single_line_comment_style' => true,
16+
'yoda_style' => false,
17+
'@PSR2' => true,
18+
'array_syntax' => ['syntax' => 'short'],
19+
'blank_line_after_opening_tag' => true,
20+
'blank_line_before_statement' => true,
21+
'cast_spaces' => true,
22+
'declare_strict_types' => true,
23+
'type_declaration_spaces' => true,
24+
'include' => true,
25+
'lowercase_cast' => true,
26+
'new_with_parentheses' => true,
27+
'no_extra_blank_lines' => true,
28+
'no_leading_import_slash' => true,
29+
'echo_tag_syntax' => true,
30+
'no_unused_imports' => true,
31+
'no_useless_else' => true,
32+
'no_useless_return' => true,
33+
'phpdoc_order' => true,
34+
'phpdoc_scalar' => true,
35+
'phpdoc_types' => true,
36+
'short_scalar_cast' => true,
37+
'blank_lines_before_namespace' => true,
38+
'single_quote' => true,
39+
'trailing_comma_in_multiline' => true,
40+
])
41+
->setRiskyAllowed(true)
42+
->setFinder($finder);
43+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OpenTelemetry\Contrib\Instrumentation\PostgreSql\PostgreSqlInstrumentation;
6+
use OpenTelemetry\SDK\Sdk;
7+
8+
if (class_exists(Sdk::class) && Sdk::isInstrumentationDisabled(PostgreSqlInstrumentation::NAME) === true) {
9+
return;
10+
}
11+
12+
if (extension_loaded('opentelemetry') === false) {
13+
trigger_error('The opentelemetry extension must be loaded in order to autoload the OpenTelemetry postgresql auto-instrumentation', E_USER_WARNING);
14+
15+
return;
16+
}
17+
18+
PostgreSqlInstrumentation::register();
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "open-telemetry/opentelemetry-auto-postgresql",
3+
"version": "dev-main",
4+
"description": "OpenTelemetry auto-instrumentation for postgresql",
5+
"keywords": [
6+
"opentelemetry",
7+
"otel",
8+
"open-telemetry",
9+
"tracing",
10+
"postgresql",
11+
"instrumentation"
12+
],
13+
"type": "library",
14+
"homepage": "https://opentelemetry.io/docs/php",
15+
"readme": "./README.md",
16+
"license": "Apache-2.0",
17+
"minimum-stability": "dev",
18+
"prefer-stable": true,
19+
"require": {
20+
"php": "^8.2",
21+
"ext-pgsql": "*",
22+
"ext-opentelemetry": "*",
23+
"open-telemetry/api": "^1.0",
24+
"open-telemetry/sem-conv": "^1.30",
25+
"symfony/polyfill-mbstring": "^1.31"
26+
},
27+
"suggest": {
28+
"ext-mbstring": "For better performance than symfony/polyfill-mbstring"
29+
},
30+
"require-dev": {
31+
"friendsofphp/php-cs-fixer": "^3",
32+
"phan/phan": "^5.0",
33+
"php-http/mock-client": "*",
34+
"phpstan/phpstan": "^1.1",
35+
"phpstan/phpstan-phpunit": "^1.0",
36+
"psalm/plugin-phpunit": "^0.19.2",
37+
"open-telemetry/sdk": "^1.0",
38+
"phpunit/phpunit": "^9.5",
39+
"vimeo/psalm": "6.4.0"
40+
},
41+
"autoload": {
42+
"psr-4": {
43+
"OpenTelemetry\\Contrib\\Instrumentation\\PostgreSql\\": "src/"
44+
},
45+
"files": [
46+
"_register.php"
47+
]
48+
},
49+
"autoload-dev": {
50+
"psr-4": {
51+
"OpenTelemetry\\Tests\\Instrumentation\\PostgreSql\\": "tests/"
52+
}
53+
},
54+
"config": {
55+
"allow-plugins": {
56+
"php-http/discovery": false
57+
}
58+
}
59+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
includes:
2+
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
4+
parameters:
5+
tmpDir: var/cache/phpstan
6+
level: 5
7+
paths:
8+
- src
9+
- tests
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?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+
47+
</phpunit>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="3"
4+
cacheDirectory="var/cache/psalm"
5+
findUnusedBaselineEntry="true"
6+
findUnusedCode="false"
7+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8+
xmlns="https://getpsalm.org/schema/config"
9+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
10+
<projectFiles>
11+
<directory name="src"/>
12+
<directory name="tests"/>
13+
</projectFiles>
14+
<plugins>
15+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
16+
</plugins>
17+
</psalm>

0 commit comments

Comments
 (0)