open-telemetry / opentelemetry-swift

OpenTelemetry API for Swift
https://opentelemetry.io/docs/instrumentation/swift/
Apache License 2.0
207 stars 124 forks source link

Implement Exponential Histgoram metrics #525

Closed jhoongo closed 5 months ago

jhoongo commented 5 months ago

This PR implements ExponentialHistogram metric in Swift SDK. Most of the implementations was inspired and driven by https://github.com/open-telemetry/opentelemetry-java SDK. It has been validated with Java SDK to ensure that it generates the same results and passes the same tests for the most part.

There might be some missing area that I might have missed on this, but this should be good enough for us to starting point for supporting Exponential Histogram.

I have excluded the implementation of Exponential Histogram on the old metric and only implemented it for Stable Metrics.

Note: I just notice the spacing/indentation issue on this PR, will follow up shortly on this. Fixed the indentation issues and added few more testings

codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 90.38462% with 55 lines in your changes are missing coverage. Please review.

Project coverage is 68.41%. Comparing base (1535a05) to head (f69c8b2).

Files Patch % Lines
...ta/Internal/Base2ExponentialHistogramIndexer.swift 67.39% 15 Missing :warning:
...elemetryProtocolCommon/metric/MetricsAdapter.swift 69.56% 14 Missing :warning:
...on/DoubleBase2ExponentialHistogramAggregator.swift 89.47% 14 Missing :warning:
...ernal/DoubleBase2ExponentialHistogramBuckets.swift 96.84% 3 Missing :warning:
...table/Exemplar/LongToDoubleExemplarReservoir.swift 75.00% 3 Missing :warning:
...le/Aggregation/AdaptingCircularBufferCounter.swift 97.05% 2 Missing :warning:
...rics/Stable/Aggregation/AdaptingIntegerArray.swift 98.44% 2 Missing :warning:
...egation/Base2ExponentialHistogramAggregation.swift 88.23% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #525 +/- ## ========================================== + Coverage 67.41% 68.41% +0.99% ========================================== Files 335 344 +9 Lines 14585 15151 +566 ========================================== + Hits 9833 10365 +532 - Misses 4752 4786 +34 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jhoongo commented 5 months ago

Really great work, just some minor stylistic issues.

Thanks for the review @nachoBonafonte ! I've updated the PR with your feedback and rebase it to the latest main. Please let me know if you still have any further feedback or concern. Thanks,