Commit Graph

38 Commits

Author SHA1 Message Date
Tobias Bachert 739f212ba9
Add instrumentation scope attributes (#735)
* Add attributes to instrumentation scope

* Remove `::getDefaultTracer()`

Instrumentation should use dedicated tracers.

* Remove SDK `::getTracer()` default name

Instrumentation should use API `TracerProvider` which requires providing a name.
2022-06-30 12:30:14 +02:00
Tobias Bachert 41f74d2aff
Make `AttributesInterface` immutable (#724)
* Cleanup `AttributesInterface`
- remove not required methods
- rename `::hasAttribute()` to `::has()` for consistency with `::get()`
* Remove public usage of `new Attributes()`
* Split `Attributes` into immutable attributes and mutable builder
* Remove `AttributesLimits`
* Remove `::incrementDroppedAttributesCount()` for now
Mainly useful for metrics sdk that has to rebuild filtered attributes.
* Remove obsolete cloning of attributes
* Update covers annotation
* Revert optional changes that might be controversial
2022-06-23 20:54:03 +10:00
Tobias Bachert 122aff0c74
Prevent leaking `TracerProvider` references in `register_shutdown_function` (#716) 2022-06-21 10:32:31 +10:00
Timo Michna 31bdeaa8f1
Add package validate call to CI (#714)
* Add package validate call

* Fix WF

* Touch composer.json to burst cache

* Fix job name

* Add PHP version to Psalm call

* Make package job depend on php job

* Fix base TestCase

* Add install directory

* Touch composer.json to burst cache

* Add install directory

* Fix install directory

* Temporarily remove job dependency

* Touch composer.json to bust cache

* Touch composer.json to bust cache

* Touch composer.json to bust cache

* Touch composer.json to bust cache

* Fix extensions

* Make package job depend on QA job

* Use PHP QA in CI badge
2022-06-17 19:15:59 -04:00
Tobias Bachert a22f9f1077
Cleanup/fix context package (#711)
* Remove `Context::withValue()`

Creates a hidden `Scope` when called without `$parent`.

* Remove `Context::detach(Scope)`

* Remove static `Context::attach()`

* Add missing typehints

* Use loop instead of recursion

* Fix `MultiTextMapPropagator::extract()` clearing context

* Fix `TextMapPropagator::composite()` for named arguments

* Make `Context` constructor non-public

* Make `Context` and `ContextKey` final

* Fix `ArrayAccessGetterSetter`

Resolves inconsistencies in case-insensitive handling.

* Fix psalm

* Fix cannot mock final class `Context`

Revert after introducing ContextInterface?

* Apply feedback and remove obsolete parentheses

* Use psalm-suppress instead of assert
2022-06-16 08:17:59 -04:00
Tobias Bachert 3c6c53bf2f
Fix overriding attribute increases total count (#710) 2022-06-16 19:57:50 +10:00
Tobias Bachert 7dda601851
Improve StackTraceFormatter (#697)
* Refactor stacktrace formatter

- fixes "... n more" to fold only identical frames
- fixes exception class names not being converted to dotted format
- fixes functions being shown as `main`
- fixes out-of-memory on circular exception

* Rename stacktrace formatter
2022-06-06 15:57:56 +10:00
Amber e728c53065
#632 : Move stack trace formatting out of Span class (#694)
* Otel-php:632 Move stack trace formatting out of Span class

* added function usages

* fix linting errors
2022-06-03 15:13:56 +02:00
Yukti 25cfcfb6e9
Add phpunit annotations for compliance tests (#670)
* Add phpunit annotations
2022-05-07 09:02:29 +10:00
Yukti 8ae46f20e1
Add compliance test and annotate existing ones (#669)
* Add compliance test and annotate existing ones
2022-05-06 22:46:47 +10:00
Brett McBride 4e3264578b
Fixing protobuf generation and InstrumentationScope (#665)
* updating proto generation
switching over to using opentelemetry-proto's own mechanism for generating protobuf interfaces, and
updating interfaces to latest version

* downgrade protobuf interfaces to 0.14.0
this is the latest version that seems to work with out grpc exporter, further
investigation required for 0.15.0+

* tidy up script

* renaming InstrumentationLibrary to InstrumentationScope and bumping protobuf
InstrumentationLibrary is now deprecated in favour of InstrumentationScope. Making this change
resolves issues with grpc+protobuf exports being ignored by the otel collector, so we now
can update the proto interfaces to latest.

* rename collector docker-compose file
2022-04-27 08:09:42 -04:00
Kishan Sangani 5de0986f86
Refactored ResourceInfo and ResourceInfoFactory Unit and Integration tests (#664) 2022-04-20 13:47:52 -04:00
Yukti 1d5283b9e4
Add integration tests for tracing compliance (#662)
* Add integration tests for span builder

* Space fixed

* Add more descriptive names and @group annotation

Modified the names of the tests to be more descriptive and added the
`@group compliance` notation.
Additionally, I commented out one of the tests that I was not totally
sure of. (unsure if `setAttribute()` should work with empty string `''`
values.

* Fixed test name

* Check for specific attributes and not just count

Removed `$span->end()` calls as they shouldn't be necessary

* Remove redundant `end()` calls

* Add test for getting default tracer

Test to get default tracer. Also, added `@group` php unit annotation for
tests to check specification compliance

* Fixed warning

* Fixed style warning
2022-04-17 13:15:34 +02:00
Tushar 6d993586b0
Move InstrumentationLibrary key generation logic out of TracerProvider/SpanConverter [#619] (#663)
* Extract InstrumentationLibrary key generation logic

Factors key generation logic for InstrumentationLibrary instances
out to a helper method in a utils class.

* Remove @see PHP annotation

Phan doesn't like it, couldn't see an acceptable workaround.

* Change key generator namespace and class

Changes the key generator's namespace to Util\Instrumentation and classname to
KeyGenerator, refactoring usages.

* Add unit tests for Instrumentation key generator

* Add test case for non-null version and null schema

Also renames the other 2 tests for descriptiveness.
2022-04-15 14:16:12 +02:00
Timo Michna 99fba0d720
Make Error level of BC messages configurable and add info to README. (#657)
* Make BC error level configurable

* Add information about BC errors to README

* Make CS happy

* Silence Psalm

* Add missing test

* Remove unused data annotation
2022-04-05 21:53:49 +02:00
Brett McBride e096e529bb
Revert "replace E_USER_NOTICE with E_USER_DEPRECATED (#647)" (#655)
This reverts commit 72816bb324.
2022-04-03 21:22:16 +10:00
Ivo Bathke 72816bb324
replace E_USER_NOTICE with E_USER_DEPRECATED (#647)
* replace E_USER_NOTICE with E_USER_DEPRECATED since it is a notice about a deprecation

* fixed tests
2022-04-02 11:30:23 -04:00
lalex 445e932ee0
Extract a Resource schemaUrl merging method (#627) 2022-04-02 07:01:52 +02:00
Yukti 169bdbee57
Add @group annotation to compliance tests for environment variables (#611)
* Add @group annotation to compliance tests

Marked tests for environment variables with phpunit @group annotations to identify
compliance tests. This enables for a way to run just those specific
test and will serve as a useful form of documentation.

* Add trace signal specific notation
2022-03-31 08:49:33 -04:00
Grunet 39c99e5a2f
Map OTEL Resources to Jaeger Process Tags (#636)
* Commit in progress work because Gitpod is weird

* Finish initial stab at the changes

* Forgot to update the exporter

* Add in proper handling of serialization of ResourceInfo

* ksort doesn't return the array...

* Only PHP 8.1 supports key-ed array destructuring

* Creating some adapters to break the hard dependency on Batch to make testing easier

* Refactoring to break the hard dependency on Batch

* Add initial unit tests around the new logic in HttpSender

* Some refactoring of the test's helpers

* Another small refactor

* Some more refactoring

* Rename ResourceInfo's test file to match it's file name

* Move a test our of REsourceInfoTest into a more appropriate file

* Add some basic conformance tests around the new ResourceInfo::serialize method

* Add a test to try and catch future properties that aren't added to ResourceInfo::serialize

* CLean up comments

* Replace string with constant

* Improve variable names

* Cleaning up comment

* Split out tag creation into a helper class

* Phan didn't like the type docs

* Fix style

* Fix tests after merge from main

* Fix coverage reporting issues on 2 of the new files

* Fix style

* Rename vals to values

* Shortening the batch adapter factory method name to create

* Inline a method call

* Inline some method calls

* Shorten factory method to just "create"

* Inline some code

* Split assertions into 3 tests

* Rename parameter in interface implementation for psalm + update the rest of the file to match

Co-authored-by: Timo Michna <timomichna@yahoo.de>
2022-03-28 03:18:32 +02:00
Timo Michna a2f64053da
Add Backward Compatibility layer (#637)
* Add Attributes BC layer

* Add AttributeLimits BC layer

* Add InstrumentationLibrary BC layer

* Add GlobalLoggerHolder BC layer

* Add triggerMethodDeprecationNotice

* Move Clock BC layer

* Add ResourceInfo BC notices

* Add missing return statement

* Add BC class directory to coverage ignore

* Fix code coverage annotations
2022-03-28 03:11:01 +02:00
Timo Michna 8e1e912c92
Move and refactor clock components (#633)
* Move Clock classes to SDK\Common\Time namespace

* Move conversion methods to Util class

* Implement StopWatch

* Implement ClockFactory

* Fix StopwatchInterface

* Finalize ClockFactory

* Implement StopWatchFactory

* Deprecate AbstractClock

* Add BC alias

* Add initial start time to StopWatch

* Unify and optimize SystemClock methods

* Use ClockFactory in Span

* Use ClockFactory in BatchSpanProcessor

* Use ClockInterface in BatchSpanProcessorTest

* Use ClockFactory in SpanData

* Use ClockFactory in examples

* Add millisToNanos Util method

* Use StopWatch in BatchSpanProcessor

* Make Phan happy

* Make Psalm happy

* Make PHPUnit happy

* Remove sllh/composer-versions-check from allowed composer plugins

* Use correct assertion

* Use correct assertion

* Assert difference
2022-03-25 23:26:39 +01:00
Kishan Sangani 2b72c92fcb
Created ResouceInfoFactory class (#628) 2022-03-24 13:54:42 +11:00
Kishan Sangani 3856d4df06
Resource Detector Unit Tests (#626)
* Added Resource Detector Unit Tests

* Modified test

* Resolved review messages
2022-03-21 18:59:04 +01:00
Timo Michna f96756ba10
Refactor and move InstrumentationLibrary (#624)
* Refactor and move InstrumentationLibrary
2022-03-20 21:36:18 +11:00
Timo Michna 940f67f1c7
Refactor Attributes (#623)
* Move Attribute classes to Common namespace

* refactor AttributesTest

* Move Attribute classes to Common namespace in examples

* Introduce AttributeLimitsInterface

* Fix bug in total added values calculation

* Move compare test to correct test-class

* Apply CS

* Refactor Attributes

* Fix attributes in Benchmark

* Move AttributeLimits defaults to interface
2022-03-19 23:51:47 -04:00
Timo Michna 1d6d717e0d
Refactor LoggerHolder (#617) 2022-03-19 12:52:06 -04:00
Timo Michna 3c5f9fc5ae
Support Env Var injection (#614) 2022-03-18 08:22:33 -04:00
lalex 3445917252
Add support for schemaUrl in TracerProvider and OTLP SpanConverter (#607)
* Add support for schemaUrl in TracerProvider and OTLP SpanConverter
2022-03-16 10:18:40 +11:00
Kishan Sangani 5dd8f967cf
Added OTEL_PHP_DETECTORS environment variable (#600)
* Added OTEL_PHP_DETECTORS environment variable to configure detectors from environment

* Added unit tests for defaultResource

* Review comment: Added exapmle

* Refactoring to keep the syntax same across examples

* Review comment: Using static method instead creating instance and using constants
2022-03-02 16:23:09 +01:00
Kishan Sangani be15243441
Refactored Environment.php to use EnvironmentVariablesTrait::hasEnvironmentVariable function (#598) 2022-03-01 12:45:53 +01:00
Kishan Sangani 8a362215fd
Refactored SpanProcessorFactory and updated corresponding unit tests (#594) 2022-02-24 09:43:53 +11:00
Kishan Sangani 08d3fe8d0d
Refactored Environment.php to use Environment constants and accessor (#592) 2022-02-23 10:31:54 -05:00
Timo Michna d2a9023632
Refactor Environment Variable Handling (#561)
* Move EnvironmentVariablesTrait

* Add env var constants

* Move EnvironmentVariablesTrait

* Set default to empty string

* Add ClassConstantAccessor

* Use Env Var constants

* Fix naming

* Add Env Var parsers

* Fix boolean values

* Add Resolver

* Fix covers annotation

* Add Accessor

* Allow unknown env vars

* Add test for empty var

* Filter correct types

* Allow empty lists and maps

* Add 'none' to known compressions

* Use inline constants

* Use Env Accessor

* Fix CS

* Make TraceIdRatioBasedSampler construction safe

* Supress wrong Psalm error

* Remove redundant checks

* Remove redundant checks

* Add additional getters to trait

* Remove redundant metadadata handling

* Fix CS

* Fix insecure gRPC credential creation

* Test for cert file
2022-02-02 09:54:32 -05:00
Tobias Bachert 0f17e55824
Move resource detection out of `ResourceInfo` (#537)
* Move resource detection out of `ResourceInfo`

* Apply feedback
2022-01-21 15:41:25 -05:00
Brett McBride b1a095d120
fixing otlp span converter with ext-protobuf (#544)
* fixing otlp span converter with ext-protobuf
There looks to be a bug in ext-protobuf, where an array with any empty string top-level values cause an error. A workaround for this is to strip out entries with empty values.
Adding ext-protobuf to the test matrix, and in passing fixing a mis-named test class
* document and suggest protobuf extension
2022-01-13 15:32:55 +11:00
Brett McBride 86ed4cff87
adding covers annotations to all tests (#540)
* adding covers annotations to all tests
* clock tests
* adding unit tests
* feedback
- cleaning up ValueRecorder tests
- ints are floats, so type-hint ValueRecorder::record and remove some checks
2022-01-07 09:33:08 +11:00
Brett McBride 56cf2db141
Separate integration and unit tests (#538)
* reorganise tests
moving tests under tests/Unit and tests/Integration, and updating namespaces
changing 'make test' to just run unit tests, and generate coverage off that
adding a 'make test-integration' to run integration tests (without coverage)
adding test-integration to 'make all'
adding a separate github action to run integration tests

* tidy 'make test'
make test is now a combination of test-unit and test-integration

* fixing 'make all'

* adding unit tests for TraceIdRatioBasedSampler
I grabbed a couple of the more unit-tests tests from the integration tests. Also starting to add some @covers
annotations to start to remove false coverage
2022-01-05 14:22:12 +01:00