Commit Graph

20 Commits

Author SHA1 Message Date
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
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
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
Tobias Bachert 6ff577b417
Restructure API / SDK components (Attributes, Clock, Trace) (#521)
* Move Attributes and Clock out of /Trace namespace

Also needed for other components (metrics).

* Move Event and Link to SDK

* Move NoopTracer to API

* Remove `Attribute` abstraction

* Move `Attributes` to SDK by widening API attributes types to `iterable`

* Move `Clockinterface` to SDK

* Fix fqcn usage

* Readd `AttributesInterface` mock

* Move `TraceState` and W3C `TraceContextPropagator` to API
2022-01-01 18:51:36 +11:00
George Dietrich 01c388e02c
Reorganize types (#434)
* Create and move namespaces into `src/` directory

* Update `composer.json`

Move test helpers outside of `SDK` namespace into `Tests`

* Follow PSR naming conventions for interfaces

* Follow PSR naming conventions for abstract classes and traits

* Do a pass on CI configs

* Add examples directory to cs-fixer config

* Fix some erroneously renamed type names
2021-10-03 06:32:46 -04:00
George Dietrich 6cffcbe5a0
Span Refactor (#422)
* First pass at updating Span API

* First pass at updated Span implementation

* Update SDK Span return types to `ReadWriteSpan`

Drop support for PHP 7.3

* Finish initial implementation

* Implement `SpanData`

* Implement `StatusData`

* Re-implement and rename `NoopSpan` to `NonRecordingSpan`

* Updates to support `SpanData` in exporters/span processors

* Add timestamp conversion helper methods

Update Exporters to use `SpanData`
Start updating Exporter tests
Implement non immutable `SpanData` test helper class

* Finish updating exporters/converters

* Fix next batch of tests

* First pass at `Tracer` refactor

Leverage a `SpanBuilder` to create the span
Use a dedicated object to share state

* Just use `NonRecordingSpan` constructor versus `create`

Start of adding tests for new Tracer implementation

* Remove some unneeded `max`

Make `Sampler` the 2nd arg to `TraceProvider`
Fix Integration tests

* Add `NoopSpanProcessor`

Continue updating/adding tests

* Install mockery

Ensure span processor is called with expected contexts/spans

* Update `SpanData` to directly return dropped amounts

Make `SpanProcessor#onStart` take a `ReadWriteSpan`
Update empty span fallback name

* Revamp `Clock` interface/implementation

* Add some additional doc comments

Continued work on updating test coverage

* Add more `Span` tests

* Get tests to a passing state

* Fix type errors

* Make CI happy

* Apply limits within `Span` constructor and `SpanBuilder` logic

Add test coverage for these cases
2021-09-29 19:10:07 -04:00
lalex edcb4327ed
Update sampling behavior (#289)
* Update sampling behavior

* Change shouldSample() method signature to accept the Context
* Default sampler is ParentBased(root=AlwaysOn)
* Avoid to start sampled and non-recording span, return NooSpan
* Change names of SamplingResult constants: DROP, RECORD_ONLY, RECORD_AND_SAMPLE
* Return an updated TraceState in SamplingResult (parent TraceState by default)
* Merge Attributes from the SamplingResult with the Attributes provided in the startSpan method

* Add an integration test case for an overridden TraceState by the Sampler
2021-03-22 22:46:27 -04:00
Dalibor Karlović 16c3f97743
chore: add static analysis for tests, examples (#208) 2020-11-04 23:00:11 -05:00
Dalibor Karlović 72ff1f2b6c
Issues found by Psalm / PHPStan level 4 and CS Fixer (#185)
* fix: small issues found by Psalm level 4

* fix: small issues found by PHPStan level 4
2020-10-04 12:11:37 -04:00
André Luis Gomes dd1d1d704d
Fix AlwaysOffTraceExample.php Sample (#195)
The `$span->addEvent()` waits a $timestamp as second argument, but
we are sending `new Attributes([...` as aprameter.
2020-10-04 12:10:17 -04:00
Beniamin c2476dfda9
split Trace SDK in sub-namespaces and create new area for contrib (#97)
move all tests in the same root directory - will be easy to follow

remove errant test and whitelist the library code for coverage instead of tests

inherit JaegerExporter from Zipkin since we are using the zipkin protocol to export to Jaeger
2020-06-17 11:24:08 -04:00
Bob Strecansky 55cc8b6ff1 Update Examples with SpanKind (#82)
* Update Examples with SpanKind

* make style
2020-05-15 16:27:38 -04:00
Beniamin e5eda43ad9
Jaeger exporter (#70)
* make zipkin-exporter implementation simpler

* add Jaeger exporter and fix zipkin exporter timestamps

* move zipkin converter logic outside of exporters

* start containers before running examples

* fix open-telemetry badge codecov.io url

* fix phpunit whitelist after api and sdk splitting
2020-04-05 16:05:52 -04:00
lalex 783ccdde06
Built-in samplers implementation (#66)
* Built-in samplers implementation
- AlwaysOffSampler
- AlwaysOnSampler
- AlwaysParentSampler
- ProbabilitySampler

* Fix code standards

* Apply an API interface refactoring

* Fix sampler examples

* Fix coding standards

* Move files around, fix small issues

* Fix doc block and coding standards

Co-authored-by: Levi Morrison <levi.morrison@datadoghq.com>
2020-04-01 17:53:43 -04:00
Levi Morrison 3262c429ff
Add API Interfaces (#64)
* Migrate src/ to sdk/ and api/

Co-authored-by: Bob Strecansky <bob.strecansky@gmail.com>

* Rename TracerFactory to TracerProvider

This follows opentelemetry/oteps#76.

Also start moving sdk tests into the sdk/Tests folder

* Touch up SpanStatus and ending spans

* Remove getTracerVersion and getTracerName

These aren't described in the spec -- we can add them back later
if we need to, but I suspect they belong only in the SDK, if anywhere.

* Update phan config and fix some warnings

* Start writing SpanOptions

Also start fixing examples, currently broken

* Fix PhpUnit 9 incompatibilities

Co-authored-by: Bob Strecansky <bob.strecansky@gmail.com>
2020-03-26 19:31:19 -04:00
Alan Storm d8a554b598
Fixes Broken Example Code and Link in README (#59)
* Give examples working code

* Fix link in README

* php-cs changes
2020-02-12 21:40:44 -05:00
Nenad Stojanovikj 7fe89db0ae Add php-cs-fixer (#50)
* Add php-cs-fixer to dev requirements

* Ignore php-cs-fixer cache file

* Add style guide configuration file

* Correct style of all PHP files

* Add Makefile target for style fixing
2020-01-24 08:15:22 -05:00
Beniamin 3d56cb7adf implement ZipkinExporter::export, and Process spans in Tracer (#41) 2020-01-20 21:48:15 -05:00
Beniamin 0991f72146 TracerFactory implementation (#38)
* implement TracerFactory, begin migration to recommended library layout, use docker-compose and make to simplify development

* add tests for all TracerFactory method, move TraceFactory configuration in constructor

* run phan in travis-ci build

* rename namespace Tracing into Trace
2020-01-07 08:39:14 -05:00
Bob Strecansky c863d37cff
Performing Always and Never Sample Steps (#30)
* Performing Always and Never Sample Steps

* Updating examples to remove builder

* Updating examples to remove builder

* Removing builder from always off trace example
2019-12-10 13:48:22 -05:00