Skip to content

Commit 8b761f7

Browse files
authored
update grpc-http example to autometrics 2.0 (#182)
* update grpc-http example to autometrics 2.0 * update name of example to follow pattern of other examples * install protoc
1 parent 1507ece commit 8b761f7

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ jobs:
3535
# Build the crate using the other optional features
3636
- run: cargo build --features=metrics-0_21,custom-objective-percentile,custom-objective-latency
3737

38+
# Install protoc for the examples
39+
- uses: arduino/setup-protoc@v3
40+
3841
# Compile the examples
3942
- run: cargo build --package example-actix-web
4043
- run: cargo build --package example-axum
4144
- run: cargo build --package example-custom-metrics
4245
- run: cargo build --package example-exemplars-tracing
4346
- run: cargo build --package example-exemplars-tracing-opentelemetry
4447
- run: cargo build --package example-full-api
48+
- run: cargo build --package example-grpc-http
4549
- run: cargo build --package example-opentelemetry-push
4650

4751

examples/grpc-http/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "grpc-http"
2+
name = "example-grpc-http"
33
version = "0.0.0"
44
publish = false
55
edition = "2021"

examples/grpc-http/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::net::SocketAddr;
22
use tonic::transport::Server as TonicServer;
33
use warp::Filter;
4+
use warp::http::StatusCode;
45

56
use autometrics::prometheus_exporter;
67
use server::MyJobRunner;
@@ -52,7 +53,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5253
// Build http /metrics endpoint
5354
let routes = warp::get()
5455
.and(warp::path("metrics"))
55-
.map(|| prometheus_exporter::encode_http_response());
56+
.map(|| prometheus_exporter::encode_to_string().map_err(|_| StatusCode::INTERNAL_SERVER_ERROR));
5657

5758
// Build http web server
5859
let (_, web_server) =

0 commit comments

Comments
 (0)