Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
673f2f9
[aws-sdk]Added Initial auto-instrumentation library for aws-sdk
AsakerMohd Apr 24, 2025
28a512e
Updated to use sem covs instead of hardcoding
AsakerMohd Apr 29, 2025
057e7d1
Merge branch 'open-telemetry:main' into main
AsakerMohd May 13, 2025
45224ce
added to gitsplit
AsakerMohd May 13, 2025
be7848e
added gitattributes file
AsakerMohd May 13, 2025
1cdadb9
Merge branch 'open-telemetry:main' into main
AsakerMohd May 14, 2025
5f3a9ed
Updated to use the latest semcov 1.32
AsakerMohd May 14, 2025
660c52f
Merge branch 'open-telemetry:main' into main
AsakerMohd May 15, 2025
500afb6
Added aws tests to php.yml
AsakerMohd May 15, 2025
ad6926c
Merge branch 'main' of https://github.com/AsakerMohd/opentelemetry-ph…
AsakerMohd May 15, 2025
ce36434
Merge branch 'open-telemetry:main' into main
AsakerMohd May 21, 2025
9a94008
Updated composer for php 8.1 and fixed style issue
AsakerMohd May 21, 2025
4fbd13e
Fixed psalm errors
AsakerMohd May 22, 2025
1a01849
Merge branch 'open-telemetry:main' into main
AsakerMohd May 22, 2025
942b7b1
initial sampler implementation
AsakerMohd May 23, 2025
3a8d4d0
Updated sampler code
AsakerMohd Jul 7, 2025
afb8528
Merge branch 'main' into xraySampler2
AsakerMohd Jul 7, 2025
8035f6f
added unit tests
AsakerMohd Jul 9, 2025
10dc6b5
updated README
AsakerMohd Jul 10, 2025
21e9312
Merge branch 'main' into xraySampler2
AsakerMohd Jul 10, 2025
f9174d2
updated after running style checks
AsakerMohd Jul 10, 2025
038731f
updated more files
AsakerMohd Jul 10, 2025
6b2801c
Fixed build issues
AsakerMohd Jul 11, 2025
bd1b9d0
added gitkeep file
AsakerMohd Jul 11, 2025
038bcbf
used otel clock instead of new class
AsakerMohd Jul 16, 2025
b222507
added entry to gitsplit
AsakerMohd Aug 26, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
'ResourceDetectors/Container',
'ResourceDetectors/DigitalOcean',
'Sampler/RuleBased',
'Sampler/Xray',
'Shims/OpenTracing',
'Symfony',
'Utils/Test'
Expand Down
13 changes: 13 additions & 0 deletions src/Sampler/Xray/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* text=auto

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

/.gitattributes export-ignore
/.gitignore export-ignore
/.phan 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
6 changes: 6 additions & 0 deletions src/Sampler/Xray/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
composer.lock

.phpunit.cache

var
vendor
370 changes: 370 additions & 0 deletions src/Sampler/Xray/.phan/config.php

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions src/Sampler/Xray/.php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('var/cache')
->in(__DIR__);

$config = new PhpCsFixer\Config();
return $config->setRules([
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'is_null' => true,
'modernize_types_casting' => true,
'ordered_imports' => true,
'php_unit_construct' => true,
'single_line_comment_style' => true,
'yoda_style' => false,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'cast_spaces' => true,
'declare_strict_types' => true,
'type_declaration_spaces' => true,
'include' => true,
'lowercase_cast' => true,
'new_with_parentheses' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'echo_tag_syntax' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_types' => true,
'short_scalar_cast' => true,
'blank_lines_before_namespace' => true,
'single_quote' => true,
'trailing_comma_in_multiline' => true,
])
->setRiskyAllowed(true)
->setFinder($finder);

51 changes: 51 additions & 0 deletions src/Sampler/Xray/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# AWS X-Ray Sampler

Provides a sampler which can get sampling configurations from AWS X-Ray to make sampling decisions. See: [AWS X-Ray Sampling](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-sampling)

## Installation

```shell
composer require open-telemetry/contrib-aws-xray-sampler
```

## Configuration
You can configure the `AWSXRayRemoteSampler` as per the following example.
Note that you will need to configure your [OpenTelemetry Collector for
X-Ray remote sampling](https://aws-otel.github.io/docs/getting-started/remote-sampling).

```php
<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use OpenTelemetry\SDK\Trace\TracerProvider;
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Trace\SpanExporter\ConsoleSpanExporterFactory;
use OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor;
use OpenTelemetry\SDK\Resource\ResourceInfo;
use OpenTelemetry\Contrib\Sampler\Xray\AWSXRayRemoteSampler;

$resource = ResourceInfo::create(Attributes::create([
'service.name' => 'MyServiceName',
'service.version'=> '1.0.0',
'cloud.provider' => 'aws',
]));

$xraySampler = new AWSXRayRemoteSampler(
$resource,
'http://localhost:2000',
2
);

$tracerProvider = TracerProvider::builder()
->setResource($resource)
->setSampler($xraySampler)
->addSpanProcessor(
new SimpleSpanProcessor(
(new ConsoleSpanExporterFactory())->create()
)
)
->build();
```
39 changes: 39 additions & 0 deletions src/Sampler/Xray/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "open-telemetry/contrib-aws-xray-sampler",
"description": "AWS X-Ray Remote Sampler for OpenTelemetry PHP Contrib",
"type": "library",
"license": "Apache-2.0",
"require": {
"php": "^8.1",
"aws/aws-sdk-php": "^3.0",
"open-telemetry/api": "^1.1.0",
"open-telemetry/sdk": "^1.1.0",
"open-telemetry/sdk-configuration": "^0.0.5",
"open-telemetry/sem-conv": "^1.32"
},
"require-dev": {
"symfony/config": "^5.4 || ^6.4 || ^7.0",
"symfony/yaml": "^6 || ^7",
"friendsofphp/php-cs-fixer": "^3",
"phan/phan": "^5.0",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"psalm/plugin-phpunit": "^0.19.2",
"phpunit/phpunit": "^10 || ^11",
"vimeo/psalm": "^4|^5|6.4.0"
},
"autoload": {
"psr-4": {
"OpenTelemetry\\Contrib\\Sampler\\Xray\\": "src/"
},
"classmap": ["src/AWSXRayRemoteSampler.php"]
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"php-http/discovery": true,
"tbachert/spi": true
}
}
}
9 changes: 9 additions & 0 deletions src/Sampler/Xray/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
tmpDir: var/cache/phpstan
level: 5
paths:
- src
- tests
22 changes: 22 additions & 0 deletions src/Sampler/Xray/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.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">
<php>
<ini name="date.timezone" value="UTC"/>
<ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/>
<ini name="error_reporting" value="E_ALL"/>
</php>
<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
15 changes: 15 additions & 0 deletions src/Sampler/Xray/psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="3"
cacheDirectory="var/cache/psalm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<projectFiles>
<directory name="src"/>
<directory name="tests"/>
</projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm>
Loading
Loading