Skip to content

Commit

Permalink
Merge branch '1.14.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Nov 22, 2024
2 parents be70882 + f928f0a commit 956ced4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
6 changes: 0 additions & 6 deletions docs/modules/ROOT/pages/contextpropagation.adoc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/observation/instrumenting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To better convey how you can do instrumentation, we need to distinguish two conc
- Context propagation
- Creation of Observations

*Context propagation* - We propagate existing context through threads or network. We use the xref:contextpropagation.adoc[Micrometer Context Propagation] library to define the context and to propagate it through threads. We use dedicated `SenderContext` and `ReceiverContext` objects, together with Micrometer Tracing handlers, to create Observations that propagate context over the wire.
*Context propagation* - We propagate existing context through threads or network. We use the https://docs.micrometer.io/context-propagation/reference/[Micrometer Context Propagation] library to define the context and to propagate it through threads. We use dedicated `SenderContext` and `ReceiverContext` objects, together with Micrometer Tracing handlers, to create Observations that propagate context over the wire.

*Creation of Observations* - We want to wrap an operation in an Observation to get measurements. We need to know if there previously has been a parent Observation to maintain the parent-child relationship of Observations.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class FixedBoundaryHistogram {

/**
* Creates a FixedBoundaryHistogram which tracks the count of values for each bucket
* bound).
* @param buckets - sorted bucket boundaries
* bound.
* @param buckets sorted bucket boundaries
* @param isCumulativeBucketCounts - whether the count values should be cumulative
* count of lower buckets and current bucket.
*/
Expand All @@ -46,10 +46,10 @@ class FixedBoundaryHistogram {

/**
* Returns the number of values that was recorded between previous bucket and the
* queried bucket (upper bound inclusive)
* queried bucket (upper bound inclusive).
* @param bucket - the bucket to find values for
* @return 0 if bucket is not a valid bucket otherwise number of values recorded
* between (index(bucket) - 1, bucket]
* between (previous bucket, bucket]
*/
private long countAtBucket(double bucket) {
int index = Arrays.binarySearch(buckets, bucket);
Expand All @@ -75,7 +75,7 @@ void record(long value) {
* valueToRecord is greater than the highest bucket.
*/
// VisibleForTesting
int leastLessThanOrEqualTo(long valueToRecord) {
int leastLessThanOrEqualTo(double valueToRecord) {
int low = 0;
int high = buckets.length - 1;

Expand Down Expand Up @@ -121,7 +121,7 @@ public CountAtBucket next() {
* Returns the list of {@link CountAtBucket} for each of the buckets tracked by this
* histogram.
*/
CountAtBucket[] getCountsAtBucket() {
CountAtBucket[] getCountAtBuckets() {
CountAtBucket[] countAtBuckets = new CountAtBucket[this.buckets.length];
long cumulativeCount = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected Supplier<CountAtBucket[]> valueSupplier() {
return () -> {
CountAtBucket[] countAtBuckets;
synchronized (fixedBoundaryHistogram) {
countAtBuckets = fixedBoundaryHistogram.getCountsAtBucket();
countAtBuckets = fixedBoundaryHistogram.getCountAtBuckets();
fixedBoundaryHistogram.reset();
}
return countAtBuckets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,25 @@ void testReset() {
fixedBoundaryHistogram.record(1);
fixedBoundaryHistogram.record(10);
fixedBoundaryHistogram.record(100);
assertThat(fixedBoundaryHistogram.getCountsAtBucket()).allMatch(countAtBucket -> countAtBucket.count() == 1);
assertThat(fixedBoundaryHistogram.getCountAtBuckets()).isNotEmpty()
.allMatch(countAtBucket -> countAtBucket.count() == 1);
fixedBoundaryHistogram.reset();
assertThat(fixedBoundaryHistogram.getCountsAtBucket()).allMatch(countAtBucket -> countAtBucket.count() == 0);
assertThat(fixedBoundaryHistogram.getCountAtBuckets()).isNotEmpty()
.allMatch(countAtBucket -> countAtBucket.count() == 0);
}

@Test
void testCountsAtBucket() {
void testCountAtBuckets() {
fixedBoundaryHistogram.record(1);
fixedBoundaryHistogram.record(10);
fixedBoundaryHistogram.record(100);
assertThat(fixedBoundaryHistogram.getCountsAtBucket()).allMatch(countAtBucket -> countAtBucket.count() == 1);
assertThat(fixedBoundaryHistogram.getCountAtBuckets()).isNotEmpty()
.allMatch(countAtBucket -> countAtBucket.count() == 1);
fixedBoundaryHistogram.reset();
assertThat(fixedBoundaryHistogram.getCountsAtBucket()).allMatch(countAtBucket -> countAtBucket.count() == 0);
assertThat(fixedBoundaryHistogram.getCountAtBuckets()).isNotEmpty()
.allMatch(countAtBucket -> countAtBucket.count() == 0);
fixedBoundaryHistogram.record(0);
assertThat(fixedBoundaryHistogram.getCountsAtBucket()).containsExactly(new CountAtBucket(1.0, 1),
assertThat(fixedBoundaryHistogram.getCountAtBuckets()).containsExactly(new CountAtBucket(1.0, 1),
new CountAtBucket(10.0, 0), new CountAtBucket(100.0, 0));
}

Expand All @@ -82,7 +86,7 @@ void testCumulativeCounts() {
fixedBoundaryHistogram.record(1);
fixedBoundaryHistogram.record(10);
fixedBoundaryHistogram.record(100);
assertThat(fixedBoundaryHistogram.getCountsAtBucket()).containsExactly(new CountAtBucket(1.0, 1),
assertThat(fixedBoundaryHistogram.getCountAtBuckets()).containsExactly(new CountAtBucket(1.0, 1),
new CountAtBucket(10.0, 2), new CountAtBucket(100.0, 3));
}

Expand Down

0 comments on commit 956ced4

Please sign in to comment.