Skip to content

Conversation

brettmc
Copy link
Contributor

@brettmc brettmc commented Oct 2, 2025

this ports the detectors from open-telemetry/opentelemetry-php#1628 into contrib

NB that I haven't yet ported across the sdk-config parts yet, which can be a follow-up.

Replaces: open-telemetry/opentelemetry-php#1628

Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 69.46108% with 102 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.39%. Comparing base (3d6f839) to head (d0c8603).

Files with missing lines Patch % Lines
...rc/ResourceDetectors/Kubernetes/src/Kubernetes.php 70.34% 78 Missing ⚠️
src/ResourceDetectors/Apache/src/Apache.php 63.41% 15 Missing ⚠️
src/ResourceDetectors/Fpm/src/Fpm.php 70.00% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #444      +/-   ##
============================================
- Coverage     82.85%   82.39%   -0.46%     
- Complexity     2353     2508     +155     
============================================
  Files           164      167       +3     
  Lines          9563     9897     +334     
============================================
+ Hits           7923     8155     +232     
- Misses         1640     1742     +102     
Flag Coverage Δ
Aws 93.41% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.42% <ø> (ø)
Instrumentation/AwsSdk 81.13% <ø> (ø)
Instrumentation/CakePHP 20.40% <ø> (ø)
Instrumentation/CodeIgniter 78.99% <ø> (ø)
Instrumentation/Curl 87.66% <ø> (ø)
Instrumentation/Doctrine 92.92% <ø> (ø)
Instrumentation/ExtAmqp 88.48% <ø> (ø)
Instrumentation/ExtRdKafka 86.11% <ø> (ø)
Instrumentation/Guzzle 75.58% <ø> (ø)
Instrumentation/HttpAsyncClient 78.04% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel 71.66% <ø> (ø)
Instrumentation/MongoDB 74.28% <ø> (ø)
Instrumentation/MySqli 95.81% <ø> (ø)
Instrumentation/OpenAIPHP 87.21% <ø> (ø)
Instrumentation/PDO 94.21% <ø> (ø)
Instrumentation/PostgreSql 93.54% <ø> (ø)
Instrumentation/Psr14 76.47% <ø> (ø)
Instrumentation/Psr15 89.15% <ø> (ø)
Instrumentation/Psr16 97.50% <ø> (ø)
Instrumentation/Psr18 77.46% <ø> (ø)
Instrumentation/Psr3 67.01% <ø> (ø)
Instrumentation/Psr6 97.61% <ø> (ø)
Instrumentation/ReactPHP 99.45% <ø> (ø)
Instrumentation/Session 94.52% <ø> (ø)
Instrumentation/Slim 84.28% <ø> (ø)
Instrumentation/Symfony 84.03% <ø> (ø)
Instrumentation/Yii 83.05% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/CloudTrace 89.77% <ø> (ø)
Propagation/Instana 98.11% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Apache 63.41% <63.41%> (?)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
ResourceDetectors/Fpm 70.00% <70.00%> (?)
ResourceDetectors/Kubernetes 70.34% <70.34%> (?)
Sampler/RuleBased 33.51% <ø> (ø)
Sampler/Xray 78.23% <ø> (ø)
Shims/OpenTracing 92.45% <ø> (ø)
Symfony 87.81% <ø> (ø)
Utils/Test 87.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/ResourceDetectors/Fpm/src/Fpm.php 70.00% <70.00%> (ø)
src/ResourceDetectors/Apache/src/Apache.php 63.41% <63.41%> (ø)
...rc/ResourceDetectors/Kubernetes/src/Kubernetes.php 70.34% <70.34%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d6f839...d0c8603. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brettmc brettmc marked this pull request as ready for review October 2, 2025 04:05
@brettmc brettmc requested a review from a team as a code owner October 2, 2025 04:05
Comment on lines +63 to +68
$components = [
'k8s',
$podUid,
$this->getPodName() ?? 'unknown-pod',
$this->getNamespace() ?? 'default',
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the following spec note is about the Collector, it seems to apply here too - the code currently generates the same instance id for all containers in a pod:

https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-instance-id

It’s not recommended for a Collector to set service.instance.id if it can’t unambiguously determine the service instance that is generating that telemetry. For instance, creating an UUID based on pod.name will likely be wrong, as the Collector might not know from which container within that pod the telemetry originated.

];

// Create a stable UUID v5 using a namespace UUID and deterministic name
$namespace = Uuid::fromString('4d63009a-8d0f-11ee-aad7-4c796ed8e320'); // DNS namespace UUID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$namespace = Uuid::fromString('4d63009a-8d0f-11ee-aad7-4c796ed8e320'); // DNS namespace UUID
$namespace = Uuid::fromString('4d63009a-8d0f-11ee-aad7-4c796ed8e320');

Same comment needs to be removed in the kubernetes detector.

Comment on lines +22 to +23
* For Apache mod_php environments, generates a stable instance ID based on the server name and hostname
* rather than using random UUIDs which cause cardinality explosion in metrics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it will violate the single writer principle when not setting process.pid / when using threads instead of processes?

https://opentelemetry.io/docs/specs/otel/metrics/data-model/#single-writer

Aggregations of metric streams MUST only be written from a single logical source at any given point time.

For example, if an SDK implementation fails to find uniquely identifying Resource attributes for a component, then all instances of that component could be reporting metrics as if they are from the same resource. In this case, metrics will be reported at inconsistent time intervals. For metrics like cumulative sums, this could cause issues where pairs of points appear to reset the cumulative sum leading to unusable metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants