From 6d55608fbdfaf7cd7397967246c7de1656b34326 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 14 Dec 2021 12:23:44 -0500 Subject: [PATCH 1/7] Bump release version. (#2086) --- README.md | 12 ++++++------ build.gradle | 2 +- examples/build.gradle | 2 +- examples/pom.xml | 2 +- examples/spring/servlet/build.gradle | 4 ++-- .../exporter/metrics/ocagent/OcAgentNodeUtils.java | 2 +- .../exporter/trace/ocagent/OcAgentNodeUtils.java | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 960e38a916..69619e36ef 100644 --- a/README.md +++ b/README.md @@ -32,14 +32,14 @@ For Maven add to your `pom.xml`: io.opencensus opencensus-api - 0.28.3 + 0.29.0 ``` For Gradle add to your dependencies: ```groovy -compile 'io.opencensus:opencensus-api:0.28.3' +compile 'io.opencensus:opencensus-api:0.29.0' ``` ### Hello "OpenCensus" trace events @@ -182,12 +182,12 @@ For Maven add to your `pom.xml`: io.opencensus opencensus-api - 0.28.3 + 0.29.0 io.opencensus opencensus-impl - 0.28.3 + 0.29.0 runtime @@ -195,8 +195,8 @@ For Maven add to your `pom.xml`: For Gradle add to your dependencies: ```groovy -compile 'io.opencensus:opencensus-api:0.28.3' -runtime 'io.opencensus:opencensus-impl:0.28.3' +compile 'io.opencensus:opencensus-api:0.29.0' +runtime 'io.opencensus:opencensus-impl:0.29.0' ``` ### How to setup exporters? diff --git a/build.gradle b/build.gradle index 68fde6694c..6b95f47c25 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ subprojects { } group = "io.opencensus" - version = "0.29.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION + version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION sourceCompatibility = 1.7 targetCompatibility = 1.7 diff --git a/examples/build.gradle b/examples/build.gradle index 87136db1e6..7da0b133e6 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -31,7 +31,7 @@ repositories { } group = "io.opencensus" -version = "0.29.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION +version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION def opencensusVersion = "0.28.3" // LATEST_OPENCENSUS_RELEASE_VERSION def grpcVersion = "1.32.2" // CURRENT_GRPC_VERSION diff --git a/examples/pom.xml b/examples/pom.xml index 2369bff21a..f6cbb737ee 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -5,7 +5,7 @@ io.opencensus opencensus-examples jar - 0.29.0-SNAPSHOT + 0.30.0-SNAPSHOT opencensus-examples http://maven.apache.org diff --git a/examples/spring/servlet/build.gradle b/examples/spring/servlet/build.gradle index 640ab5d961..aa0a801eb8 100644 --- a/examples/spring/servlet/build.gradle +++ b/examples/spring/servlet/build.gradle @@ -30,7 +30,7 @@ repositories { } group = "io.opencensus" -version = "0.29.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION +version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION def opencensusVersion = "0.26.0" // LATEST_OPENCENSUS_RELEASE_VERSION def prometheusVersion = "0.6.0" @@ -85,7 +85,7 @@ apply plugin: 'io.spring.dependency-management' bootJar { mainClassName = 'com.baeldung.Application' baseName = 'opencensus-examples-spring-servlet' - version = "0.29.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION + version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION } sourceCompatibility = 1.8 diff --git a/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java b/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java index 02f3bec86d..09bd059843 100644 --- a/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java +++ b/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java @@ -39,7 +39,7 @@ final class OcAgentNodeUtils { // The current version of the OpenCensus OC-Agent Exporter. @VisibleForTesting - static final String OC_AGENT_EXPORTER_VERSION = "0.29.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + static final String OC_AGENT_EXPORTER_VERSION = "0.30.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION @Nullable private static final io.opencensus.resource.Resource AUTO_DETECTED_RESOURCE = diff --git a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java index caf7e63f3c..d8571a79dd 100644 --- a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java +++ b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java @@ -38,7 +38,7 @@ final class OcAgentNodeUtils { // The current version of the OpenCensus OC-Agent Exporter. @VisibleForTesting - static final String OC_AGENT_EXPORTER_VERSION = "0.29.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + static final String OC_AGENT_EXPORTER_VERSION = "0.30.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION @Nullable private static final io.opencensus.resource.Resource AUTO_DETECTED_RESOURCE = From 93d13d2b3a7cdb06f374a3e81522d98d8bb4bee5 Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Thu, 16 Dec 2021 08:44:52 -0500 Subject: [PATCH 2/7] Test against log4j 2.16.0 (#2087) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6b95f47c25..703d32c981 100644 --- a/build.gradle +++ b/build.gradle @@ -166,7 +166,7 @@ subprojects { googleAuthVersion = '0.20.0' googleCloudBetaVersion = '0.100.0-beta' googleCloudGaVersion = '1.82.0' - log4j2Version = '2.15.0' + log4j2Version = '2.16.0' signalfxVersion = '0.0.48' springBoot2Version = '2.1.5.RELEASE' springBootVersion = '1.5.15.RELEASE' From 158450785c3ff0d6a6660b8918515ad31fd03478 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 16 Dec 2021 23:45:19 -0500 Subject: [PATCH 3/7] Bump release version. (#2088) --- README.md | 12 ++++++------ build.gradle | 2 +- examples/build.gradle | 4 ++-- examples/pom.xml | 2 +- examples/spring/servlet/build.gradle | 2 +- .../exporter/metrics/ocagent/OcAgentNodeUtils.java | 2 +- .../exporter/trace/ocagent/OcAgentNodeUtils.java | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 69619e36ef..10b1789a66 100644 --- a/README.md +++ b/README.md @@ -32,14 +32,14 @@ For Maven add to your `pom.xml`: io.opencensus opencensus-api - 0.29.0 + 0.30.0 ``` For Gradle add to your dependencies: ```groovy -compile 'io.opencensus:opencensus-api:0.29.0' +compile 'io.opencensus:opencensus-api:0.30.0' ``` ### Hello "OpenCensus" trace events @@ -182,12 +182,12 @@ For Maven add to your `pom.xml`: io.opencensus opencensus-api - 0.29.0 + 0.30.0 io.opencensus opencensus-impl - 0.29.0 + 0.30.0 runtime @@ -195,8 +195,8 @@ For Maven add to your `pom.xml`: For Gradle add to your dependencies: ```groovy -compile 'io.opencensus:opencensus-api:0.29.0' -runtime 'io.opencensus:opencensus-impl:0.29.0' +compile 'io.opencensus:opencensus-api:0.30.0' +runtime 'io.opencensus:opencensus-impl:0.30.0' ``` ### How to setup exporters? diff --git a/build.gradle b/build.gradle index 703d32c981..722ebb5a7e 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ subprojects { } group = "io.opencensus" - version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION + version = "0.31.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION sourceCompatibility = 1.7 targetCompatibility = 1.7 diff --git a/examples/build.gradle b/examples/build.gradle index 7da0b133e6..6c83d90233 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -31,9 +31,9 @@ repositories { } group = "io.opencensus" -version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION +version = "0.31.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION -def opencensusVersion = "0.28.3" // LATEST_OPENCENSUS_RELEASE_VERSION +def opencensusVersion = "0.30.0" // LATEST_OPENCENSUS_RELEASE_VERSION def grpcVersion = "1.32.2" // CURRENT_GRPC_VERSION def prometheusVersion = "0.6.0" def jettyVersion = "9.4.17.v20190418" diff --git a/examples/pom.xml b/examples/pom.xml index f6cbb737ee..8f3dbfb165 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -5,7 +5,7 @@ io.opencensus opencensus-examples jar - 0.30.0-SNAPSHOT + 0.31.0-SNAPSHOT opencensus-examples http://maven.apache.org diff --git a/examples/spring/servlet/build.gradle b/examples/spring/servlet/build.gradle index aa0a801eb8..bb07aa8e00 100644 --- a/examples/spring/servlet/build.gradle +++ b/examples/spring/servlet/build.gradle @@ -85,7 +85,7 @@ apply plugin: 'io.spring.dependency-management' bootJar { mainClassName = 'com.baeldung.Application' baseName = 'opencensus-examples-spring-servlet' - version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION + version = "0.31.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION } sourceCompatibility = 1.8 diff --git a/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java b/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java index 09bd059843..72307d5062 100644 --- a/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java +++ b/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java @@ -39,7 +39,7 @@ final class OcAgentNodeUtils { // The current version of the OpenCensus OC-Agent Exporter. @VisibleForTesting - static final String OC_AGENT_EXPORTER_VERSION = "0.30.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + static final String OC_AGENT_EXPORTER_VERSION = "0.31.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION @Nullable private static final io.opencensus.resource.Resource AUTO_DETECTED_RESOURCE = diff --git a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java index d8571a79dd..a989e7c6d3 100644 --- a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java +++ b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java @@ -38,7 +38,7 @@ final class OcAgentNodeUtils { // The current version of the OpenCensus OC-Agent Exporter. @VisibleForTesting - static final String OC_AGENT_EXPORTER_VERSION = "0.30.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + static final String OC_AGENT_EXPORTER_VERSION = "0.31.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION @Nullable private static final io.opencensus.resource.Resource AUTO_DETECTED_RESOURCE = From 0899c0b28605afbdcbadb058131d6d9192a2704f Mon Sep 17 00:00:00 2001 From: Abhay Mujumdar Date: Fri, 17 Dec 2021 20:48:59 -0500 Subject: [PATCH 4/7] Add text for upgrading to latest log4j (#2089) * Add text for upgrading to latest log4j * Update the package-specific README too Co-authored-by: Punya Biswal --- README.md | 12 ++++++++++++ contrib/log_correlation/log4j2/README.md | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 10b1789a66..a133ff3b15 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,18 @@ [![Windows Build Status][appveyor-image]][appveyor-url] [![Coverage Status][codecov-image]][codecov-url] +> :exclamation: The [opencensus-contrib-log-correlation-log4j2](https://github.com/census-instrumentation/opencensus-java/tree/master/contrib/log_correlation/stackdriver) +> Java client library is part of the OpenCensus project. +> [CVE-2021-44228](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228) +> and [CVE-2021-45046](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45046) disclosed +> security vulnerabilities in the Apache Log4j 2 version 2.15 or below. The recent version +> v0.28.3 depends on Log4j 2.11.1. A number of previous versions also depend on vulnerable +> Log4j versions. +> +> :exclamation: We merged several fixes and published a release that depends on a safe version of +> Log4j (2.16). **We strongly encourage customers who depend on the +> opencensus-contrib-log-correlation-log4j2 library to upgrade to the latest +> release [(v0.30.0)](https://repo1.maven.org/maven2/io/opencensus/opencensus-contrib-log-correlation-log4j2/0.30.0/).** OpenCensus is a toolkit for collecting application performance and behavior data. It currently includes 3 apis: stats, tracing and tags. diff --git a/contrib/log_correlation/log4j2/README.md b/contrib/log_correlation/log4j2/README.md index 3d256a1d7e..ec980028b0 100644 --- a/contrib/log_correlation/log4j2/README.md +++ b/contrib/log_correlation/log4j2/README.md @@ -1,5 +1,16 @@ # OpenCensus Log4j 2 Log Correlation +> :exclamation: [CVE-2021-44228](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228) +> and [CVE-2021-45046](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45046) disclosed +> security vulnerabilities in the Apache Log4j 2 version 2.15 or below. The recent version +> v0.28.3 depends on Log4j 2.11.1. A number of previous versions also depend on vulnerable +> Log4j versions. +> +> :exclamation: We merged several fixes and published a release that depends on a safe version of +> Log4j (2.16). **We strongly encourage customers who depend on the +> opencensus-contrib-log-correlation-log4j2 library to upgrade to the latest +> release [(v0.30.0)](https://repo1.maven.org/maven2/io/opencensus/opencensus-contrib-log-correlation-log4j2/0.30.0/).** + The `opencensus-contrib-log-correlation-log4j2` artifact provides a [Log4j 2](https://logging.apache.org/log4j/2.x/) [`ContextDataInjector`](https://logging.apache.org/log4j/2.x/manual/extending.html#Custom_ContextDataInjector) From 81225afc9a7979e9e64b45d0311e40441b6dfdd1 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Fri, 14 Jan 2022 00:02:20 +0100 Subject: [PATCH 5/7] fix: Shutdown Stackdriver MetricServiceClient properly (#2091) Using the default configuration of StackdriverStatsConfiguration, a MetricServiceClient is initialized by the StackdriverStatsExporter. This client was never closed, this will be done now when the .unregister() method is called on the exporter. If a custom MetricServiceStub is given by the user, it will *not* be closed as the user should be in charge of it. --- CHANGELOG.md | 2 ++ .../stackdriver/StackdriverStatsExporter.java | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f908a339..d87ac88589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Unreleased +- fix: Shutdown `MetricServiceClient` properly on `StackdriverStatsExporter.unregister()` (#2007) + ## 0.28.3 - 2021-01-12 - fix: Return public access to unsafe `ContextUtils` api. Remove bincompat issue from 0.27.1. (#2072) diff --git a/exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java b/exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java index d68019a399..cc2d1a9b81 100644 --- a/exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java +++ b/exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java @@ -77,6 +77,10 @@ public final class StackdriverStatsExporter { @Nullable private static StackdriverStatsExporter instance = null; + @GuardedBy("monitor") + @Nullable + private static MetricServiceClient metricServiceClient = null; + private static final String EXPORTER_SPAN_NAME = "ExportMetricsToStackdriver"; // See io.grpc.internal.GrpcUtil.USER_AGENT_KEY @@ -392,10 +396,13 @@ private static void createInternal( throws IOException { synchronized (monitor) { checkState(instance == null, "Stackdriver stats exporter is already created."); - MetricServiceClient client = - stub == null - ? createMetricServiceClient(credentials, deadline) - : MetricServiceClient.create(stub); + final MetricServiceClient client; + if (stub == null) { + metricServiceClient = createMetricServiceClient(credentials, deadline); + client = metricServiceClient; + } else { + client = MetricServiceClient.create(stub); + } instance = new StackdriverStatsExporter( projectId, @@ -445,6 +452,10 @@ public static void unregister() { instance.intervalMetricReader.stop(); } instance = null; + if (metricServiceClient != null) { + metricServiceClient.close(); + metricServiceClient = null; + } } } } From 2e90f499881f601bfee1942b8bbfa2f79eaccc34 Mon Sep 17 00:00:00 2001 From: Mackenzie Starr Date: Mon, 24 Jan 2022 14:43:21 -0500 Subject: [PATCH 6/7] implement gRPC client retry stats measures and views (#2084) * implement gRPC client retry stats measures and views based on https://github.com/grpc/proposal/blob/master/A45-retry-stats.md#metrics-to-expose * fix aggregation arguments for new RpcViewConstants * attempt to fix checkstyle * add more sensible bucket boundaries for retry per call histograms * remove extraneous buckets and make >= 5 the upper bound * apply fix pointed out by @asafdav2 --- .../grpc/metrics/RpcMeasureConstants.java | 31 ++++++++ .../grpc/metrics/RpcViewConstants.java | 76 +++++++++++++++++++ .../contrib/grpc/metrics/RpcViews.java | 27 +++++++ .../grpc/metrics/RpcMeasureConstantsTest.java | 3 + .../grpc/metrics/RpcViewConstantsTest.java | 14 +++- .../contrib/grpc/metrics/RpcViewsTest.java | 8 ++ 6 files changed, 157 insertions(+), 2 deletions(-) diff --git a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java index 8bb66d2d3b..215e4de795 100644 --- a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java +++ b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java @@ -227,6 +227,37 @@ public final class RpcMeasureConstants { Measure.MeasureLong.create( "grpc.io/client/started_rpcs", "Number of started client RPCs.", COUNT); + /** + * {@link Measure} for total number of retry or hedging attempts excluding transparent retries + * made during the client call. + * + * @since 0.31.0 + */ + public static final MeasureLong GRPC_CLIENT_RETRIES_PER_CALL = + Measure.MeasureLong.create( + "grpc.io/client/retries_per_call", "Number of retries per call.", COUNT); + + /** + * {@link Measure} for total number of transparent retries made during the client call. + * + * @since 0.28 + */ + public static final MeasureLong GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL = + Measure.MeasureLong.create( + "grpc.io/client/transparent_retries_per_call", + "Number of transparent retries per call.", + COUNT); + + /** + * {@link Measure} for total time of delay while there is no active attempt during the client + * call. + * + * @since 0.28 + */ + public static final MeasureLong GRPC_CLIENT_RETRY_DELAY_PER_CALL = + Measure.MeasureLong.create( + "grpc.io/client/retry_delay_per_call", "Retry delay per call.", MILLISECOND); + /** * {@link Measure} for gRPC client error counts. * diff --git a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java index 3adb75359f..35dffdddad 100644 --- a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java +++ b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java @@ -21,6 +21,8 @@ import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_RECEIVED_BYTES_PER_RPC; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_RECEIVED_MESSAGES_PER_METHOD; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC; +import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_RETRIES_PER_CALL; +import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_RETRY_DELAY_PER_CALL; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_ROUNDTRIP_LATENCY; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_SENT_BYTES_PER_METHOD; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_SENT_BYTES_PER_RPC; @@ -29,6 +31,7 @@ import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_SERVER_LATENCY; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_STARTED_RPCS; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_STATUS; +import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_SERVER_METHOD; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_SERVER_RECEIVED_BYTES_PER_METHOD; import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.GRPC_SERVER_RECEIVED_BYTES_PER_RPC; @@ -131,6 +134,10 @@ public final class RpcViewConstants { 0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0, 8192.0, 16384.0, 32768.0, 65536.0)); + @VisibleForTesting + static final List RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES = + Collections.unmodifiableList(Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0)); + // Use Aggregation.Mean to record sum and count stats at the same time. @VisibleForTesting static final Aggregation MEAN = Aggregation.Mean.create(); @VisibleForTesting static final Aggregation COUNT = Count.create(); @@ -151,6 +158,10 @@ public final class RpcViewConstants { static final Aggregation AGGREGATION_WITH_COUNT_HISTOGRAM = Distribution.create(BucketBoundaries.create(RPC_COUNT_BUCKET_BOUNDARIES)); + @VisibleForTesting + static final Aggregation AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM = + Distribution.create(BucketBoundaries.create(RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES)); + @VisibleForTesting static final Duration MINUTE = Duration.create(60, 0); @VisibleForTesting static final Duration HOUR = Duration.create(60 * 60, 0); @@ -502,6 +513,71 @@ public final class RpcViewConstants { COUNT, Arrays.asList(GRPC_CLIENT_METHOD)); + /** + * {@link View} for client retries per call. + * + * @since 0.28 + */ + public static final View GRPC_CLIENT_RETRIES_PER_CALL_VIEW = + View.create( + View.Name.create("grpc.io/client/retries_per_call"), + "Number of client retries per call", + GRPC_CLIENT_RETRIES_PER_CALL, + AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM, + Arrays.asList(GRPC_CLIENT_METHOD)); + + /** + * {@link View} for total transparent client retries across calls. + * + * @since 0.28 + */ + public static final View GRPC_CLIENT_TRANSPARENT_RETRIES_VIEW = + View.create( + View.Name.create("grpc.io/client/transparent_retries"), + "Total number of transparent client retries across calls", + GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL, + SUM, + Arrays.asList(GRPC_CLIENT_METHOD)); + + /** + * {@link View} for total time of delay while there is no active attempt during the client call. + * + * @since 0.28 + */ + public static final View GRPC_CLIENT_RETRY_DELAY_PER_CALL_VIEW = + View.create( + View.Name.create("grpc.io/client/retry_delay_per_call"), + "Total time of delay while there is no active attempt during the client call", + GRPC_CLIENT_RETRY_DELAY_PER_CALL, + AGGREGATION_WITH_MILLIS_HISTOGRAM, + Arrays.asList(GRPC_CLIENT_METHOD)); + + /** + * {@link View} for total retries across all calls, excluding transparent retries. + * + * @since 0.28 + */ + public static final View GRPC_CLIENT_RETRIES_VIEW = + View.create( + View.Name.create("grpc.io/client/retries"), + "Total number of client retries across all calls", + GRPC_CLIENT_RETRIES_PER_CALL, + SUM, + Arrays.asList(GRPC_CLIENT_METHOD)); + + /** + * {@link View} for transparent retries per call. + * + * @since 0.28 + */ + public static final View GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL_VIEW = + View.create( + View.Name.create("grpc.io/client/transparent_retries_per_call"), + "Number of transparent client retries per call", + GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL, + AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM, + Arrays.asList(GRPC_CLIENT_METHOD)); + // Rpc server cumulative views. /** diff --git a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java index f454a8cee5..1926c30a59 100644 --- a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java +++ b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java @@ -144,6 +144,15 @@ public final class RpcViews { RpcViewConstants.GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW, RpcViewConstants.GRPC_CLIENT_STARTED_RPC_VIEW); + @VisibleForTesting + static final ImmutableSet GRPC_CLIENT_RETRY_VIEWS_SET = + ImmutableSet.of( + RpcViewConstants.GRPC_CLIENT_RETRIES_PER_CALL_VIEW, + RpcViewConstants.GRPC_CLIENT_RETRIES_VIEW, + RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL_VIEW, + RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_VIEW, + RpcViewConstants.GRPC_CLIENT_RETRY_DELAY_PER_CALL_VIEW); + @VisibleForTesting static final ImmutableSet GRPC_SERVER_BASIC_VIEWS_SET = ImmutableSet.of( @@ -188,6 +197,24 @@ static void registerClientGrpcViews(ViewManager viewManager) { } } + /** + * Registers client retry gRPC views. + * + *

It is recommended to call this method before doing any RPC call to avoid missing stats. + * + * @since 0.31.0 + */ + public static void registerClientRetryGrpcViews() { + registerClientRetryGrpcViews(Stats.getViewManager()); + } + + @VisibleForTesting + static void registerClientRetryGrpcViews(ViewManager viewManager) { + for (View view : GRPC_CLIENT_RETRY_VIEWS_SET) { + viewManager.registerView(view); + } + } + /** * Registers all standard server gRPC views. * diff --git a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstantsTest.java b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstantsTest.java index 21e92c6cd0..18146135a5 100644 --- a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstantsTest.java +++ b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstantsTest.java @@ -57,6 +57,9 @@ public void testConstants() { assertThat(RpcMeasureConstants.GRPC_CLIENT_SERVER_LATENCY).isNotNull(); assertThat(RpcMeasureConstants.GRPC_CLIENT_ROUNDTRIP_LATENCY).isNotNull(); assertThat(RpcMeasureConstants.GRPC_CLIENT_STARTED_RPCS).isNotNull(); + assertThat(RpcMeasureConstants.GRPC_CLIENT_RETRIES_PER_CALL).isNotNull(); + assertThat(RpcMeasureConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL).isNotNull(); + assertThat(RpcMeasureConstants.GRPC_CLIENT_RETRY_DELAY_PER_CALL).isNotNull(); // Test server measurement descriptors. assertThat(RpcMeasureConstants.RPC_SERVER_ERROR_COUNT).isNotNull(); diff --git a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java index 87875ceab0..0212487d6a 100644 --- a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java +++ b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java @@ -66,6 +66,9 @@ public void testConstants() { 0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0, 8192.0, 16384.0, 32768.0, 65536.0) .inOrder(); + assertThat(RpcViewConstants.RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES) + .containsExactly(1.0, 2.0, 3.0, 4.0, 5.0) + .inOrder(); // Test Aggregations assertThat(RpcViewConstants.MEAN).isEqualTo(Mean.create()); @@ -82,7 +85,10 @@ public void testConstants() { .isEqualTo( Distribution.create( BucketBoundaries.create(RpcViewConstants.RPC_COUNT_BUCKET_BOUNDARIES))); - + assertThat(RpcViewConstants.AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM) + .isEqualTo( + Distribution.create( + BucketBoundaries.create(RpcViewConstants.RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES))); // Test Duration and Window assertThat(RpcViewConstants.MINUTE).isEqualTo(Duration.create(60, 0)); assertThat(RpcViewConstants.HOUR).isEqualTo(Duration.create(60 * 60, 0)); @@ -112,7 +118,11 @@ public void testConstants() { assertThat(RpcViewConstants.GRPC_CLIENT_SENT_MESSAGES_PER_METHOD_VIEW).isNotNull(); assertThat(RpcViewConstants.GRPC_CLIENT_RECEIVED_MESSAGES_PER_METHOD_VIEW).isNotNull(); assertThat(RpcViewConstants.GRPC_CLIENT_SERVER_LATENCY_VIEW).isNotNull(); - assertThat(RpcViewConstants.GRPC_CLIENT_STARTED_RPC_VIEW).isNotNull(); + assertThat(RpcViewConstants.GRPC_CLIENT_RETRIES_PER_CALL_VIEW).isNotNull(); + assertThat(RpcViewConstants.GRPC_CLIENT_RETRIES_VIEW).isNotNull(); + assertThat(RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL_VIEW).isNotNull(); + assertThat(RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_VIEW).isNotNull(); + assertThat(RpcViewConstants.GRPC_CLIENT_RETRY_DELAY_PER_CALL_VIEW).isNotNull(); // Test server distribution view descriptors. assertThat(RpcViewConstants.RPC_SERVER_ERROR_COUNT_VIEW).isNotNull(); diff --git a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewsTest.java b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewsTest.java index 70f3dd3fdf..5052ab17a8 100644 --- a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewsTest.java +++ b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewsTest.java @@ -83,6 +83,14 @@ public void registerClientGrpcViews() { .containsExactlyElementsIn(RpcViews.GRPC_CLIENT_VIEWS_SET); } + @Test + public void registerClientRetryGrpcViews() { + FakeViewManager fakeViewManager = new FakeViewManager(); + RpcViews.registerClientRetryGrpcViews(fakeViewManager); + assertThat(fakeViewManager.getRegisteredViews()) + .containsExactlyElementsIn(RpcViews.GRPC_CLIENT_RETRY_VIEWS_SET); + } + @Test public void registerServerGrpcViews() { FakeViewManager fakeViewManager = new FakeViewManager(); From 3b0b339fc26910ffcd9479295665ac56de5c9e88 Mon Sep 17 00:00:00 2001 From: Punya Biswal Date: Tue, 25 Jan 2022 16:30:56 +0000 Subject: [PATCH 7/7] Bump version to 0.31.0 --- .../io/opencensus/common/OpenCensusLibraryInformation.java | 2 +- build.gradle | 2 +- examples/build.gradle | 2 +- examples/pom.xml | 2 +- examples/spring/servlet/build.gradle | 4 ++-- .../opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java | 2 +- .../opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java b/api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java index ce285b1930..234e6d19ae 100644 --- a/api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java +++ b/api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java @@ -29,7 +29,7 @@ public final class OpenCensusLibraryInformation { * * @since 0.8 */ - public static final String VERSION = "0.29.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + public static final String VERSION = "0.29.0"; // CURRENT_OPENCENSUS_VERSION private OpenCensusLibraryInformation() {} } diff --git a/build.gradle b/build.gradle index 722ebb5a7e..5bfef1e13e 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ subprojects { } group = "io.opencensus" - version = "0.31.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION + version = "0.31.0" // CURRENT_OPENCENSUS_VERSION sourceCompatibility = 1.7 targetCompatibility = 1.7 diff --git a/examples/build.gradle b/examples/build.gradle index 6c83d90233..c1010bb217 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -31,7 +31,7 @@ repositories { } group = "io.opencensus" -version = "0.31.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION +version = "0.31.0" // CURRENT_OPENCENSUS_VERSION def opencensusVersion = "0.30.0" // LATEST_OPENCENSUS_RELEASE_VERSION def grpcVersion = "1.32.2" // CURRENT_GRPC_VERSION diff --git a/examples/pom.xml b/examples/pom.xml index 8f3dbfb165..2aab89989b 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -5,7 +5,7 @@ io.opencensus opencensus-examples jar - 0.31.0-SNAPSHOT + 0.31.0 opencensus-examples http://maven.apache.org diff --git a/examples/spring/servlet/build.gradle b/examples/spring/servlet/build.gradle index bb07aa8e00..d5e6723e37 100644 --- a/examples/spring/servlet/build.gradle +++ b/examples/spring/servlet/build.gradle @@ -30,7 +30,7 @@ repositories { } group = "io.opencensus" -version = "0.30.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION +version = "0.30.0" // CURRENT_OPENCENSUS_VERSION def opencensusVersion = "0.26.0" // LATEST_OPENCENSUS_RELEASE_VERSION def prometheusVersion = "0.6.0" @@ -85,7 +85,7 @@ apply plugin: 'io.spring.dependency-management' bootJar { mainClassName = 'com.baeldung.Application' baseName = 'opencensus-examples-spring-servlet' - version = "0.31.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION + version = "0.31.0" // CURRENT_OPENCENSUS_VERSION } sourceCompatibility = 1.8 diff --git a/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java b/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java index 72307d5062..6c20994508 100644 --- a/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java +++ b/exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/OcAgentNodeUtils.java @@ -39,7 +39,7 @@ final class OcAgentNodeUtils { // The current version of the OpenCensus OC-Agent Exporter. @VisibleForTesting - static final String OC_AGENT_EXPORTER_VERSION = "0.31.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + static final String OC_AGENT_EXPORTER_VERSION = "0.31.0"; // CURRENT_OPENCENSUS_VERSION @Nullable private static final io.opencensus.resource.Resource AUTO_DETECTED_RESOURCE = diff --git a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java index a989e7c6d3..7ffd3629a7 100644 --- a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java +++ b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java @@ -38,7 +38,7 @@ final class OcAgentNodeUtils { // The current version of the OpenCensus OC-Agent Exporter. @VisibleForTesting - static final String OC_AGENT_EXPORTER_VERSION = "0.31.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + static final String OC_AGENT_EXPORTER_VERSION = "0.31.0"; // CURRENT_OPENCENSUS_VERSION @Nullable private static final io.opencensus.resource.Resource AUTO_DETECTED_RESOURCE =