Commit Graph

712 Commits

Author SHA1 Message Date
Brett McBride 500f6ee1bd
implement events v1.32 (#1291)
* implement events v1.32
implement the events api + sdk per spec v1.32:
- event logger is now only retrievable via an event logger provider
- domain attribute for events is removed
- events accept a subset of logrecord params, rather than an entire logrecord

* convert severity to a backed enum

* lint

* remove instead of deprecating logEvent, mark Logger constructor as internal

* make severity an enum only

* event attributes to iterable

* inject ClockInterface, add CachedInstrumentation, update examples

* set correct defaults for events

* test coverage

* Revert "make severity an enum only"

This reverts commit 710822907b.
Also, move PSR-3 mapping into the Severity enum.

* event attributes to iterable

* apply review feedback
2024-05-05 18:35:19 -04:00
Brett McBride 8031c78512
move test tools into vendor-bin (#1302)
* move test tools into vendor-bin
To reduce (hopefully, eliminate) the situations where our testing tools have conflicting
dependencies, use bamarni/composer-bin-plugin to manage them as separate vendored dirs.
Add symlinks under tools/, and update Makefile to use the self-contained versions.
Remove the dependencies from root composer.json
Rejigger dockerfile to add opcache, and some config required for latest version of grpc

* update action tools locations

* revert phpstan from vendor-bin
the phpstan plugins do not work. phpstan has no dependencies anyway, so it's safe enough to keep in vendor

* remove tools symlinks, update makefile
2024-05-05 18:34:52 -04:00
Brett McBride 8e810c6598
adding enum for semconv versions (#1301) 2024-05-05 10:19:13 +10:00
Tobias Bachert 82b191b984
Fix `weaken` for PHP8.4 closure names (#1303) 2024-05-03 09:14:33 +10:00
Brett McBride 100e593bd6
fix deptrac config to allow http clients (#1293)
* fix deptrac config to allow http clients

* Update deptrac.yaml

Co-authored-by: Chris Lightfoot-Wild <github-clw@wild.me.uk>

---------

Co-authored-by: Chris Lightfoot-Wild <github-clw@wild.me.uk>
2024-04-30 14:28:45 -04:00
Tobias Bachert 80114317f8
Set OTLP 1.2.0 span parent/link remote flags (#1298)
* Generate protobuf 1.3.0

* Set otlp exporter proto 1.2.0 remote flags
2024-04-30 14:28:30 -04:00
Dalibor Karlović 5747fac40c
fix: correct path to autoloader in metrics/getting-started (#1299) 2024-04-30 20:51:20 +10:00
Andy Postnikov f2cba82c28
[PHP 8.4] Fixes for implicit nullability deprecation (#1297) 2024-04-29 15:24:44 +10:00
Brett McBride fc161a8548
migrate Clock classes to API (#1281)
* migrate Clock classes to API
- move Clock* + Util into API
- add a deprecated wrapper for ClockFactory and Util
- remove unused StopWatch* classes

* review feedback

* replace ClockFactory with Clock
It's not really a factory, and really only provides access to a system clock. Create a
Clock class which is more clear in its purpose.

* remove time Util class
per review feedback, it's only used in Zipkin. Removed some unused consts from ClockInterface

* Apply suggestions from code review

Co-authored-by: Tobias Bachert <git@b-privat.de>

---------

Co-authored-by: Tobias Bachert <git@b-privat.de>
2024-04-29 10:28:06 +10:00
Paul 9fe6aa0cd7
Include schema_url in FriendlySpanConverter (#1292) 2024-04-29 10:22:58 +10:00
Brett McBride cea2d7c4cb
use codecov action (#1294)
our previous method of uploading to codecov.io is suffering from throttling and taking 5+ hours,
a post in the opentelemetry maintainers channel suggests this is the way to do it now
2024-04-29 09:51:57 +10:00
Tobias Bachert 8a6dd4750d
Add `Span::addLink()` and `Meter::createGauge()` (#1289)
* Add `Span::addLink()`

https://opentelemetry.io/docs/specs/otel/trace/api/#add-link

* Bump API version to `1.1.x-dev`

* Add experimental `Meter::createGauge()`

https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge
2024-04-27 14:59:15 +10:00
Brett McBride 5a395e09da
enable timeout for http transports (#1275)
* enable timeout for http transports
Attempt to do our own discovery for some well-known PSR-18 clients, which allows
for configuring timeout (and in future certificates, keys etc).
This is not complete and a prototype for feedback, but I've updated an example to
show that it works for Guzzle and Symfony http clients

* improve client discovery

* refactor, test, add more implementations

* add timeout for logs and metrics
2024-04-25 16:21:00 +10:00
Brett McBride 5019361068
fixing warnings from local build (#1277)
A couple of warnings have popped up recently:
- docker compose 'version' is deprecated
- BSD host id test was running a command that doesn't exist, which was visible in test output (removed test case)
- synchronous metric stream test was triggering a warnings which was visible in test output (changed to use LogsMessagesTrait)
- resource merging with different schema URLs was triggering a warnings from Config test (updated yaml schema_url and documented)
2024-04-19 09:04:57 +10:00
Brett McBride 43339294f5
port Nevay/otel-sdk-configuration into opentelemetry-php (#1276)
* port Nevay/otel-sdk-configuration into opentelemetry-php
This is a lift-and-shift, except for:
- changing namespaces
- fixes or ignore rules required to make static analysis tools happy
- commenting out one part of yaml test (unquoted hex value from env var)

* fix psalm on php81
2024-04-15 09:15:37 -04:00
Kevin Mian Kraiker fda522a90b
Update SemConv to 1.25.0 (#1271)
* generate semconv 1.25.0
* Tweak template `deprecated` attributes behavior and regen
* Use is_deprecated filter
2024-04-10 09:31:35 +10:00
Tobias Bachert 6cd7a8af2c
Improve fiber bound context storage (#1270)
* Improve fiber bound context storage

Now works properly in fibers once initial context is attached.

* Change `Context::storage()` return type to `ContextStorageInterface`

`ExecutionContextAwareInterface` should not be relevant for end-users / it was mainly exposed for the FFI fiber handler; calling any of its method with enabled fiber handler would have broken the storage.
Swoole context storage README creates a new storage instead of wrapping `Context::storage()`: `Context::setStorage(new SwooleContextStorage(new ContextStorage()));`.

* Add BC layer for execution context aware fiber storage

* Fix BC layer inactive execution context detection for {main}
2024-04-09 09:11:29 +10:00
John Bley e44f5a97d9
Clean up shell scripts (#1269)
* Clean up shell scripts
* Add shellcheck CI step
2024-04-03 10:54:21 +11:00
Matt Hensley bb9eb40a50
Add host.id for non-containerized systems (#1266)
Co-authored-by: Tobias Bachert <git@b-privat.de>
Co-authored-by: Chris Lightfoot-Wild <github-clw@wild.me.uk>
2024-04-02 09:20:09 +11:00
Tobias Bachert 7ec0e90402
File configuration (#1249)
* Add configuration model
* Add metrics and logs configuration model
* Remove accidentally added package dependency
* Fix `$properties` typehint to match config
Default value available -> cannot be null.
* Add configuration example that utilizes env substitution
* Fix/suppress config psalm issues
* Fix/suppress config phpstan issues
* Suppress config phan issues
* Apply cs-fixer
* Change config package version to development version 0.x
* Add README
* Add basic test
* Fix psalm and cs
* Fix composer requirement for PRs
* gitsplit, copy spi config to root composer.json
2024-04-01 18:13:01 +11:00
Tobias Bachert 6dd255deac
Fix tracestate implementation (#1267)
* Port tracestate tests
* Fix tracestate implementation
* Fix W3C test service
* Fix style
* Move tests into `TraceStateTest`
* Assert that warning is triggered when parsing invalid tracestate
* Add additional tests for valid/invalid keys/values
2024-04-01 17:05:09 +11:00
Brett McBride a1489d3081
upgrade to phpunit 10 (#1258)
* upgrade to phpunit 10

* removing unintended commented code
2024-03-18 21:02:39 -04:00
Tobias Bachert 639d8e2561
Update docker compose default php version to 8.1 (#1259)
* Update default php version for docker compose
* Use docker compose v2
> From July 2023 Compose V1 stopped receiving updates.
2024-03-16 10:50:25 +11:00
Brett McBride 4cb04999d9
drop php 8.0 support (#1256)
* bump php to 8.1, apply rector
* readonly and typehints
* suppress a dodgy readonly property conversion
* remove some redundant readonly phpdocs
* dont run workflows against 8.0
* more readonly and typehints
* phpdoc reformat
* typehints
* remove php81 polyfill
* revert a rector BC breaking change, and disable that rector for ParentBased
2024-03-15 10:14:21 +11:00
Tobias Bachert 1753fbe32b
Fix conversion of non-utf8 sequences to `AnyValue` (#1253)
String values which are not valid Unicode sequences SHOULD be converted to AnyValue's bytes_value with the bytes representing the string in the original order and format of the source string.
2024-03-14 09:30:50 +11:00
Alexandre Choura 01c46a2350
perf: Re-use empty resource instance (#1251) 2024-03-12 14:49:02 +11:00
Brett McBride bb07aca7a2
upgrade psalm to v5 (#1246) 2024-03-04 06:58:09 -05:00
Brett McBride f798bb6f01
Drop PHP 7.4 support (#1244)
* drop php 7.4 support
update composer.json minimums, and run rector over the code to update what it can. changed some static analysis
config to fix some rector-induced failures.

* adding union typehints

* reformat constructor property promotions

* updating/removing phpdoc

* suppress protobuf extension complaint
submitted a PR upstream to fix phan stubs

* don't validate packages against 7.4

* remove php8 polyfill

* fix readonly comments

* apply trailing commas to multiline fixer
upgrade php-cs-fixer, and apply a new rule for multiline comments

* remove unreachable default match arms for protobuf serializer

* adding more union types to vars

* use weakmap directly

* remove handling for not-supported WeakMap

* spacing
2024-03-03 20:21:16 -05:00
Alexandre Choura cc56628c4d
feat: Allow OTEL_PHP_DEBUG_SCOPES_DISABLED as en environment variable (#1237)
* fix: Allow OTEL_PHP_DEBUG_SCOPES_DISABLED env var + use of null-coalescing operator
* refactor: Check order & env reset
* refactor: Use class constant
* fix: Respect order and value if it is set
* style: Lint
* tests: Falsey behavior
2024-03-01 10:04:41 +11:00
Brett McBride 258e58644a
support url-encoded OTEL_EXPORTER_OTLP_HEADERS values (#1242)
Per a recent spec clarification in https://github.com/open-telemetry/opentelemetry-specification/issues/3832 OTLP
headers should support url-encoded header values.

Co-authored-by: Tobias Bachert <git@b-privat.de>
2024-02-29 08:57:02 +11:00
Brett McBride b20c45df10
log previous exception message from error writer (#1231)
it's not always clear from an exception message what the underlying issue was, so
also print out the previous exception's message, if available.
2024-02-06 12:32:25 +11:00
Brett McBride 1f187c7837
update image build actions to latest versions (#1229)
this should resolve some deprecation warnings for some things that will soon break
2024-02-05 14:09:57 +11:00
Brett McBride e522d9d81f
improve excluded urls code (#1227)
improve code and add more tests to the OTEL_PHP_EXCLUDED_URLS feature
2024-02-02 14:42:40 +11:00
Brett McBride 36e2b7f613
adding OTEL_PHP_EXCLUDED_URLS (#1226)
Modeled on python's feature to turn off all instrumentation for specific URLs,
https://opentelemetry.io/docs/languages/python/automatic/agent-config/#excluded-urls
this feature will effectively disable SDK autoloading if there is a request URI that
matches one of the provided excluded URLs, and no-op implementations will be used
for tracer/logger/meter providers.
2024-02-01 08:21:30 -05:00
Brett McBride 91f5e20ffc
document when we drop support for end of life PHP versions (#1222) 2024-01-31 07:57:34 -05:00
安正超 84cf0a5635
Add required $contentType arguments (#1225) 2024-01-27 18:23:12 +11:00
Joao Jacome f2ab3c5e1d
Adding 'all' as an option for disabling auto instrumentations (#1220) 2024-01-24 23:00:22 +11:00
Brett McBride 810aa2f95a
generate semconv 1.24.0 (#1219)
* generate semconv 1.24.0
generate latest semconv version, and add back Trace and Resource attribute values which
seem to have been dropped in a previous change.

* document source repo release urls

* remove redundant semconv deprecations
two trace attributes were deleted then added back to upstream semconv, so remove our ones.
2024-01-24 08:47:17 +11:00
Tobias Bachert 1af83342f7
Fix proto 1.1.0 trace flags (#1216) 2024-01-17 23:46:01 +11:00
Brett McBride 102f5dc187
update proto to 1.1.0 (#1215)
updates generated protobuf files to 1.1.0, and adds trace flags to OTLP-encoded spans and span links
2024-01-17 08:54:57 +11:00
Brett McBride 2390dc07b0
cache php extensions (#1213)
Optimize build times by caching php extensions for one week, particularly for 8.4/nightly which otherwise builds extensions from source each time.
This ended up being a little convoluted, since caching extensions does not run on failure. So, make all steps continue-on-failure for experimental builds, and add a final post job which checks the status of the steps and does a final fail.
2024-01-17 08:32:21 +11:00
Brett McBride 521940d988
optimize resource merging (#1214)
- do not revalidate/normalize resource attributes on merge, since they have already been validated/normalized
- string concat is about 10x faster than sprintf, so use it in ClassConstantAccessor since it's called many times
2024-01-16 08:33:18 +11:00
Brett McBride 3928b13152
optimize resource creation (#1210)
* reduce resource creation from sdk autoloader
- instead of creating new resources from various factories, create them once from sdk autoloader and
pass them to the factories (most of which already supported this).
- check env before php.ini for config, since this is the more popular approach and saves some cycles
- cache header from OtlpUtil, to save a couple of calls to Sdk detector
* adding benchmark for resource creation
2024-01-13 16:52:09 +11:00
Brett McBride 25726f6cb9
fixing deptrac complaints (#1211) 2024-01-13 16:51:17 +11:00
Tobias Bachert 925ae9b12f
Handle out-of-order destruction of Fibers/DebugScopes during final shutdown (#1209)
* Handle DebugScope out-of-order destruction during final shutdown
* Move debug traces from local scope storage to debug scope properties
* Fix phpstan error
2024-01-13 16:50:44 +11:00
Tobias Bachert 596d4a2cea
Add support for multi-instrument callbacks (#1202)
* Add support for multi-instrument callbacks

https://opentelemetry.io/docs/specs/otel/metrics/api/#multiple-instrument-callbacks

* Fix undefined offset on detach of batch callback with repeated instrument

* Unify BatchObservableCallback and ObservableCallback

* Add missing typehint

* Do not bump API dependency

Not required, SDK will continue to work with lower API versions, only `::batchObserve()` won't be usable.
2024-01-10 08:04:59 -05:00
Tobias Bachert 82c0f8ed59
Add option to disable debug scopes (#1205) 2024-01-09 11:33:41 +11:00
Tobias Bachert a196c13425
Fix delta storage failing to merge node under rare circumstances (#1201)
Only fails if a node that was created after exceeding 63 readers should be merged with a node that was created before exceeding 63 readers, resulting in an `GMP===int` comparison. Affected nodes were still merged on the next `::collect()` call -> solely internal change.
2023-12-29 09:10:34 +11:00
Brett McBride 7c45db059d
adding 8.3 to build matrix (#1189)
* adding 8.3 to build matrix

* add experimental 8.4
2023-12-25 12:58:29 +11:00
Tobias Bachert bf8119c420
Prevent propagator packages from throwing fatal error if sdk not installed (#1198)
* Prevent propagator extensions from failing if sdk not installed

* Remove KnownValues dependency

Also prevents failing for cloudtrace: sdk < 1.0.1 and jaeger: sdk < 1.0.3.
2023-12-25 10:31:33 +11:00