From c7cd10b742bba17936d6bd91282fd851cb742915 Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Mon, 20 Mar 2023 14:43:52 -0700 Subject: [PATCH 1/8] add examples for gcp-observability --- examples/example-gcp-observability/README.md | 39 ++++++ .../example-gcp-observability/build.gradle | 68 +++++++++++ .../example-gcp-observability/settings.gradle | 1 + .../ObservabilityHelloWorldClient.java | 113 ++++++++++++++++++ .../ObservabilityHelloWorldServer.java | 98 +++++++++++++++ .../main/proto/helloworld/helloworld.proto | 39 ++++++ .../gcp_observability_config.json | 17 +++ 7 files changed, 375 insertions(+) create mode 100644 examples/example-gcp-observability/README.md create mode 100644 examples/example-gcp-observability/build.gradle create mode 100644 examples/example-gcp-observability/settings.gradle create mode 100644 examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java create mode 100644 examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java create mode 100644 examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto create mode 100644 examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json diff --git a/examples/example-gcp-observability/README.md b/examples/example-gcp-observability/README.md new file mode 100644 index 00000000000..1c1916422c7 --- /dev/null +++ b/examples/example-gcp-observability/README.md @@ -0,0 +1,39 @@ +gRPC GCP Observability Example +================ + +The GCP Observability example consists of a Hello World client and a Hello World server instrumented for logs, metrics and tracing. + +__Please refer to GCP observability user guide for setting up authorization to acess Google Cloud Platform with Google user credentials.__ + +### Build the example + +Build the Observability hello-world example client & server. From the `grpc-java/examples/examples-gcp-observability` +directory: +``` +$ ../gradlew installDist +``` + +This creates the scripts `build/install/example-gcp-observability/bin/observability-hello-world-client` and +`build/install/example-gcp-observability/bin/observability-hello-world-server`. + +### Run the example with configuration + +To use Observability, you should first setup and configure authorization and credentials to use gCloud CLI. + +You need to set the `GRPC_GCP_OBSERVABILITY_CONFIG_FILE` environment variable to point to the gRPC GCP Observability configuration file (preferred) or if that +is not set then `GRPC_GCP_OBSERVABILITY_CONFIG` environment variable to gRPC GCP Observability configuration value. This is needed by both +`build/install/example-gcp-observability/bin/observability-hello-world-client` and +`build/install/example-gcp-observability/bin/observability-hello-world-server`. + +1. To start the observability-enabled example server on its default port of 50051, run: +``` +$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json +$ ./build/install/example-gcp-observability/bin/observability-hello-world-server +``` + +2. In a different terminal window, run the observability-enabled example client: +``` +$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json +$ ./build/install/example-gcp-observability/bin/observability-hello-world-client +``` + diff --git a/examples/example-gcp-observability/build.gradle b/examples/example-gcp-observability/build.gradle new file mode 100644 index 00000000000..c8979e22731 --- /dev/null +++ b/examples/example-gcp-observability/build.gradle @@ -0,0 +1,68 @@ +plugins { + // Provide convenience executables for trying out the examples. + id 'application' + // ASSUMES GRADLE 5.6 OR HIGHER. Use plugin version 0.8.10 with earlier gradle versions + id 'com.google.protobuf' version '0.8.17' + // Generate IntelliJ IDEA's .idea & .iml project files + id 'idea' + id 'java' +} + +repositories { + maven { // The google mirror is less flaky than mavenCentral() + url "https://maven-central.storage-download.googleapis.com/maven2/" + } + mavenCentral() + mavenLocal() +} + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you +// are looking at a tagged version of the example and not "master"! + +// Feel free to delete the comment at the next line. It is just for safely +// updating the version in our release process. +def grpcVersion = '1.55.0-SNAPSHOT' // CURRENT_GRPC_VERSION +def protocVersion = '3.21.7' + +dependencies { + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "io.grpc:grpc-gcp-observability:${grpcVersion}" + compileOnly "org.apache.tomcat:annotations-api:6.0.53" + runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}" +} + +protobuf { + protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" } + plugins { + grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" } + } + generateProtoTasks { + all()*.plugins { grpc {} } + } +} + +startScripts.enabled = false + +task ObservabilityHelloWorldServer(type: CreateStartScripts) { + mainClass = 'io.grpc.examples.observabilityHelloWorld.ObservabilityHelloWorldServer' + applicationName = 'observability-hello-world-server' + outputDir = new File(project.buildDir, 'tmp/scripts/' + name) + classpath = startScripts.classpath +} + +task ObservabilityHelloWorldClient(type: CreateStartScripts) { + mainClass = 'io.grpc.examples.observabilityHelloWorld.ObservabilityHelloWorldClient' + applicationName = 'observability-hello-world-client' + outputDir = new File(project.buildDir, 'tmp/scripts/' + name) + classpath = startScripts.classpath +} + +applicationDistribution.into('bin') { + from(ObservabilityHelloWorldServer) + from(ObservabilityHelloWorldClient) + fileMode = 0755 +} \ No newline at end of file diff --git a/examples/example-gcp-observability/settings.gradle b/examples/example-gcp-observability/settings.gradle new file mode 100644 index 00000000000..2df07f93757 --- /dev/null +++ b/examples/example-gcp-observability/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'example-gcp-observability' \ No newline at end of file diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java new file mode 100644 index 00000000000..da8dafea6c1 --- /dev/null +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.examples.observabilityHelloWorld; + +import io.grpc.Channel; +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import io.grpc.ManagedChannel; +import io.grpc.StatusRuntimeException; +import io.grpc.examples.helloworld.GreeterGrpc; +import io.grpc.examples.helloworld.HelloReply; +import io.grpc.examples.helloworld.HelloRequest; +import io.grpc.gcp.observability.GcpObservability; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A simple observability client that requests a greeting from the {@link HelloWorldServer}. + */ +public class ObservabilityHelloWorldClient { + private static final Logger logger = Logger.getLogger(ObservabilityHelloWorldClient.class.getName()); + private static final int EXPORT_INTERVAL = 60; + + private final GreeterGrpc.GreeterBlockingStub blockingStub; + + /** Construct client for accessing HelloWorld server using the existing channel. */ + public ObservabilityHelloWorldClient(Channel channel) { + // 'channel' here is a Channel, not a ManagedChannel, so it is not this code's responsibility to + // shut it down. + + // Passing Channels to code makes code easier to test and makes it easier to reuse Channels. + blockingStub = GreeterGrpc.newBlockingStub(channel); + } + + /** Say hello to server. */ + public void greet(String name) { + logger.info("Will try to greet " + name + " ..."); + HelloRequest request = HelloRequest.newBuilder().setName(name).build(); + HelloReply response; + try { + response = blockingStub.sayHello(request); + } catch (StatusRuntimeException e) { + logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus()); + return; + } + logger.info("Greeting: " + response.getMessage()); + } + + /** + * Greet server. If provided, the first element of {@code args} is the name to use in the + * greeting. The second argument is the target server. + */ + public static void main(String[] args) throws Exception { + String user = "world"; + // Access a service running on the local machine on port 50051 + String target = "localhost:50051"; + // Allow passing in the user and target strings as command line arguments + if (args.length > 0) { + if ("--help".equals(args[0])) { + System.err.println("Usage: [name [target]]"); + System.err.println(""); + System.err.println(" name The name you wish to be greeted by. Defaults to " + user); + System.err.println(" target The server to connect to. Defaults to " + target); + System.exit(1); + } + user = args[0]; + } + if (args.length > 1) { + target = args[1]; + } + + // Initialize observability + try (GcpObservability observability = GcpObservability.grpcInit()) { + // Create a communication channel to the server, known as a Channel. Channels are thread-safe + // and reusable. It is common to create channels at the beginning of your application and reuse + // them until the application shuts down. + // + // For the example we use plaintext insecure credentials to avoid needing TLS certificates. To + // use TLS, use TlsChannelCredentials instead. + ManagedChannel channel = Grpc.newChannelBuilder(target, InsecureChannelCredentials.create()) + .build(); + try { + ObservabilityHelloWorldClient client = new ObservabilityHelloWorldClient(channel); + client.greet(user); + } finally { + // ManagedChannels use resources like threads and TCP connections. To prevent leaking these + // resources the channel should be shut down when it will no longer be used. If it may be used + // again leave it running. + channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + } + System.out.println( + String.format( + "Sleeping %d seconds before shutdown to ensure all records are flushed.", + EXPORT_INTERVAL)); + Thread.sleep(TimeUnit.MILLISECONDS.convert(EXPORT_INTERVAL, TimeUnit.SECONDS)); + } // observability.close() called implicitly + } +} diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java new file mode 100644 index 00000000000..170fbb48a56 --- /dev/null +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java @@ -0,0 +1,98 @@ +/* + * Copyright 2023 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.examples.observabilityHelloWorld; + +import io.grpc.Grpc; +import io.grpc.InsecureServerCredentials; +import io.grpc.Server; +import io.grpc.examples.helloworld.GreeterGrpc; +import io.grpc.examples.helloworld.HelloReply; +import io.grpc.examples.helloworld.HelloRequest; +import io.grpc.gcp.observability.GcpObservability; +import io.grpc.stub.StreamObserver; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +/** + * Observability server that manages startup/shutdown of a {@code Greeter} server. + */ +public class ObservabilityHelloWorldServer { + private static final Logger logger = Logger.getLogger(ObservabilityHelloWorldServer.class.getName()); + + private Server server; + + private void start() throws IOException { + /* The port on which the server should run */ + int port = 50051; + server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create()) + .addService(new GreeterImpl()) + .build() + .start(); + logger.info("Server started, listening on " + port); + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + // Use stderr here since the logger may have been reset by its JVM shutdown hook. + System.err.println("*** shutting down gRPC server since JVM is shutting down"); + try { + ObservabilityHelloWorldServer.this.stop(); + } catch (InterruptedException e) { + e.printStackTrace(System.err); + } + System.err.println("*** server shut down"); + } + }); + } + + private void stop() throws InterruptedException { + if (server != null) { + server.shutdown().awaitTermination(30, TimeUnit.SECONDS); + } + } + + /** + * Await termination on the main thread since the grpc library uses daemon threads. + */ + private void blockUntilShutdown() throws InterruptedException { + if (server != null) { + server.awaitTermination(); + } + } + + /** + * Main launches the server from the command line. + */ + public static void main(String[] args) throws IOException, InterruptedException { + // Initialize observability + try (GcpObservability observability = GcpObservability.grpcInit()) { + final ObservabilityHelloWorldServer server = new ObservabilityHelloWorldServer(); + server.start(); + server.blockUntilShutdown(); + } // observability.close() called implicitly + } + + static class GreeterImpl extends GreeterGrpc.GreeterImplBase { + + @Override + public void sayHello(HelloRequest req, StreamObserver responseObserver) { + HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + req.getName()).build(); + responseObserver.onNext(reply); + responseObserver.onCompleted(); + } + } +} diff --git a/examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto b/examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto new file mode 100644 index 00000000000..d1a762b1709 --- /dev/null +++ b/examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto @@ -0,0 +1,39 @@ +/* + * Copyright 2023 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "io.grpc.examples.helloworld"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings +message HelloReply { + string message = 1; +} \ No newline at end of file diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json new file mode 100644 index 00000000000..6c42beb4c41 --- /dev/null +++ b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json @@ -0,0 +1,17 @@ +{ + "cloud_monitoring": {}, + "cloud_trace": { + "sampling_rate": 1.00 + }, + "cloud_logging": { + "client_rpc_events": [{ + "methods": ["helloworld.Greeter/*"] + }], + "server_rpc_events": [{ + "methods": ["helloworld.Greeter/*"] + }] + }, + "labels": { + "environment" : "observability-example" + } +} \ No newline at end of file From 11d4ada4e1148e1cab7f50faa40e1c156a5f4f77 Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Mon, 20 Mar 2023 14:50:39 -0700 Subject: [PATCH 2/8] updated comments --- .../observabilityHelloWorld/ObservabilityHelloWorldClient.java | 3 ++- .../observabilityHelloWorld/ObservabilityHelloWorldServer.java | 3 ++- .../src/main/proto/helloworld/helloworld.proto | 2 +- .../observabilityHelloWorld/gcp_observability_config.json | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java index da8dafea6c1..19610241d27 100644 --- a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java @@ -30,7 +30,8 @@ import java.util.logging.Logger; /** - * A simple observability client that requests a greeting from the {@link HelloWorldServer}. + * A simple observability client that requests a greeting from the {@link HelloWorldServer} and + * generates logs, metrics and traces based on the configuration. */ public class ObservabilityHelloWorldClient { private static final Logger logger = Logger.getLogger(ObservabilityHelloWorldClient.class.getName()); diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java index 170fbb48a56..a4dacc7846e 100644 --- a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java @@ -29,7 +29,8 @@ import java.util.logging.Logger; /** - * Observability server that manages startup/shutdown of a {@code Greeter} server. + * Observability server that manages startup/shutdown of a {@code Greeter} server and generates + * logs, metrics and traces based on the configuration. */ public class ObservabilityHelloWorldServer { private static final Logger logger = Logger.getLogger(ObservabilityHelloWorldServer.class.getName()); diff --git a/examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto b/examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto index d1a762b1709..64a8c09ee16 100644 --- a/examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto +++ b/examples/example-gcp-observability/src/main/proto/helloworld/helloworld.proto @@ -36,4 +36,4 @@ message HelloRequest { // The response message containing the greetings message HelloReply { string message = 1; -} \ No newline at end of file +} diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json index 6c42beb4c41..fb50f1070eb 100644 --- a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json +++ b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json @@ -14,4 +14,4 @@ "labels": { "environment" : "observability-example" } -} \ No newline at end of file +} From 502e58219ad654734756eac3f11e9be7ea9dc010 Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Mon, 20 Mar 2023 14:53:28 -0700 Subject: [PATCH 3/8] added newline at EOF --- examples/example-gcp-observability/build.gradle | 2 +- examples/example-gcp-observability/settings.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/example-gcp-observability/build.gradle b/examples/example-gcp-observability/build.gradle index c8979e22731..1677aa843f0 100644 --- a/examples/example-gcp-observability/build.gradle +++ b/examples/example-gcp-observability/build.gradle @@ -65,4 +65,4 @@ applicationDistribution.into('bin') { from(ObservabilityHelloWorldServer) from(ObservabilityHelloWorldClient) fileMode = 0755 -} \ No newline at end of file +} diff --git a/examples/example-gcp-observability/settings.gradle b/examples/example-gcp-observability/settings.gradle index 2df07f93757..1e4ba3812eb 100644 --- a/examples/example-gcp-observability/settings.gradle +++ b/examples/example-gcp-observability/settings.gradle @@ -1 +1 @@ -rootProject.name = 'example-gcp-observability' \ No newline at end of file +rootProject.name = 'example-gcp-observability' From 0df5bb84eaa37600b8f72de21859fdd3da4368fc Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Tue, 21 Mar 2023 00:22:42 -0700 Subject: [PATCH 4/8] Updated package name and class names; added separate configurations for client and server --- examples/example-gcp-observability/README.md | 22 ++++++------- .../example-gcp-observability/build.gradle | 8 ++--- .../gcpObservabilityClient.java} | 31 +++---------------- .../gcpObservabilityServer.java} | 15 +++------ .../gcp_observability_client_config.json} | 2 +- .../gcp_observability_server_config.json | 17 ++++++++++ 6 files changed, 43 insertions(+), 52 deletions(-) rename examples/example-gcp-observability/src/main/java/io/grpc/examples/{observabilityHelloWorld/ObservabilityHelloWorldClient.java => gcpObservability/gcpObservabilityClient.java} (64%) rename examples/example-gcp-observability/src/main/java/io/grpc/examples/{observabilityHelloWorld/ObservabilityHelloWorldServer.java => gcpObservability/gcpObservabilityServer.java} (83%) rename examples/example-gcp-observability/src/main/resources/io/grpc/examples/{observabilityHelloWorld/gcp_observability_config.json => gcpObservability/gcp_observability_client_config.json} (86%) create mode 100644 examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json diff --git a/examples/example-gcp-observability/README.md b/examples/example-gcp-observability/README.md index 1c1916422c7..43cf6cfb9dc 100644 --- a/examples/example-gcp-observability/README.md +++ b/examples/example-gcp-observability/README.md @@ -3,37 +3,37 @@ gRPC GCP Observability Example The GCP Observability example consists of a Hello World client and a Hello World server instrumented for logs, metrics and tracing. -__Please refer to GCP observability user guide for setting up authorization to acess Google Cloud Platform with Google user credentials.__ +__Please refer to GCP Observability [user guide](https://cloud.google.com/stackdriver/docs/solutions/grpc/set-up-observability) for setup.__ ### Build the example -Build the Observability hello-world example client & server. From the `grpc-java/examples/examples-gcp-observability` +Build the Observability client & server. From the grpc-java/examples/example-gcp-observability directory: ``` $ ../gradlew installDist ``` -This creates the scripts `build/install/example-gcp-observability/bin/observability-hello-world-client` and -`build/install/example-gcp-observability/bin/observability-hello-world-server`. +This creates the scripts `build/install/example-gcp-observability/bin/gcp-observability-client` and +`build/install/example-gcp-observability/bin/gcp-observability-server`. ### Run the example with configuration -To use Observability, you should first setup and configure authorization and credentials to use gCloud CLI. +To use Observability, you should first setup and configure authorization as mentioned in the user guide. You need to set the `GRPC_GCP_OBSERVABILITY_CONFIG_FILE` environment variable to point to the gRPC GCP Observability configuration file (preferred) or if that is not set then `GRPC_GCP_OBSERVABILITY_CONFIG` environment variable to gRPC GCP Observability configuration value. This is needed by both -`build/install/example-gcp-observability/bin/observability-hello-world-client` and -`build/install/example-gcp-observability/bin/observability-hello-world-server`. +`build/install/example-gcp-observability/bin/gcp-observability-client` and +`build/install/example-gcp-observability/bin/gcp-observability-server`. 1. To start the observability-enabled example server on its default port of 50051, run: ``` -$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json -$ ./build/install/example-gcp-observability/bin/observability-hello-world-server +$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json +$ ./build/install/example-gcp-observability/bin/gcp-observability-server ``` 2. In a different terminal window, run the observability-enabled example client: ``` -$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json -$ ./build/install/example-gcp-observability/bin/observability-hello-world-client +$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_client_config.json +$ ./build/install/example-gcp-observability/bin/gcp-observability-client ``` diff --git a/examples/example-gcp-observability/build.gradle b/examples/example-gcp-observability/build.gradle index 1677aa843f0..91a45a2a39c 100644 --- a/examples/example-gcp-observability/build.gradle +++ b/examples/example-gcp-observability/build.gradle @@ -48,15 +48,15 @@ protobuf { startScripts.enabled = false task ObservabilityHelloWorldServer(type: CreateStartScripts) { - mainClass = 'io.grpc.examples.observabilityHelloWorld.ObservabilityHelloWorldServer' - applicationName = 'observability-hello-world-server' + mainClass = 'io.grpc.examples.gcpObservability.gcpObservabilityServer' + applicationName = 'gcp-observability-server' outputDir = new File(project.buildDir, 'tmp/scripts/' + name) classpath = startScripts.classpath } task ObservabilityHelloWorldClient(type: CreateStartScripts) { - mainClass = 'io.grpc.examples.observabilityHelloWorld.ObservabilityHelloWorldClient' - applicationName = 'observability-hello-world-client' + mainClass = 'io.grpc.examples.gcpObservability.gcpObservabilityClient' + applicationName = 'gcp-observability-client' outputDir = new File(project.buildDir, 'tmp/scripts/' + name) classpath = startScripts.classpath } diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityClient.java similarity index 64% rename from examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java rename to examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityClient.java index 19610241d27..7be39301f5f 100644 --- a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldClient.java +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.grpc.examples.observabilityHelloWorld; +package io.grpc.examples.gcpObservability; import io.grpc.Channel; import io.grpc.Grpc; @@ -33,18 +33,13 @@ * A simple observability client that requests a greeting from the {@link HelloWorldServer} and * generates logs, metrics and traces based on the configuration. */ -public class ObservabilityHelloWorldClient { - private static final Logger logger = Logger.getLogger(ObservabilityHelloWorldClient.class.getName()); - private static final int EXPORT_INTERVAL = 60; +public class gcpObservabilityClient { + private static final Logger logger = Logger.getLogger(gcpObservabilityClient.class.getName()); private final GreeterGrpc.GreeterBlockingStub blockingStub; /** Construct client for accessing HelloWorld server using the existing channel. */ - public ObservabilityHelloWorldClient(Channel channel) { - // 'channel' here is a Channel, not a ManagedChannel, so it is not this code's responsibility to - // shut it down. - - // Passing Channels to code makes code easier to test and makes it easier to reuse Channels. + public gcpObservabilityClient(Channel channel) { blockingStub = GreeterGrpc.newBlockingStub(channel); } @@ -68,9 +63,7 @@ public void greet(String name) { */ public static void main(String[] args) throws Exception { String user = "world"; - // Access a service running on the local machine on port 50051 String target = "localhost:50051"; - // Allow passing in the user and target strings as command line arguments if (args.length > 0) { if ("--help".equals(args[0])) { System.err.println("Usage: [name [target]]"); @@ -87,28 +80,14 @@ public static void main(String[] args) throws Exception { // Initialize observability try (GcpObservability observability = GcpObservability.grpcInit()) { - // Create a communication channel to the server, known as a Channel. Channels are thread-safe - // and reusable. It is common to create channels at the beginning of your application and reuse - // them until the application shuts down. - // - // For the example we use plaintext insecure credentials to avoid needing TLS certificates. To - // use TLS, use TlsChannelCredentials instead. ManagedChannel channel = Grpc.newChannelBuilder(target, InsecureChannelCredentials.create()) .build(); try { - ObservabilityHelloWorldClient client = new ObservabilityHelloWorldClient(channel); + gcpObservabilityClient client = new gcpObservabilityClient(channel); client.greet(user); } finally { - // ManagedChannels use resources like threads and TCP connections. To prevent leaking these - // resources the channel should be shut down when it will no longer be used. If it may be used - // again leave it running. channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); } - System.out.println( - String.format( - "Sleeping %d seconds before shutdown to ensure all records are flushed.", - EXPORT_INTERVAL)); - Thread.sleep(TimeUnit.MILLISECONDS.convert(EXPORT_INTERVAL, TimeUnit.SECONDS)); } // observability.close() called implicitly } } diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java similarity index 83% rename from examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java rename to examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java index a4dacc7846e..ffe97ec580a 100644 --- a/examples/example-gcp-observability/src/main/java/io/grpc/examples/observabilityHelloWorld/ObservabilityHelloWorldServer.java +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.grpc.examples.observabilityHelloWorld; +package io.grpc.examples.gcpObservability; import io.grpc.Grpc; import io.grpc.InsecureServerCredentials; @@ -32,13 +32,12 @@ * Observability server that manages startup/shutdown of a {@code Greeter} server and generates * logs, metrics and traces based on the configuration. */ -public class ObservabilityHelloWorldServer { - private static final Logger logger = Logger.getLogger(ObservabilityHelloWorldServer.class.getName()); +public class gcpObservabilityServer { + private static final Logger logger = Logger.getLogger(gcpObservabilityServer.class.getName()); private Server server; private void start() throws IOException { - /* The port on which the server should run */ int port = 50051; server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create()) .addService(new GreeterImpl()) @@ -48,10 +47,9 @@ private void start() throws IOException { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { - // Use stderr here since the logger may have been reset by its JVM shutdown hook. System.err.println("*** shutting down gRPC server since JVM is shutting down"); try { - ObservabilityHelloWorldServer.this.stop(); + gcpObservabilityServer.this.stop(); } catch (InterruptedException e) { e.printStackTrace(System.err); } @@ -66,9 +64,6 @@ private void stop() throws InterruptedException { } } - /** - * Await termination on the main thread since the grpc library uses daemon threads. - */ private void blockUntilShutdown() throws InterruptedException { if (server != null) { server.awaitTermination(); @@ -81,7 +76,7 @@ private void blockUntilShutdown() throws InterruptedException { public static void main(String[] args) throws IOException, InterruptedException { // Initialize observability try (GcpObservability observability = GcpObservability.grpcInit()) { - final ObservabilityHelloWorldServer server = new ObservabilityHelloWorldServer(); + final gcpObservabilityServer server = new gcpObservabilityServer(); server.start(); server.blockUntilShutdown(); } // observability.close() called implicitly diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_client_config.json similarity index 86% rename from examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json rename to examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_client_config.json index fb50f1070eb..cf17faa32c6 100644 --- a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/observabilityHelloWorld/gcp_observability_config.json +++ b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_client_config.json @@ -12,6 +12,6 @@ }] }, "labels": { - "environment" : "observability-example" + "environment" : "example-client" } } diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json new file mode 100644 index 00000000000..6f8a67d3fe4 --- /dev/null +++ b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json @@ -0,0 +1,17 @@ +{ + "cloud_monitoring": {}, + "cloud_trace": { + "sampling_rate": 1.00 + }, + "cloud_logging": { + "client_rpc_events": [{ + "methods": ["helloworld.Greeter/*"] + }], + "server_rpc_events": [{ + "methods": ["helloworld.Greeter/*"] + }] + }, + "labels": { + "environment" : "example-server" + } +} From 04a70f75108ab8eb98dac036ff13440edf4aff1a Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Tue, 21 Mar 2023 16:28:23 -0700 Subject: [PATCH 5/8] added observability.close() to be invoked as part of server shutdown --- .../gcpObservabilityServer.java | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java index ffe97ec580a..8d32d713e05 100644 --- a/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java @@ -44,18 +44,6 @@ private void start() throws IOException { .build() .start(); logger.info("Server started, listening on " + port); - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - System.err.println("*** shutting down gRPC server since JVM is shutting down"); - try { - gcpObservabilityServer.this.stop(); - } catch (InterruptedException e) { - e.printStackTrace(System.err); - } - System.err.println("*** server shut down"); - } - }); } private void stop() throws InterruptedException { @@ -74,12 +62,31 @@ private void blockUntilShutdown() throws InterruptedException { * Main launches the server from the command line. */ public static void main(String[] args) throws IOException, InterruptedException { - // Initialize observability - try (GcpObservability observability = GcpObservability.grpcInit()) { + try { + // Initialize observability + GcpObservability observability = GcpObservability.grpcInit(); final gcpObservabilityServer server = new gcpObservabilityServer(); server.start(); + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + System.err.println("*** shutting down gRPC server since JVM is shutting down"); + try { + server.stop(); + // Shut down observability + observability.close(); + } catch (InterruptedException e) { + e.printStackTrace(System.err); + } + System.err.println("*** server shut down"); + } + }); + server.blockUntilShutdown(); - } // observability.close() called implicitly + } finally { + logger.info("Server shut down"); + } } static class GreeterImpl extends GreeterGrpc.GreeterImplBase { From 623273aa7414223a9d4355ce639770ed37c01a82 Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Tue, 21 Mar 2023 18:33:30 -0700 Subject: [PATCH 6/8] updated package and class names --- examples/example-gcp-observability/README.md | 6 +-- .../example-gcp-observability/build.gradle | 4 +- .../GcpObservabilityClient.java} | 10 ++-- .../GcpObservabilityServer.java} | 46 +++++++++---------- .../gcp_observability_client_config.json | 0 .../gcp_observability_server_config.json | 0 6 files changed, 31 insertions(+), 35 deletions(-) rename examples/example-gcp-observability/src/main/java/io/grpc/examples/{gcpObservability/gcpObservabilityClient.java => gcpobservability/GcpObservabilityClient.java} (92%) rename examples/example-gcp-observability/src/main/java/io/grpc/examples/{gcpObservability/gcpObservabilityServer.java => gcpobservability/GcpObservabilityServer.java} (71%) rename examples/example-gcp-observability/src/main/resources/io/grpc/examples/{gcpObservability => gcpobservability}/gcp_observability_client_config.json (100%) rename examples/example-gcp-observability/src/main/resources/io/grpc/examples/{gcpObservability => gcpobservability}/gcp_observability_server_config.json (100%) diff --git a/examples/example-gcp-observability/README.md b/examples/example-gcp-observability/README.md index 43cf6cfb9dc..56f62e7d687 100644 --- a/examples/example-gcp-observability/README.md +++ b/examples/example-gcp-observability/README.md @@ -7,7 +7,7 @@ __Please refer to GCP Observability [user guide](https://cloud.google.com/stackd ### Build the example -Build the Observability client & server. From the grpc-java/examples/example-gcp-observability +Build the Observability client & server. From the `grpc-java/examples/example-gcp-observability` directory: ``` $ ../gradlew installDist @@ -27,13 +27,13 @@ is not set then `GRPC_GCP_OBSERVABILITY_CONFIG` environment variable to gRPC GCP 1. To start the observability-enabled example server on its default port of 50051, run: ``` -$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json +$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json $ ./build/install/example-gcp-observability/bin/gcp-observability-server ``` 2. In a different terminal window, run the observability-enabled example client: ``` -$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_client_config.json +$ export GRPC_GCP_OBSERVABILITY_CONFIG_FILE=src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json $ ./build/install/example-gcp-observability/bin/gcp-observability-client ``` diff --git a/examples/example-gcp-observability/build.gradle b/examples/example-gcp-observability/build.gradle index 91a45a2a39c..5d8571aefef 100644 --- a/examples/example-gcp-observability/build.gradle +++ b/examples/example-gcp-observability/build.gradle @@ -48,14 +48,14 @@ protobuf { startScripts.enabled = false task ObservabilityHelloWorldServer(type: CreateStartScripts) { - mainClass = 'io.grpc.examples.gcpObservability.gcpObservabilityServer' + mainClass = 'io.grpc.examples.gcpobservability.GcpObservabilityServer' applicationName = 'gcp-observability-server' outputDir = new File(project.buildDir, 'tmp/scripts/' + name) classpath = startScripts.classpath } task ObservabilityHelloWorldClient(type: CreateStartScripts) { - mainClass = 'io.grpc.examples.gcpObservability.gcpObservabilityClient' + mainClass = 'io.grpc.examples.gcpobservability.GcpObservabilityClient' applicationName = 'gcp-observability-client' outputDir = new File(project.buildDir, 'tmp/scripts/' + name) classpath = startScripts.classpath diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityClient.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpobservability/GcpObservabilityClient.java similarity index 92% rename from examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityClient.java rename to examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpobservability/GcpObservabilityClient.java index 7be39301f5f..34112adb108 100644 --- a/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityClient.java +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpobservability/GcpObservabilityClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.grpc.examples.gcpObservability; +package io.grpc.examples.gcpobservability; import io.grpc.Channel; import io.grpc.Grpc; @@ -33,13 +33,13 @@ * A simple observability client that requests a greeting from the {@link HelloWorldServer} and * generates logs, metrics and traces based on the configuration. */ -public class gcpObservabilityClient { - private static final Logger logger = Logger.getLogger(gcpObservabilityClient.class.getName()); +public class GcpObservabilityClient { + private static final Logger logger = Logger.getLogger(GcpObservabilityClient.class.getName()); private final GreeterGrpc.GreeterBlockingStub blockingStub; /** Construct client for accessing HelloWorld server using the existing channel. */ - public gcpObservabilityClient(Channel channel) { + public GcpObservabilityClient(Channel channel) { blockingStub = GreeterGrpc.newBlockingStub(channel); } @@ -83,7 +83,7 @@ public static void main(String[] args) throws Exception { ManagedChannel channel = Grpc.newChannelBuilder(target, InsecureChannelCredentials.create()) .build(); try { - gcpObservabilityClient client = new gcpObservabilityClient(channel); + GcpObservabilityClient client = new GcpObservabilityClient(channel); client.greet(user); } finally { channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); diff --git a/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpobservability/GcpObservabilityServer.java similarity index 71% rename from examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java rename to examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpobservability/GcpObservabilityServer.java index 8d32d713e05..c599e7047c5 100644 --- a/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpObservability/gcpObservabilityServer.java +++ b/examples/example-gcp-observability/src/main/java/io/grpc/examples/gcpobservability/GcpObservabilityServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.grpc.examples.gcpObservability; +package io.grpc.examples.gcpobservability; import io.grpc.Grpc; import io.grpc.InsecureServerCredentials; @@ -32,8 +32,8 @@ * Observability server that manages startup/shutdown of a {@code Greeter} server and generates * logs, metrics and traces based on the configuration. */ -public class gcpObservabilityServer { - private static final Logger logger = Logger.getLogger(gcpObservabilityServer.class.getName()); +public class GcpObservabilityServer { + private static final Logger logger = Logger.getLogger(GcpObservabilityServer.class.getName()); private Server server; @@ -62,31 +62,27 @@ private void blockUntilShutdown() throws InterruptedException { * Main launches the server from the command line. */ public static void main(String[] args) throws IOException, InterruptedException { - try { - // Initialize observability - GcpObservability observability = GcpObservability.grpcInit(); - final gcpObservabilityServer server = new gcpObservabilityServer(); - server.start(); + // Initialize observability + GcpObservability observability = GcpObservability.grpcInit(); + final GcpObservabilityServer server = new GcpObservabilityServer(); + server.start(); - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - System.err.println("*** shutting down gRPC server since JVM is shutting down"); - try { - server.stop(); - // Shut down observability - observability.close(); - } catch (InterruptedException e) { - e.printStackTrace(System.err); - } - System.err.println("*** server shut down"); + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + System.err.println("*** shutting down gRPC server since JVM is shutting down"); + try { + server.stop(); + } catch (InterruptedException e) { + e.printStackTrace(System.err); } - }); + // Shut down observability + observability.close(); + System.err.println("*** server shut down"); + } + }); - server.blockUntilShutdown(); - } finally { - logger.info("Server shut down"); - } + server.blockUntilShutdown(); } static class GreeterImpl extends GreeterGrpc.GreeterImplBase { diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_client_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json similarity index 100% rename from examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_client_config.json rename to examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json similarity index 100% rename from examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpObservability/gcp_observability_server_config.json rename to examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json From bce8a0aff91cd2c83ad27684ec5eeaf26a7328dd Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Wed, 22 Mar 2023 14:56:46 -0700 Subject: [PATCH 7/8] remove user-guide link, as the current link does not have setup instructions --- examples/example-gcp-observability/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example-gcp-observability/README.md b/examples/example-gcp-observability/README.md index 56f62e7d687..3cf03f69e83 100644 --- a/examples/example-gcp-observability/README.md +++ b/examples/example-gcp-observability/README.md @@ -3,7 +3,7 @@ gRPC GCP Observability Example The GCP Observability example consists of a Hello World client and a Hello World server instrumented for logs, metrics and tracing. -__Please refer to GCP Observability [user guide](https://cloud.google.com/stackdriver/docs/solutions/grpc/set-up-observability) for setup.__ +__Please refer to GCP Observability user guide for setup.__ ### Build the example From 48dbdc077109c814400e13c7169ada783eca6855 Mon Sep 17 00:00:00 2001 From: Vindhya Ningegowda Date: Wed, 22 Mar 2023 16:28:57 -0700 Subject: [PATCH 8/8] update gRPC GCP observability product name to Microservices Observability --- examples/example-gcp-observability/README.md | 2 +- .../gcpobservability/gcp_observability_client_config.json | 2 +- .../gcpobservability/gcp_observability_server_config.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/example-gcp-observability/README.md b/examples/example-gcp-observability/README.md index 3cf03f69e83..95270fa8140 100644 --- a/examples/example-gcp-observability/README.md +++ b/examples/example-gcp-observability/README.md @@ -3,7 +3,7 @@ gRPC GCP Observability Example The GCP Observability example consists of a Hello World client and a Hello World server instrumented for logs, metrics and tracing. -__Please refer to GCP Observability user guide for setup.__ +__Please refer to Microservices Observability user guide for setup.__ ### Build the example diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json index cf17faa32c6..9c69d55e7f7 100644 --- a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json +++ b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_client_config.json @@ -1,7 +1,7 @@ { "cloud_monitoring": {}, "cloud_trace": { - "sampling_rate": 1.00 + "sampling_rate": 1.0 }, "cloud_logging": { "client_rpc_events": [{ diff --git a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json index 6f8a67d3fe4..78698c05faf 100644 --- a/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json +++ b/examples/example-gcp-observability/src/main/resources/io/grpc/examples/gcpobservability/gcp_observability_server_config.json @@ -1,7 +1,7 @@ { "cloud_monitoring": {}, "cloud_trace": { - "sampling_rate": 1.00 + "sampling_rate": 1.0 }, "cloud_logging": { "client_rpc_events": [{