Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update grpc-http example to autometrics 2.0 #182

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading