Skip to content

Commit 4137e37

Browse files
committed
adding apache, fpm, k8s resource detectors
this ports the detectors from open-telemetry/opentelemetry-php#1628 into contrib
1 parent 3d6f839 commit 4137e37

36 files changed

+2946
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
* text=auto
2+
3+
*.md diff=markdown
4+
*.php diff=php
5+
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/.phan export-ignore
9+
/.php-cs-fixer.php export-ignore
10+
/coverage.clover export-ignore
11+
/phpstan.neon.dist export-ignore
12+
/phpstan.neon.dist export-ignore
13+
/phpunit.xml.dist export-ignore
14+
/psalm.xml.dist export-ignore
15+
/tests export-ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

src/ResourceDetectors/Apache/.phan/config.php

Lines changed: 371 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->exclude('vendor')
4+
->exclude('var/cache')
5+
->exclude('proto')
6+
->in(__DIR__);
7+
8+
$config = new PhpCsFixer\Config();
9+
return $config->setRules([
10+
'concat_space' => ['spacing' => 'one'],
11+
'declare_equal_normalize' => ['space' => 'none'],
12+
'is_null' => true,
13+
'modernize_types_casting' => true,
14+
'ordered_imports' => true,
15+
'php_unit_construct' => true,
16+
'single_line_comment_style' => true,
17+
'yoda_style' => false,
18+
'@PSR2' => true,
19+
'array_syntax' => ['syntax' => 'short'],
20+
'blank_line_after_opening_tag' => true,
21+
'blank_line_before_statement' => true,
22+
'cast_spaces' => true,
23+
'declare_strict_types' => true,
24+
'type_declaration_spaces' => true,
25+
'include' => true,
26+
'lowercase_cast' => true,
27+
'new_with_parentheses' => true,
28+
'no_extra_blank_lines' => true,
29+
'no_leading_import_slash' => true,
30+
'echo_tag_syntax' => true,
31+
'no_unused_imports' => true,
32+
'no_useless_else' => true,
33+
'no_useless_return' => true,
34+
'phpdoc_order' => true,
35+
'phpdoc_scalar' => true,
36+
'phpdoc_types' => true,
37+
'short_scalar_cast' => true,
38+
'blank_lines_before_namespace' => true,
39+
'single_quote' => true,
40+
'trailing_comma_in_multiline' => true,
41+
])
42+
->setRiskyAllowed(true)
43+
->setFinder($finder);
44+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[![Releases](https://img.shields.io/badge/releases-purple)](https://github.com/opentelemetry-php/contrib-aws/releases)
2+
[![Issues](https://img.shields.io/badge/issues-pink)](https://github.com/open-telemetry/opentelemetry-php/issues)
3+
[![Source](https://img.shields.io/badge/source-contrib-green)](https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Azure)
4+
[![Mirror](https://img.shields.io/badge/mirror-opentelemetry--php--contrib-blue)](https://github.com/opentelemetry-php/detector-azure)
5+
[![Latest Version](http://poser.pugx.org/open-telemetry/detector-azure/v/unstable)](https://packagist.org/packages/open-telemetry/detector-azure/)
6+
[![Stable](http://poser.pugx.org/open-telemetry/detector-azure/v/stable)](https://packagist.org/packages/open-telemetry/detector-azure/)
7+
8+
This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.
9+
10+
# OpenTelemetry Apache Resource Detectors
11+
12+
This package provides OpenTelemetry `ResourceDetector`s which will detect a stable service instance id.
13+
14+
## Installation via composer
15+
16+
```bash
17+
$ composer require open-telemetry/detector-apache
18+
```
19+
20+
## Usage
21+
22+
The detector will be automatically registered as part of composer autoloading.
23+
24+
By default, all built-in and registered custom resource detectors are used, and will be added to the default resources associated with traces, metrics, and logs.
25+
26+
You can also provide a list of detectors via the `OTEL_PHP_DETECTORS` config (environment variable or php.ini setting):
27+
```php
28+
putenv('OTEL_PHP_DETECTORS=apache,env,os,<others>')
29+
30+
var_dump(ResourceInfoFactory::defaultResource());
31+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OpenTelemetry\SDK\Registry;
6+
7+
Registry::registerResourceDetector('apache', new OpenTelemetry\Contrib\Resource\Detector\Apache\Apache());
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "open-telemetry/detector-apache",
3+
"description": "OpenTelemetry Apache resource detector",
4+
"keywords": ["opentelemetry", "otel", "open-telemetry", "detector", "apache"],
5+
"type": "library",
6+
"homepage": "https://opentelemetry.io/docs/php",
7+
"readme": "./README.md",
8+
"license": "Apache-2.0",
9+
"minimum-stability": "dev",
10+
"prefer-stable": true,
11+
"require": {
12+
"php": "^8.1",
13+
"open-telemetry/sdk": "^1.0",
14+
"open-telemetry/sem-conv": "^1.36",
15+
"ramsey/uuid": "^3.0 || ^4.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"OpenTelemetry\\Contrib\\Resource\\Detector\\Apache\\": "src/"
20+
},
21+
"files": [
22+
"_register.php"
23+
]
24+
},
25+
"require-dev": {
26+
"friendsofphp/php-cs-fixer": "^3",
27+
"mikey179/vfsstream": "^1.6.11",
28+
"phan/phan": "^5.0",
29+
"phpstan/phpstan": "^1.1",
30+
"phpstan/phpstan-phpunit": "^1.0",
31+
"psalm/plugin-phpunit": "^0.19.2",
32+
"phpunit/phpunit": "*",
33+
"vimeo/psalm": "6.4.0",
34+
"symfony/http-client": "^5.4|^6.0",
35+
"guzzlehttp/promises": "^1.5|^2",
36+
"php-http/message-factory": "^1.0",
37+
"nyholm/psr7": "^1.5"
38+
},
39+
"config": {
40+
"allow-plugins": {
41+
"php-http/discovery": true
42+
}
43+
}
44+
}
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" backupGlobals="false" 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+
</testsuites>
14+
<source>
15+
<include>
16+
<directory>src</directory>
17+
</include>
18+
</source>
19+
</phpunit>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="3"
4+
cacheDirectory="var/cache/psalm"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
8+
<projectFiles>
9+
<directory name="src"/>
10+
<directory name="tests"/>
11+
</projectFiles>
12+
<plugins>
13+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
14+
</plugins>
15+
</psalm>

0 commit comments

Comments
 (0)