* fixing psalm complaints
use rector (and psalm) to add Override attributes, and add symfony polyfill to
provide Override in earlier php versions
* fixing more psalm complaints
* more fixes
* adding stubs for deptrac
there are some things in our code that deptrac doesn't understand or are missing
for some php versions. stub them to quieten all those violation warnings
* why not cache invalid :(
* display tools versions
* fix tools cache key
* changing cache key
* dont complain about unused psalm suppressions
* suppress invalid attribute
* quieten phpstan php8.5 complaints
* revert previous commit...now other php versions complain about an unused ignore :(
* revert typecasting in metrics aggregators
* Update src/Contrib/Otlp/ProtobufSerializer.php
Co-authored-by: Chris Lightfoot-Wild <github-clw@wild.me.uk>
* remove override stub and use the polyfill from deptrac
---------
Co-authored-by: Chris Lightfoot-Wild <github-clw@wild.me.uk>
* Move `ComponentProvider` and related classes to API
* Use API `ComponentProvider`
* Use API `ComponentProvider` in tests
* Add `EnvComponentLoader` API
* Add `EnvComponentLoader` example
* Ignore deptrac violations
* Remove namespace from `ComponentProvider` BC layer
* Add API requirement to config package
* Fix/suppress unrelated phpstan errors caused by `google/protobuf` `^4.31`
This brings declarative config support up to 0.3 plus some of the unreleased 0.4 features:
* porting code from Nevay/otel-sdk-configuration
* support 0.4 metric reader config
* allow empty keys
since https://github.com/open-telemetry/opentelemetry-specification/pull/4269 empty keys are allows, and NULL is no longer equivalent to unset
* update config example to remove empty objects
* remove moved component providers from composer.json
* add ComponentProviderRegistry::componentMap for instrumentation configuration
the spec has added in-development otlp file/stdout exporter. We already supported this programmatically, so
add some factories and sdk config to allow configuration from environment (only for stdout, per spec)
- headers and attributes are now arrays with `key` and `value` elements
- headers can optionally contain a `headers_list` element which supports a lower-priority CSV of key/value entries
- attributes can optionally contain an `attributes_list` element which supports a lower-priority CSV of key/value/data-type entries
update semconv generation to use the new tooling. This is fairly close to a 1:1 of what we have now,
although I noted a couple of TODOs which we might consider in future to align with what Java is
doing: split attribute up into file-per-type, and split stable/unstable.
Follow-up from #1383. Debug exporter isn't available until v0.86.0, so this new configuration throws an error when trying to run the collector. `Error: cannot unmarshal the configuration: unknown exporters type "debug" for "debug"` Instead of setting to v0.86.0, I noticed the other docker files omitted the tag (so latest is pulled). I just updated this to match.
implement recent additions to the otel spec re: config provider. Config provider should return a
ConfigProperties, but we were already returning a ConfigurationRegistry. Added a ConfigProperties
interface for ConfigurationRegistry to implement, which gets us pretty close to spec.
We don't make ConfigProvider globally available, instead passing the ConfigurationRegistry in to
each instrumentation as we register it. The spec allows for this.
* auto root span creation
proof of concept for automatically creating a root span on startup.
the obvious deficiencies are:
- no idea of response values (status code etc)
- does not capture exceptions
* deptrac
* adding LocalRootSpan class
this is based on Java's implementation, https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/v2.3.0/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/LocalRootSpan.java
and adds the ability to identify and locate the "local root span" in a trace. The local root span is the top-level active span which has either
an invalid or remote parent.
It's tracked automatically as part of making a span active, either via `Span::activate()` or `Span::storeInContext()`, and can be retrieved in
a couple of ways, but most easily via `LocalRootSpan::current()`.
* remove redundant local root span check
* move context key to api
* internal
* adding example
* mark LocalRootSpan as experimental
* adding an example of local root span usage
* style, fix broken build
* [WIP] Add instrumentation configuration
* add autoloading for auto-instrumentations using SPI
* allow autoloading and non-autoloading to work
* fix attribute
* experimental config file
* fixing invalid dependencies
- deptrac was rightly complaining that API (indirectly) depended on SDK through config/sdk. For now,
remove usage of Config\SDK\Configuration\Context
- update deptrac config to allow some new dependencies
* dont register hook manager globally or in sdk
* remove unused function, psalm ignore missing extension function
* possibly fixing type-hint
psalm doesn't complain now, so that should be good
* load config files relative to cwd
* fixing hook manager enable/disable + psalm complaints
* fixing 8.1 psalm error
* use context to pass providers to instrumentations
- make "register global" a function of Sdk, but keep the sdk builder's interface intact
- invent an API instrumentation context, similar to the one in config/sdk, to pass providers
to instrumentations
- add an initial test of autoloading from a config file
* adding tests for sdk::registerGlobal
in passing, remove some dead code for handling invalid booleans - config already handles this correctly
* linting
* test coverage for globals
* add opentelemetry extension to developer image and actions
* always register instrumentations via SPI
* register globals initializer for file-config sdk
allow SDK created from config file to coexist with components using globals initializer
* linting
* remove globals init function
* fix phan warning
* simplify hook manager
- drop storage from hook manager: can't guarantee that something else, eg swoole, won't modify storage
- drop context from hook manager: we must lazy-load globals via initializers, because not all instrumentations use SPI (although that may change in future)
- default hook manager to enabled
* add todo to deprecate Registry in future
* autoload instrumentations without config
if no config provided, still try to load them. wrap registration in a try/catch/log
* fixing phan ref, update doc
* remove phan suppress
* fix example
* bump SPI to 0.2.1
* adding late-binding tracer+provider
per review from Nevay, this will allow instrumentations to get things from Globals as late as possible
* adding late binding logger and meter providers
* more late binding test coverage
* tidy
* dont use CoversMethod yet
not available in phpunit 10, so comment out and leave a todo
* kitchen sink, remove unused var
* instrumentation config as a map, per config file spec
* adding general config
* move general config into sdk
* test config caching
* move general instrumentation config to api
* avoid bad version of sebastian/exporter
* bump config yaml files to 0.3
* fix tests
* disable hook manager during file-based init
* cleanup
* support multiple config files in autoloader
* move hook manager enable/disable out of extension hook manager
The most obvious place to do this is in a class named HookManager, which _was_ an
interface for hook managers. Rename existing HookManager to HookManagerInterface,
then re-purpose HookManager for globally enabling/disabling hook managers as well
as determining the disabled status.
* update spi config
---------
Co-authored-by: Tobias Bachert <git@b-privat.de>
* 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
* 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>
* 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
* 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
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.
Whilst investigating upgrading to psalm 5, I notice that it generates a lot of new complaints. This fixes the ones that looked legit and
require an API change, or were trivial. Does not upgrade to psalm 5 yet, though. That's a bigger job for another day.
send errors/warnings/etc by default through PHP's error_log. This gives more control to administrators, since error_log can
be configured to write to any stream (file, stderr, etc). I think it's also less surprising for people trying out otel (particularly
with development PHP settings, where trigger_error often breaks an application).
Adding a configuration value to control where logs go: OTEL_PHP_LOG_DESTINATION.
https://github.com/open-telemetry/opentelemetry-specification/pull/3563 clarifies the behaviour of
forceFlush with push/non-push metric exporters.
Break forceFlush out into a PushMetricExporterInterface, and update ExportingReader to only collect/flush
if exporter is a push metric exporter.
to make getting started easier (in opentelemetry.io docs), create an sdk-based metrics
exporter. this means we can export all signals without needing a protobuf implementation.
since console export is only useful for playing around, the change in format to a
simpler human-readable output seems reasonable.
- apply TC review feedback to move Globals to top-level.
it was suggested to move Instrumentation into its own package, but I chose instead to just move that dir
up to the top level of API
- added a BC layer to alias the moved classes
- added some more examples
allow the existing metric exporter to be created from env vars, by creating a factory
and registering it against 'console'. Now, OTEL_METRICS_EXPORTER=console will create
a metrics provider with console output. Note that it lives in contrib/otlp, since it
uses the existing otlp converters.
New Relic now fully supports OTLP ingestion, and having proprietary exporters is no longer their strategy. The proprietary exporters have been marked as abandoned in packagist, and suggest exporter-otlp as a replacement.
the example is very old, does not work, and it doesn't look like the capability
is in the spec these days. Remove the code so that it doesn't cause confusion.
Introduce spec-compliant ResourceInfo::merge, and deprecate our current implementation.
When merging resources, later (updating) keys should override existing keys, per spec.
Reorganise detectors so that environment has highest priority (per spec, OTEL_SERVICE_NAME should be the highest priority built-in way of setting service name)
Adding the experimental telemetry.auto.version attribute, if the auto-instrumentation extension is installed.
* implement bridge api
* adding logs memory exporter
* clarify bridge api not for developers
* adding logger provider builder
* review feedback
* removing Bridge and documenting what a bridge is