Commit Graph

216 Commits

Author SHA1 Message Date
Anuraag Agrawal 737a5e2b26
Deprecate GlobalMeterProvider (#3948) 2021-12-03 08:43:49 +09:00
Anuraag Agrawal b1651a18cf
Rename .observe to .record (#3949)
* Rename .observe to .record

* Apply deprecation
2021-12-03 08:37:22 +09:00
jack-berg 37d08f5bf9
Change EmptyAggregator to Drop Aggregator, remove @Nullable (#3887)
* Change EmptyAggregator to Drop Aggregator, remove @Nullable

* Add SdkMeterProvider unit test for drop aggregator

* Move EmptyMetricData to internal package

* Fix merge issue

* Add unit test for EmptyMetricData
2021-12-01 14:19:18 +09:00
jack-berg 3aac6c47d4
Fix metric descriptor compatibility check (#3941) 2021-11-30 18:55:54 -08:00
jack-berg ec45e9476f
Remove supported temporality (#3939)
* Remove supported temporality

* Switch to ternary
2021-11-30 11:43:51 +09:00
jack-berg 947406d149
Drop MinMaxSumCount aggregation (#3929) 2021-11-24 07:57:35 -08:00
jack-berg 201934aef5
Catch throwable in async callbacks, and propagate if fatal (#3922)
* Catch throwable in async callbacks, and propogate if fatal

* Add unit tests, adjust propagate ordering

* Create util function for propagateIfFatal

* PR feedback
2021-11-24 14:39:18 +09:00
jack-berg 12a54710b7
Remove bound instrument from metric API, move to internal package of metric SDK (#3928) 2021-11-24 13:23:31 +09:00
jack-berg bc4f8f75a2
Make InstrumentSelect#getInstrumentType() nullable (#3893) 2021-11-17 18:02:53 -08:00
jack-berg 300c4963d8
Wrap async callbacks in try catch (#3895) 2021-11-17 18:01:39 -08:00
Eugene R 95ada8edd2
Refactor `MeterSharedState` (#3867)
* refactor `MeterSharedState`

* fix format violations

* annotate the register method as Nullable

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
2021-11-17 17:31:53 +09:00
Anuraag Agrawal 7972e84c8d
Enable nullaway for metrics SDK (#3845)
* Enable nullaway for metrics SDK

* Fix nullness

* Fix

* Cleanup

* Exception
2021-11-16 11:39:39 +09:00
Anuraag Agrawal 966c358ef1
Use a wrapper of primitive long array for histogram counts. (#3854)
* Use a wrapper of primitive long array for histogram counts.

* Fix

* Better
2021-11-16 10:53:09 +09:00
Josh Suereth 3ee4936ea2
Fixes #3494 - Removes ofLongs/ofDoubles when the default is long/double for a builder. (#3873) 2021-11-14 12:05:07 -08:00
jack-berg 10d677b736
Cleanup metric deprecations (#3869) 2021-11-12 16:42:57 -08:00
James Moessis 82e2bc2630
Prototype for Exponential Histogram Aggregator (#3724)
* draft for exponential histogram aggregator

* autoscaling for exponential histogram

* more tests for exp histogram

* re-add nr copyright notice after spotlessapply deleted them; convert some comments to javadoc

* change to long index for bucketmapper

* add scale to hashCode for buckets

* implement jsuereth initial review for exphist

* move data and pointdata for exphist into data package

* replace windowedCounterArray with minimal map implementation

* use Arrays.asList() for exposing bucket counts

* remove WindowedCounterArray and MultiTypeCounterArray

* javadoc for ExponentialCounter

* implement and test merge() for exponential histogram aggregation; fix scale reduction bug

* appease spotless check

* optimize inital hashmap size for MapCounter

* merging exphist accumulation not alter original accumulation

* more tests, with a currently failing limit tester

* change map counter to be able to copy any of its interface type

* add dummy switch cases for exponential histogram exporter to appease build

* test fixes

* metrics-testing helpers for exponential histogram

* javadoc and linting

* multithreaded test on update/merge for exphist

* some cleanup

* resolve conflicts

* Update sdk/metrics-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/metrics/ExponentialHistogramAssert.java

Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>

* address some review

* spotless

* add static factories to interface as per anuraag review

* use string concatenation in favour of String.format()

* address minor review comments

* make doIncrement() atomic

* change index from long to int

* refactor aggregator to align with recent Aggregator refactor

* implement diff() for exponential histogram aggregator

* add missing javadoc for metric assertions

* more javadoc for diff()

* remove unnecessary comment

* add another test for diff exphist

* spotless

* address comment regarding failure message

* metric assertions test for exponential histogram assertions

* replace warning log with IllegalStateException

* improve test coverage

* make record package private

* remove unnecessary double check to improve code cov

* add comments

Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
2021-11-11 18:15:22 -08:00
jack-berg 619a1b1526
Cleanup of metrics SDK (#3851) 2021-11-11 08:30:08 -08:00
jason plumb d6d81b43d1
Backfill test coverage for MetricStorageUtils (#3834)
* backfill test coverage for MetricStorageUtils

* rename for consistency

* code review comments

* clarity around diff/merge in results

* more private. more static.

* make public again so errorprone doesn't table flip

* fix test after rebase

* factor out duplicate code
2021-11-10 16:44:41 -08:00
Eugene R 28592b7f6d
use internal `@GuardedBy` annotation (#3853) 2021-11-10 16:40:11 -08:00
jack-berg d20345f0b1
Drop outdated readme hiding in java src (#3852) 2021-11-11 09:38:55 +09:00
jack-berg fc68a88be2
Metric cardinality limits (#3831)
* Drop stale streams, make metrics minimum collection interval configurable

* Limit number of accumulations in async and sync metric storage

* PR feedback
2021-11-09 09:46:14 -08:00
Eugene R 8f2b21b5ff
A few optimizations and documentation fixes (#3843)
* a few optimizations and documentation fixes

* revert addAll
2021-11-09 17:05:40 +09:00
Eugene R 8b86107446
fix potential NPE (#3844) 2021-11-09 16:47:12 +09:00
jack-berg e6cdfbf64a
Use AttributeBuilder#removeIf in AttributeProcessor#filterByKeyName (#3838) 2021-11-09 10:07:47 +09:00
jack-berg c858e1801b
Restore @Immutable annotation on MetricData (#3839) 2021-11-09 08:47:14 +09:00
jack-berg 8d96cb892b
Deprecate MeterProvider#get(..) methods (#3812)
* Deprecate MeterProvider#get(..) methods

* Retain MeterProvider#get(String instrumentationName)
2021-11-05 09:05:30 +09:00
Josh Suereth 8d0052fd3b
Add diagnostic messages for metric registration conflicts. (#3808)
* Add mechanism to track view/instrument registration for errors.

- Create SourceInfo class to track code/config based sources of errors.
- Add SourceInfo creation to both InstrumentDescritpor and View
- Update DuplicateMetricStorageException to remember source
  MetricDescriptors
- Update MetricDescriptor to include source view + instrument
  descriptors.
- Add new error messages with gory detail on conflict that will be
  logged.

* Move InstrumentDescriptor into internal package

We use this class to track instrument sources/debugging so we don't want it exposed publicly.   This just moves it next to MetricDescriptor.

* Fix logs to include throwable.

* Fix javadoc.

* Add mechanism to enable/disable metric diagnostics.

- Create DebugConfig class that knows whether metrics are on/off
- Add testing utility to enable/disable debug configuraiton.
- Update NoSourceInfo to use real enablement message.
- Move "default on" diagnostic tests into their own group, similar to
  context.

* Update to use Thread.getStackTrace

* Fixes from review.
2021-11-03 18:45:40 -07:00
Josh Suereth 8f081ba8a1
Remove AggregationTemporality from View configuration API (#3805)
Update all tests / use cases to leverage exporter-based configuration.
2021-10-29 08:00:09 -07:00
jack-berg 5f259ee4ee
Add remove method to AttributesBuilder (#3771)
* Add remove method to AttributesBuilder

* Improve test coverage

* Remove attributes by nulling out instead of removing from list

* feedback wip

* Add AttributesBuilder#remove(String) method

* Add removeIf() method

* AbstractFixedSizeExemplarReservoir uses more efficient removeIf() attribute filter
2021-10-28 08:47:50 +09:00
jack-berg c4c2e6c9db
Align SdkMeterProvider with SdkTracerProvider (#3792)
* Align SdkMeterProvider with SdkTracerProvider

* Use noop meter provider when metric exporter is none
2021-10-27 10:03:08 -07:00
kryalama 559d0b26b1
remove IntervalMetricReader reference in docs (#3760)
* remove IntervalMetricReader reference in docs

* fix formatting in configuration

* fix more issues

* spotlessApply changes

* Update docs/sdk-configuration.md

Co-authored-by: John Watson <jkwatson@gmail.com>

* more formatting

Co-authored-by: John Watson <jkwatson@gmail.com>
2021-10-26 11:31:48 -07:00
Josh Suereth f6754b66cf
Allow exporters to influence Aggregation (#3762)
* Major refactoring to Aggregator

- Remove all state from Aggregator but for exemplar reservoir factory.
  - Reosurce/IL passed from MP/MeterSharedState
  - MetricDescriptor already stored on MetricStorage.
- Give Aggregators explicit "diff" and "merge" operations, split Sum aggregator
- Update Storage to use explicit diff/merge in appropriate locations.
- Aggregtors are now passed AggregationTemporality in as a parameter
- Update MetricStorage to take requested aggregation tempoarlity as parameter, always storing data for either.

Note: Things compile, aggregator + storage tests pass, but e2e is broken until aggregation temporality is appropriatley wired through to readers.

* Remove extraneous bits of information from AggregatorFactory interface

* Spotless + remove extraneous pieces of data from Aggregation interface.

* Added supported + preferred temprality to export interfaces.

- Add supported/preferred temporality to export interfaces
- Update tracking of collection information through internal packages to pass
  one data class instead of many individual components.

* Finish wiring configured temporality through Views.

- Update gauge tests to account for start time (as recommended in spec).
- Allow configured temporality to be null for views
- Propogate configured temporality from View API through to storage

* Fix remaining gauge tests

* Update exporters to specify desired temporality

* Other build fixes

* Fix javadoc

* add tests for cumulative+delta in temporal storage

- Add cumulative+delta tests
- Fix error messages from sum data assert

* Move diffInPlace and megeInPlace into utility class

* Add explicit test for delta vs. cumulative exporters.

* Spotless fixes

* Remove AggregatorFactory

This interface was fully replaced by Aggregation, and offerred little benefit post-refactor.

* Fixes from review

* Add javadoc for new parameters in temporal metric storage.

* Fixes from review.

* Add some unit tests for the aggregation config

* Add "diff" unit test for histogram + lastvalue

* Apply suggestions from code review

Co-authored-by: John Watson <jkwatson@gmail.com>

* Fixes from code review.

Co-authored-by: John Watson <jkwatson@gmail.com>
2021-10-26 09:39:31 -07:00
jason plumb 5aab26a0d1
Transition MetricData to an interface (#3783)
* Rename MetricData to MetricDataBuilder and extract MetaData interface

* rename abstract class and pull create methods up

* add package private constructor for consistency/safety

* move the defaults into their respective types

* rename default -> empty
2021-10-22 09:06:51 +09:00
jack-berg cde99eb77d
Add InMemoryLogExporter (#3757)
* Add InMemoryLogExporter

* Use synchronized list in in memory exporters

* merge conflict

* Use ConcurrentLinkedQueue
2021-10-21 15:08:52 +09:00
jack-berg 18bed97f99
Remove PMR deprecated methods, fix javadoc (#3782) 2021-10-21 15:05:55 +09:00
Anuraag Agrawal ebf5507cde
Add PeriodicMetricReaderBuilder (#3735)
* Add PeriodicMetricReaderBuilder

* More tests

* Cleanup

* Improve default
2021-10-14 18:28:59 -07:00
jack-berg 4ab882ccd2
Fix typo in Aggregation#explicitBucketHistogram() (#3734) 2021-10-12 19:59:51 -07:00
Anuraag Agrawal 02ef53b109
Some cleanup to InMemoryMetricReader (#3728) 2021-10-12 08:27:57 -07:00
Anuraag Agrawal 5bc953ec68
Replace InMemoryMetricReader constructor with factory. (#3727)
* Replace InMemoryMetricReader constructor with factory.

* Update InMemoryMetricReader.java
2021-10-12 11:06:05 +09:00
Anuraag Agrawal 59e84e9c04
Fix SdkMeterProvider shutdown (#3702) 2021-10-07 08:05:41 -07:00
Josh Suereth 97bbaa6a64
Fix Clock usage in Metrics SDK and slight optimisation to synchronous collection (#3689)
* Add timeout between delta collection to avoid rapid collection cycles across multiple readers.

* Fix issue where exemplars were not sampling wall-clock time.

* Fix synchronous collection supression to track duration using Clock.nanoTime

* Fixes from review.

* Remove leftover TODO.
2021-10-07 22:51:46 +09:00
Josh Suereth 50e2ac76c2
Exemplar data classes should match convention. (#3688)
* Fix #3535 - Exemplar data classes should match convention.

* Fix spotless issue.
2021-10-04 21:03:12 +09:00
Josh Suereth 70086cf014
MetricReader and Multi-export features (#3578)
* Start of multi-exporter codebase.

* Restore InMemoryExporter + fix javadocs.

* Quick javadoc fix

* Fix some javadoc build failures and missing things.

* Fix bug with autoconfigure

* Modify InMemoryMetricReader + register methods to allow for immutable SdkMeterProvider

- InMemoryMetricReader is now a factory + reader
- Hide register on SdkMeterProvider
- Update all tests to make sure things pass.

* Make metric-readers 'immutable' post-construction of SdkMeterProvider.   Update all code around registration of readers and autoconfigure.   Create new 'sdk noop' meter provider for when we have no readers configured.

* Fix integration test.

* Fix jmh benchmarks for trace.

* Fix jmh build.

* Fix broken in-memory exporter things, and Noop API issue.

* Migrate MetricReader.Factory to MetricReaderFactory.

* Rename PeriodMetricReader.Factory to PeriodicMetricReaderFactory.

* Apply suggestions from code review

Co-authored-by: John Watson <jkwatson@gmail.com>

* Minor cleanup of ColectionHandle.

* Fixes from review.

* Extract delta accumulation and add tests.

* Fragment the abstraction in SynchronousMetricStorage for better separation of responsibilities.

* Add tests (and minor optimisation) for delta metric storage.

* Add test for temporal metric storage.

* Update temporal metric storage to fix issue w/ async instruments.

* Migrate Async storage to use temporal metric storage (with better tests).

* Another fix from review.

* Remove start epoch nano parameter from storage constructors.

* Fixes from review.

* Migrate flush -> forceFlush as per review.

* Add test coverage for flush.

* Fixes from review.

* Fix public API breakage.

* Fixes from review.

* Fix threadsafe annotations

Co-authored-by: John Watson <jkwatson@gmail.com>
Co-authored-by: Anuraag Agrawal <aanuraag@amazon.co.jp>
2021-09-30 22:22:09 +09:00
James Moessis 694ac3f34f
Data classes for exponential histogram prototype (#3550) (#3637)
* Data classes for exponential histogram prototype (#3550)
2021-09-30 11:49:29 +09:00
Anuraag Agrawal 0560c82d5c
Enable nullaway except for metrics. (#3668) 2021-09-28 09:28:00 -07:00
Josh Suereth 95551dbbdb
Finish wiring exemplars into metrics SDK (#3599)
* Initial implementation of simple ExemplarReservoirs

- Add an implementation of naive fixed-bucket reservoir sampling
- Add an implementation of FixedSizeHistogram reservoir sampling where latest-measurement per-histogram-bucket is kept.
- Add assertions for exemplars.

* Remove explicit locks for mild performance boost.

* Create a new random holder abstraction.

- Create new random holder abstraction that allows
  - ThreadLocalRandom when efficient
  - simple detection of Android + workaround for TLR
  - Overridable with mocked random for testing.
- Update tracing RandomIdGenerator to leverage new RnadomHolder
- Expand exemplar reservoir tests to use new random holder
- Remove android-only random id generator test

* Add api diff + fix silly naming thing.

* Move random hodler to be Supplier, other updates from code review.

* Fixes from review.

* Fix bytebuddy issue with mocking.

* Expose aggregation configuration and wire in exemplar sampler

- Expose classes for aggregation configuration that are visible in exemplar sampler
- Create default exemplar sampler that samples w/ traces
- Expand metric benchmarks to include exemplar + no-exemplar to check overhead.

* Fix merge conflict.

* Wire exemplar filter config into autoconfigure module.

* Expose aggregation configuration and wire in exemplar sampler

- Expose classes for aggregation configuration that are visible in exemplar sampler
- Create default exemplar sampler that samples w/ traces
- Expand metric benchmarks to include exemplar + no-exemplar to check overhead.

* Fix merge conflict.

* Wire exemplar filter config into autoconfigure module.

* Migrate exemplar reservoir instantiation into aggregations.  Start migrating off AggregatorFactory -> Aggregation.

* Small cleanup.

* Fixes from review (and report of clsasloader fixes from other laptop.

* Migrate to null-object pattern.

* Add internal boilerplate.

* Run spotless.

* Fix toString of aggregation values.

* Fix ==
2021-09-24 13:55:46 -07:00
Anuraag Agrawal b311d50d03
Fix some nullness. (#3647)
* Fix some nullness.

* Log
2021-09-22 09:00:57 -07:00
Josh Suereth e6424654b2
Implementations of Exemplar Reservoirs (#3592)
* Initial implementation of simple ExemplarReservoirs

- Add an implementation of naive fixed-bucket reservoir sampling
- Add an implementation of FixedSizeHistogram reservoir sampling where latest-measurement per-histogram-bucket is kept.
- Add assertions for exemplars.

* Remove explicit locks for mild performance boost.

* Create a new random holder abstraction.

- Create new random holder abstraction that allows
  - ThreadLocalRandom when efficient
  - simple detection of Android + workaround for TLR
  - Overridable with mocked random for testing.
- Update tracing RandomIdGenerator to leverage new RnadomHolder
- Expand exemplar reservoir tests to use new random holder
- Remove android-only random id generator test

* Add api diff + fix silly naming thing.

* Move random hodler to be Supplier, other updates from code review.

* Fixes from review.

* Fix bytebuddy issue with mocking.

* Update sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/exemplar/AbstractFixedSizeExemplarReservoir.java

Co-authored-by: John Watson <jkwatson@gmail.com>

* Fix name from review.

* Update sdk/common/src/main/java/io/opentelemetry/sdk/internal/RandomSupplier.java

Co-authored-by: John Watson <jkwatson@gmail.com>
Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
2021-09-17 13:20:06 +09:00
Josh Suereth 16f9cc2182
Wire in Exemplar Pre-Filters (#3591)
* Add ExemplarFilter as a configurable portion of exemplar system.

* Add tests.

* Fixes from review.

* Apply suggestions from code review

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
2021-09-15 07:49:50 -07:00
Josh Suereth 9170e851e6
Wire Exemplar Reservoir into Metrics SDK (#3583)
* Initially wiring of ExemplarReservoir into Aggregator

- Create ExemplarReservoir + ExemplarSampler public interface
- Wire ExemplarRervoir into Aggregators
- Basic AggregationHandle tests of exemplar interface
- Fix up all tests and things

DOES NOT wire exemplar usage into aggregators yet.

* Fix JMH tests

* Wire exemplar reservoir usage into histogram aggregation

* Wire exemplar reservoirs into long aggregators

* Add DoubleAccumulation and fix exemplars in double-based aggregators.

* Renames from review.

* Fixes from review

- Clean up ExemplarStorageStrategy to have less dumb name
- don't have publicly accessible singletons on interfaces
- Call suppliers, suppliers.

* Rearrange methods on AggregatorHandle.

* More fixes from reviews

* Update documentation for Aggregator and add tests for merge method

- Fix issue in Histogram accumulations merge method
- Update all tests to check merge prefers recent measurement
- Document (likely bug scenario) where async measurements get merged outside a "previous/next" scenario.

* Add package private constructor for Exemplar Sampler.
2021-09-13 10:52:42 -07:00