Commit Graph

946 Commits

Author SHA1 Message Date
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
Eugene R 90bd4afa21
remove redundant synchronization (#3855) 2021-11-11 19:35:46 +09: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 cb057dda8e
Rework log fields (#3837)
* Rework log fields

* PR feedback
2021-11-09 18:04:09 -08: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
jason plumb 7b86d53427
Let clock be overridden for log creators (#3823)
* Allow the clock to be overridden so that we aren't directly coupled to System.currentTimeMillis()

* move clock usage to dedicated test

* move clock foolery to its own dedicated test method

* address some code review comments and checkstyle violations

* cleanup: remove builder() from LogData interface and remove clock methods from LogBuilder interface.

* make inner impl static

* make method package private

* factor builder out to top-level class and remove creation work from constructor

* fix up tests for SdkLogEmitter and SdkLogBuilder

* backfill coverage for second shutdown

* remove mock
2021-11-09 14:00:33 +09:00
Eugene R e4ea3ab673
avoid redundant allocation of `DefaultThreadFactory` on a `newThread` call (#3836) 2021-11-09 10:19:50 +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
Anuraag Agrawal 3869ecf491
Remove final from methods on final class. (#3816) 2021-11-02 07:48:34 -07:00
jack-berg f171884ed5
Refactor Log SDK to implement OTEP-0150 (#3759)
* Add log processors to the builder so LogSinkSdkProvider is immutable

* Add api diff

* Rename to SdkLogSinkProvider

* Rework log sdk

* Refactor logging sdk to implement OTEP-0150

* Fix typo

* Add unit tests

* Reorganize to facilitate potential future API

* Rename ReadableLog* to SdkLog*, make SdkLog* package private

* Add LogEmitterProvider interface, tidy up some javadoc

* Respond to PR feedback

* Make SdkLogEmitterBuilder final

* Switch to LogEmitter.logBuilder().emit() pattern
2021-11-01 13:16:59 +09: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
jack-berg 9ad1d55779
Fix DelegatingSpanData#toString() typo (#3781) 2021-10-20 15:24:30 -07:00
Anuraag Agrawal 27c48f6ffe
Promote DelegatingSpanData out of incubator. (#3768)
* Promote DelegatingSpanData out of incubator.

* Not final equals
2021-10-20 12:48:56 +09:00
jack-berg c70629356e
Add log processors to the builder so LogSinkSdkProvider is immutable (#3751)
* Add log processors to the builder so LogSinkSdkProvider is immutable

* Add api diff
2021-10-18 09:49:12 -07:00
jack-berg 2241ae6eec
Add SimpleLogProcessor (#3749) 2021-10-15 08:20:05 -07:00
Anuraag Agrawal ebf5507cde
Add PeriodicMetricReaderBuilder (#3735)
* Add PeriodicMetricReaderBuilder

* More tests

* Cleanup

* Improve default
2021-10-14 18:28:59 -07:00
jack-berg 7f56fd2186
LogData nullable spanId, traceId (#3745)
* Add failing test for toProtoLogRecord with minimal fields

* Make LogData spanId and traceId nullable
2021-10-14 10:46:54 -07:00
Anuraag Agrawal 3d4dbec88a
Move logging extension to logs signal module (#3738) 2021-10-14 08:38:43 +09: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 3085c58073
Avoid zipSatisfy (#3705) 2021-10-07 08:11:28 -07: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
Anuraag Agrawal 776b4f71d7
Replace :proto usage with published io.opentelemetry.proto (#3697) 2021-10-06 11:51:17 -07: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
Anuraag Agrawal b7e469f861
Test ResourceBuilder with null inputs (#3672) 2021-09-28 09:16:52 -07:00
Anuraag Agrawal 534eeac73d
Add tests for illegal span limits (#3673) 2021-09-28 09:15:44 -07:00
Anuraag Agrawal f59087b183
Don't crash on null spans in BSP (#3664) 2021-09-27 08:23:23 -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
Anuraag Agrawal b70c114f51
Use concatenation instead of stringbuilder in RERS. (#3646) 2021-09-22 08:16:40 -07:00