Skip to content

Commit bf065e9

Browse files
authored
grpc-java-opentelemetry: Add more hints (#30)
1 parent 07ce592 commit bf065e9

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

codelabs/grpc-java-opentelemetry/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ With a successful setup, you will see the following output for the server.
156156
INFO: Server started, listening on 50051
157157
```
158158

159-
While, the server is running, on another terminal start client by running:
159+
While, the server is running, on another terminal start client by running
160160

161161
```java
162162
$ ./build/install/start_here/bin/opentelemetry-client world
163163
```
164164

165-
A successful run will look like \-
165+
A successful run will look like
166166

167167
```
168168
[date and time]io.grpc.codelabs.opentelemetry.OpenTelemetryClient greet
@@ -176,7 +176,7 @@ INFO: Greeting: Hello world
176176
Since we have set-up gRPC OpenTelemetry to export metrics using Prometheus.
177177
Those metrics will be available on localhost:9464 for server and localhost:9465 for client.
178178

179-
To see client metrics:
179+
To see client metrics, run
180180

181181
```shell
182182
curl localhost:9465/metrics
@@ -340,7 +340,7 @@ tar xvfz prometheus-*.tar.gz
340340
cd prometheus-*
341341
```
342342

343-
Create a prometheus configuration file with the following \-
343+
Create a prometheus configuration file with the following
344344

345345
```shell
346346
cat > grpc_otel_java_prometheus.yml <<EOF
@@ -356,7 +356,7 @@ scrape_configs:
356356
EOF
357357
```
358358

359-
Start prometheus with the new configuration -
359+
Start prometheus with the new configuration
360360

361361
```shell
362362
./prometheus --config.file=grpc_otel_java_prometheus.yml

codelabs/grpc-java-opentelemetry/start_here/src/main/java/io/grpc/codelabs/opentelemetry/OpenTelemetryClient.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,27 @@ public void run() {
110110
});
111111

112112
///////////////////////////////////////////////////////////////////////////
113-
// CODELAB HINT : Add code to register GrpcOpenTelemetry here.
113+
// CODELAB HINT : Add code to create Prometheus exporter here. The default
114+
// port has been initialized for you in a variable named prometheusPort.
115+
// Please use that while configuring teh exporter.
114116
///////////////////////////////////////////////////////////////////////////
115117

118+
///////////////////////////////////////////////////////////////////////////
119+
// CODELAB HINT : Add code for the following tasks here:
120+
// 1. After creating PrometheusHttpServer instance, use that
121+
// as a MetricReader to create SdkMeterProvider.
122+
// 2. Use newly created SdkMeterProvider to initialize an OpenTelemetrySdk
123+
// instance.
124+
///////////////////////////////////////////////////////////////////////////
125+
126+
///////////////////////////////////////////////////////////////////////////
127+
// CODELAB HINT : Add code for the following tasks here:
128+
// 1. Add code to create a GrpcOpenTelemetry instance and
129+
// provide the above created OpenTelemetrySdk instance.
130+
// 2. Register GrpcOpenTelemetry instance globally.
131+
///////////////////////////////////////////////////////////////////////////
132+
133+
116134
// Create a communication channel to the server, known as a Channel.
117135
ManagedChannel channel = Grpc.newChannelBuilder(target, InsecureChannelCredentials.create())
118136
.build();

codelabs/grpc-java-opentelemetry/start_here/src/main/java/io/grpc/codelabs/opentelemetry/OpenTelemetryServer.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,24 @@ public static void main(String[] args) throws IOException, InterruptedException
8686
}
8787

8888
///////////////////////////////////////////////////////////////////////////
89-
// CODELAB HINT : Add code to register GrpcOpenTelemetry here.
89+
// CODELAB HINT : Add code to create Prometheus exporter here. The default
90+
// port has been initialized for you in a variable named prometheusPort.
91+
// Please use that while configuring teh exporter.
92+
///////////////////////////////////////////////////////////////////////////
93+
94+
///////////////////////////////////////////////////////////////////////////
95+
// CODELAB HINT : Add code for the following tasks here:
96+
// 1. After creating PrometheusHttpServer instance, use that
97+
// as a MetricReader to create SdkMeterProvider.
98+
// 2. Use newly created SdkMeterProvider to initialize an OpenTelemetrySdk
99+
// instance.
100+
///////////////////////////////////////////////////////////////////////////
101+
102+
///////////////////////////////////////////////////////////////////////////
103+
// CODELAB HINT : Add code for the following tasks here:
104+
// 1. Add code to create a GrpcOpenTelemetry instance and
105+
// provide the above created OpenTelemetrySdk instance.
106+
// 2. Register GrpcOpenTelemetry instance globally.
90107
///////////////////////////////////////////////////////////////////////////
91108

92109
final OpenTelemetryServer server = new OpenTelemetryServer();

0 commit comments

Comments
 (0)