Commit Graph

910 Commits

Author SHA1 Message Date
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
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
jack-berg 9b9ef48b34
Add autoconfigure for span attribute value length limits (#3602)
* Rename SpanLimitsBuilder.setMaxAttributeLength to setMaxAttributeValueLength

* Add span attribute value length limits to autoconfigure

* Fix build
2021-09-10 14:01:33 -07:00
jack-berg 060e50ed5f
Add attribute length limits to SpanLimits. (#3551)
* Add attribute length limits to SpanLimits.

* Respond to PR feedback

* Respond to PR feedback

* Remove test utility function

* Rename method to getMaxAttributeValueLength
2021-09-10 09:49:55 +09:00
Josh Suereth 8d91eaee1b
Rework LabelsProcessor to have access to context - Update View SDK API (#3562)
* Rename LabelsProcessor to attribtues processor and allow it to interact with context/baggage appropriately.

* Flesh out view API from SDK specification and add tests for new features.

* Add better end-to-end test of baggage/context usage in attributes processor.

* Shrink size of attributes processor from early prototype.

* Reduce public aggregator API to match latest specification. (#3557)

* Move aggregators to internal package so it's not exposed in public API for first release.

* Continue migrating aggregators to hidden api, expose new public api.

* Fix tests.

* Fix up some name issues.

* Fix up javadoc.

* Fix autoconfigure tests.

* Minor cleanups.

* Fixes from review.

* Fixes from review.

* Remove aggregation extension and update tests.

* Fixes from review.

* Fix merge conflicts.

* update from PR feedback.

* Run spotless.

* Fixes from review.
2021-09-03 10:59:02 -07:00
Josh Suereth 3c1c863a98
Reduce public aggregator API to match latest specification. (#3557)
* Move aggregators to internal package so it's not exposed in public API for first release.

* Continue migrating aggregators to hidden api, expose new public api.

* Fix tests.

* Fix up some name issues.

* Fix up javadoc.

* Fix autoconfigure tests.

* Minor cleanups.

* Fixes from review.

* Fixes from review.

* Remove aggregation extension and update tests.

* Fixes from review.
2021-09-01 08:12:54 +09:00
Trask Stalnaker 86eea94b76
Allow creating a SpanContext without validation for internal use (#3564)
* Avoid unnecessary calls to TraceId and SpanId.isValid()

* Alternative: move ImmutableSpanContext to internal package

* javadoc

* Only skip for safe IdGenerators

* Simplify

* Errorprone

* Add test and fix boolean logic

* Spotless

* Add test

* Revert toString test change
2021-08-31 11:09:19 -07:00
Anuraag Agrawal adbf811249
Only compute nanoTime once for a root span. (#3567)
* Only compute nanoTime once for a root span.

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/RecordEventsReadableSpan.java

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/RecordEventsReadableSpan.java

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

Co-authored-by: John Watson <jkwatson@gmail.com>
2021-08-31 08:43:09 +09:00
Anuraag Agrawal 6ef3091cfb
Copy in spotless-conventions from instrumentation repo (#3554)
* Copy in spotless-conventions from instrumentation repo.

* Reformat

* A few more dotfiles
2021-08-27 08:28:31 -07:00
Josh Suereth b19157ed98
Allow multiple views per instrument (#3541)
* Allow synchronous instruments to have multiple views per-instrument.

- Split writeable api from readable api for storage
- Create multi-writeable APIs for when multiple views are defined per instrument.
- Add test to ensure multiple metrics can be exported
- Fix minor issues in registry + sdk meter provider limiting multi-view registration.

* Allow multiple metrics to be registered per async instrument

* Don't fail on metric-identifier overlap, just log.

Does not update tests.

* Fix SdkMeter tests to use logs instead of exceptions

* Fix code reivew comment.

* Fix spotless issue.
2021-08-25 13:44:06 -07:00
jack-berg 4a945e63e3
Add gradle ktlint spotless config to all projects (#3543) 2021-08-25 08:36:17 +09:00
Josh Suereth cc547d2a1d
Update View-wiring to match SDK specificaiton (#3510)
* Modify view lookup order to match SDK specification

* Correctly register views using metric/description name relabelling

* Wire view's metric descriptor into aggregators, allowing metric names to change.

* Add test for view renames.

* Fix jmh and javadoc issues.
2021-08-19 10:51:53 -07:00
Josh Suereth e3bbca0b06
Renaame instruments *Sdk. -> Sdk* (#3508) 2021-08-18 20:02:42 -07:00
Josh Suereth 0e38773e45
View API additons (#3491)
* First set of chaanges for new view SDK

- Update default aggregaators
- Expand instrument selector for views

* Fix tests for histogram as default aggregation.

* Remove unimplemented view methods for now.

* Javadoc cleanups.

* Apply suggestions from code review

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>

* Migrate to predicates for strings, and List instead of Linked maps.

* fix missing bucket count test for histogram stress.

* Add some tests and a few fixes.

* Fixes from review.

* More fixes from review.

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
2021-08-17 08:26:39 -07:00
jack-berg 58c16a9133
Add missing readmes and missing javadoc links (#3500) 2021-08-16 12:36:54 -07:00
Anuraag Agrawal 42da2da1cc
Fix some nullability in SDK. (#3474)
* Fix some nullabiity in SDK.

* Cleanup

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracer.java

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
2021-08-15 09:47:39 +09:00
Anuraag Agrawal 1a881a6946
Fix nullness in Resource (low priority). (#3472) 2021-08-14 14:12:02 +09:00
Trask Stalnaker 651df06cc9
Add getAttribute to ReadableSpan (#3458)
* Add getAttribute to ReadableSpan

* javadoc
2021-08-14 10:33:33 +09:00
Anuraag Agrawal 87f2b5e0a8
Update error-prone (#3485) 2021-08-13 09:44:29 -07:00
Anuraag Agrawal 2844471335
Fix Resource version properties lookup and extract version file gener… (#3467)
* Fix Resource version properties lookup and extract version file generation.

* Only published

* Cleanup

* Better merge

* Fix merge
2021-08-12 10:15:51 -07:00
Anuraag Agrawal 7fb6061af7
Don't create test-specific mocks in BSPTest. (#3469) 2021-08-12 10:05:34 -07:00
Anuraag Agrawal f83ab58317
Fix Nullable of Resource.getAttribute (high priority) (#3473)
* Fix Nullable of Resource.getAttribute

* API
2021-08-12 08:25:19 -07:00
jason plumb cb5198ba99
encapsulate Resource.getAttribute() to help with some law of Demeter violations. (#3468) 2021-08-12 09:06:31 +09:00
Christian Neumüller dd7cae97d5
Fix OpenTelemetrySdk(.tracerProvider).tracerBuilder() being noop. (#3466)
* Add test for obfuscated tracerBuilder.

* Fix bug, add more tests.
2021-08-11 09:02:09 -07:00
Josh Suereth 0752a4bb17
Overhaul sdk.metrics package for new SDK: Decouple Instrument + Storage per-metric. (#3455)
* Peel away dependency between instrument API hooks and aggregator package.

- Create new BoundStorageHandle interface for synchronous instruments to use.
- Update all SDK instruments to use it.

* Set up interfaces for storage registry.

* Create MetricStorage abstraction

- Wire all SDK instruments through a MetricStorage abstraction.
- Move all wiring of measurements -> aggregators into an internal package.
- Migrate previous "Accumulation" classes to "storage" classes
- Do just enough to get things compiling (not tested yet)

Goal is to have the "Aggregator" package not referenced in the sdk.metrics package directly in the future.

* Fix tests for metric storage refactoring.

- Move tests to appropriate location
- For now just make view-things public
- Fix possible bug in test of labels processor + appending attributes in a test....

* Remove instrument registry (now metric registry)

* Rename DoubleValueRecorder => DoubleHistogram in SDK

* Rename LongValueRecorderSdk => LongHistogramSdk.

* Rename ValueObserver -> Gauge

* Rename instrument type enum

Update enum to match specification.

* Move ViewRegistry + Helper into internal package

* Fixes to benchmarks

* Add missing javadoc

* Remove references to Labels

* Fixes from review.

* Rework tryUnmap to test the exposed interface
2021-08-10 13:23:08 -07:00
HaloFour b5f56ccac7
Adds getParentSpanContext to ReadableSpan interface (#3454)
* Adds getParentSpanContext to ReadableSpan

* Unit tests
2021-08-08 11:17:40 +09:00
Josh Suereth 0ef19291c2
Swap old Metrics API for currently specified Metrics API (#3423)
* Update the API to the latest SDK specification.

* API updates to other sdk areas.

* First half of SDK updates for API.

Passing off to other cmoputer.

* Get SDK compiling again.

* Get tests compiling again (and failing).

* Fix bad copy-paste error.

* Get all SDK tests passing.

* More fixes to builds across SDK impls.

* Remove unecessary publics

* more fixes for new API.

* spotless fixes.

* Make tests for metric points order independent.

* Restore readme.

* Fix readmes.

* Add noop meter provider tests for code coverage.

* Add code coverage for assertion library.

* Fix wierd test failure that gradle cache is preventing me from seeing locally.

* Fix javadoc/spelling comments from review.

* Remove marker interfaces.

* Switch from atomic ref to volatile.

* Fixes from review.

* Apply suggestions from code review

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

* Fixes from review.

* Fixes from review.

* Update OTLP HTTP exporter to use new metrics api

Co-authored-by: John Watson <jkwatson@gmail.com>
2021-08-05 13:58:49 -07:00
Anuraag Agrawal ca8a12ff01
Add AttributesAssert.containsKey (#3433) 2021-08-03 12:51:49 -07:00
jack-berg 42831fe004
Add support for signal specific timeout and headers autoconfiguration. (#3434)
* Add support for signal specific timeout and headers autoconfiguration.

* Attempt to fix build.

Co-authored-by: Anuraag Agrawal <aanuraag@amazon.co.jp>
2021-08-03 10:43:45 -07:00
Anuraag Agrawal 2d9a949c70
Add Iterable versions of hasTraces / Spans (#3429) 2021-08-03 10:32:36 -07:00
Trask Stalnaker 60c3c5ca0c
Format build.gradle.kts files (#3427) 2021-07-29 13:21:38 +09:00
Anuraag Agrawal d4bbaf405d
Add containsEntry overload that accepts int (#3412) 2021-07-21 13:41:59 +09:00
BrianYan 9fdd001e58
Add factories for SamplingResult (#3410)
* fix:rebase it

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/SamplingResult.java

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/SamplingResult.java

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/SamplingResult.java

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/SamplingResult.java

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/SamplingResult.java

* Update sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/SamplingResult.java

Co-authored-by: John Watson <jkwatson@gmail.com>
2021-07-20 08:44:53 -07:00
Anuraag Agrawal 8163b9fc00
Add assertion for exception (#3409) 2021-07-20 08:49:40 +09:00
Anuraag Agrawal 3d0485364b
Add hasNoParent assertion (#3406) 2021-07-15 14:09:25 +09:00