Commit Graph

13 Commits

Author SHA1 Message Date
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
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
Brett McBride 0538a5a7c7
fixing empty tracestate header handling (#936)
if an empty tracestate header was passed, we were emitting a warning (discovered in the demo app after enabling logging).
to fix this, check for empty string as well as null.
2023-03-16 18:45:15 +11:00
Brett McBride 904da75ee6
adding exporter + transport registry (#862)
* adding exporter + transport registry
to remove the hidden dependency between SDK and contrib, move all of the exporter knowledge out of
exporter factory, and invent a registry to hold those values. The registry can be added to by contrib
modules as part of composer autoloading.
This also allows users to override things like transports (eg, provide their own grpc transport).
Remove exporter's fromConnectionString as it's not in spec, and I couldn't get it to work nicely with the
registry idea.

* fixing up examples

* allow callables to be registered as factories
adding an example of replacing a registered transport factory with another implementation

* Registry to FactoryRegistry

* new relic exporter factory, tests

* review suggestions

* tidy

* change fromEnvironment() to create() in factories
2022-11-23 14:39:24 -05:00
Brett McBride f083b10909
refactor environment configuration (#859)
refactoring Environment access to allow configuration from multiple sources. Initially, the sources are env ($_SERVER) and php.ini, but this should allow us to add more sources in future without changing the API.
do not modify OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
allow resolvers to return mixed
2022-11-10 09:48:17 +11:00
Timo Michna 3f56af97ce
Upgrade phpstan packages to stable versions (#463)
* Upgrade phpstan packages to stable versions

* Fix phpstan errors

* Add ContextKeyTest

* Fix CS
2021-11-11 11:26:38 -05: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
Sean Hood 8a135019cc
OTLP/GRPC Exporter Implementation (#272)
* Adding Proto to opentelemetry-php
Signed-off-by:Ritick Gautam <riticksinghrajput@gmail.com>

* Updated the script for generating proto folder in root

* Moved shell file in script folder
updated .gitignore

* Removed opentelemetry-proto

* Bug fixed

* added docker-compose.proto.yaml
updated script file
updated Makefile

* Update docker-compose.proto.yaml

* Updated README.md

* OtlpGrpc

* Added Request-response

* Example Updated

* Updated Span Converter

* small fixes

* modified: SpanConvertor.php

* (WIP): Partially working OTLP/GRPC Exporter

What's working?
* Sends spans to the Otel Collector
* Spans contain: Attributes, Status Code, Kind, Start/End timestamp, Lib Version
* Sucessfully sent OTLP to Honeycomb.io

What's not working?
* Need to rebase main onto this branch
* Trace ID and Span ID are too long, and have been fudged to trim them.
* No tests. Unit/Integ
* Events on spans haven't been tested
* Child spans haven't been tested
* Example code needs to be updated (been testing with laravel-otel)
* Need to check the status returned
* Links not implemented
* Generally just unfinished

Anything more to add?
* Thank you to the Ruby OTLP Exporter, lots of inspiration was taken from there

* Fixed traceid and spanid hacks; Now supports Events

* Use localhost:4317 for the default host; + cleanup

* Split code between Exporter.php and SpanConverter.php; Beginnings of tests

* More progress on tests, array's now correctly get converted. Also ran `make style` to format the code

* * Ironed out passing in headers. Could not figure out how best to validate the format php grpc wants the metadata to be in so accepting just the required string format now.
* Beginnings of tests for the Exporter
* Compression now configurable, not tested
* Removed ServiceName from being passed to the Exporter, I believe this should be set as an Attribute on a Resource in the TracerProvider
* Checking the status code coming back from GRPC client, Otel Spec says transient errors MUST be retried, retries not yet implemented: ffc85ddfd9/specification/protocol/exporter.md (retry)

* Add (failing) test for converting SDK Span to OTLP Span

* I'm struggling to set (or even get) an end timestamp for the span.
* Attributes not implemented on Events

* Further progress on Tests for the Exporter

* SpanConverter now translates attrs on Events

* Add opentelemtry-proto files

* Ran `make style' on proto. Do we want this?

I pushed the proto files and build is complaining, not sure if we want to exclude this dir from linting or not?

Testing it formatted so I can try to get this build green.

* Few changes in this one..

1. Moved out ResourcesSpans into the SpanConverter
2. Time is almost fixed, well tests pass but... I learned the clock didn't work as I expected it to. Wall clock and monotonic clock are entirely unrelated. I still think this needs more work but I _think_ it tests that the duration is correctly set on the otlp span.
3. ResourceInfo is now populated on otlp ResourceSpans.

* Fix some of the complaints from static analysis

* Revert "Ran `make style' on proto. Do we want this?"

No, we do not want generated code to be formatted with php-cs-fixer

This reverts commit 996b473ad3.

* make style

* Static analysis fixes

* Hopefully this adds the grpc extension

* Hopefully this adds the grpc extension

* Some Psalm fixes

* Added a few comments; disable testing of InstrumentationLibrary until it's implemented

Co-authored-by: Ritick Gautam <riticksinghrajput@gmail.com>
Co-authored-by: Ritick Gautam <41835832+riticksingh@users.noreply.github.com>
2021-05-05 14:17:24 -04:00
Fahmy Mohammed cd8d714fd6
W3c trace context test service (#288)
* Add W3C trace context test service

* Add README

* style formatting

* Update test service to use local files

* fix phpstan suppression

* ignore phpstan and psalm errors

* lock symfony version to 5.2

* cleanup

* more cleanup
2021-04-14 14:10:21 -04:00
Dalibor Karlović 16c3f97743
chore: add static analysis for tests, examples (#208) 2020-11-04 23:00:11 -05:00
Dalibor Karlović 2514c45b55
fix: bump PHPStan to level 5, Psalm to level 3 (#205) 2020-11-04 08:40:10 -05:00
Dalibor Karlović 266498403b
chore: .editorconfig, .gitattributes (#207)
* chore: add .editorconfig

* chore: add .gitattributes, cleanup Composer package
2020-11-03 11:11:10 -05:00