Skip to content

Commit

Permalink
update grpc-http example to autometrics 2.0 (#182)
Browse files Browse the repository at this point in the history
* update grpc-http example to autometrics 2.0

* update name of example to follow pattern of other examples

* install protoc
  • Loading branch information
mellowagain authored Sep 9, 2024
1 parent 1507ece commit 8b761f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ jobs:
# Build the crate using the other optional features
- run: cargo build --features=metrics-0_21,custom-objective-percentile,custom-objective-latency

# Install protoc for the examples
- uses: arduino/setup-protoc@v3

# Compile the examples
- run: cargo build --package example-actix-web
- run: cargo build --package example-axum
- run: cargo build --package example-custom-metrics
- run: cargo build --package example-exemplars-tracing
- run: cargo build --package example-exemplars-tracing-opentelemetry
- run: cargo build --package example-full-api
- run: cargo build --package example-grpc-http
- run: cargo build --package example-opentelemetry-push


Expand Down
2 changes: 1 addition & 1 deletion examples/grpc-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "grpc-http"
name = "example-grpc-http"
version = "0.0.0"
publish = false
edition = "2021"
Expand Down
3 changes: 2 additions & 1 deletion examples/grpc-http/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::net::SocketAddr;
use tonic::transport::Server as TonicServer;
use warp::Filter;
use warp::http::StatusCode;

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

// Build http web server
let (_, web_server) =
Expand Down

0 comments on commit 8b761f7

Please sign in to comment.