Skip to content

Commit

Permalink
fix: update trace attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Sep 27, 2024
1 parent 7645adf commit 46abc57
Show file tree
Hide file tree
Showing 26 changed files with 8 additions and 49 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ opentelemetry-otlp = { version = "0.25", default-features = false, features = [
"trace",
"http-proto",
] }
opentelemetry-prometheus = { version = "0.16", features = [
opentelemetry-semantic-conventions = { version = "0.25" }
opentelemetry-prometheus = { version = "0.17", features = [
"prometheus-encoding",
] }
opentelemetry-semantic-conventions = { version = "0.15" }
prometheus = "0.13"

# Tracing
Expand Down
2 changes: 0 additions & 2 deletions examples/compression/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;

Expand Down
2 changes: 0 additions & 2 deletions examples/cors/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;
use viz::{get, middleware::cors, serve, Method, Request, Result, Router};
Expand Down
2 changes: 0 additions & 2 deletions examples/csrf/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::{net::SocketAddr, time::Duration};
use tokio::net::TcpListener;

Expand Down
2 changes: 0 additions & 2 deletions examples/databases/sea-orm/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

//! `SeaOrm` example for Viz framework.
use sea_orm_example::{api, db::init_db};
use std::{env, net::SocketAddr, path::PathBuf};
Expand Down
2 changes: 0 additions & 2 deletions examples/forms/form/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
use tokio::net::TcpListener;
Expand Down
2 changes: 0 additions & 2 deletions examples/forms/multipart/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use futures_util::TryStreamExt;
use std::{fs::File, net::SocketAddr};
use tempfile::tempdir;
Expand Down
2 changes: 0 additions & 2 deletions examples/graceful-shutdown/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;
use tokio::signal;
Expand Down
2 changes: 0 additions & 2 deletions examples/hello-world/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::{net::SocketAddr, str::FromStr};
use tokio::net::TcpListener;
use viz::{serve, Request, Result, Router};
Expand Down
2 changes: 0 additions & 2 deletions examples/htmlx/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// #![deny(warnings)]

use handlebars::{DirectorySourceOptions, Handlebars};
use serde::{Deserialize, Serialize};
use serde_json::json;
Expand Down
2 changes: 0 additions & 2 deletions examples/limits/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;
use viz::{
Expand Down
2 changes: 0 additions & 2 deletions examples/otel/metrics/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;

Expand Down
1 change: 0 additions & 1 deletion examples/otel/tracing/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![deny(warnings)]
#![allow(clippy::unused_async)]

use opentelemetry::global;
Expand Down
1 change: 0 additions & 1 deletion examples/routing/openapi/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![deny(warnings)]
#![allow(clippy::unused_async)]
#![allow(clippy::needless_pass_by_value)]

Expand Down
2 changes: 0 additions & 2 deletions examples/routing/todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::{
net::SocketAddr,
sync::{Arc, Mutex, PoisonError},
Expand Down
2 changes: 0 additions & 2 deletions examples/rustls/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::{net::SocketAddr, sync::Arc};
use tokio::net::TcpListener;
use viz::{get, serve, tls, Request, Result, Router};
Expand Down
2 changes: 0 additions & 2 deletions examples/session/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;

Expand Down
2 changes: 0 additions & 2 deletions examples/sse/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use futures_util::StreamExt;
use std::{net::SocketAddr, sync::Arc};
use systemstat::{Platform, System};
Expand Down
2 changes: 0 additions & 2 deletions examples/static-files/embed/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;
use viz::{handlers::embed, serve, Result, Router, StatusCode};
Expand Down
1 change: 0 additions & 1 deletion examples/static-files/include-dir/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![deny(warnings)]
#![allow(clippy::unused_async)]

use http_body_util::Full;
Expand Down
2 changes: 0 additions & 2 deletions examples/static-files/serve/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::{env, net::SocketAddr, path::PathBuf};
use tokio::net::TcpListener;
use viz::{handlers::serve, serve, Request, Response, ResponseExt, Result, Router};
Expand Down
2 changes: 0 additions & 2 deletions examples/static-routes/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use hyper::server::conn::http1;
use hyper::service::service_fn;
use std::{
Expand Down
2 changes: 0 additions & 2 deletions examples/tracing/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use std::net::SocketAddr;
use tokio::net::TcpListener;
use tracing::{debug, error, info, instrument};
Expand Down
1 change: 0 additions & 1 deletion examples/unix-socket/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! ```sh
//! curl --unix-socket /tmp/viz.sock http://localhost/
//! ```
#![deny(warnings)]
#[cfg(unix)]
#[tokio::main]
Expand Down
2 changes: 0 additions & 2 deletions examples/websocket-chat/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

use futures_util::{SinkExt, StreamExt};
use std::net::SocketAddr;
use tokio::net::TcpListener;
Expand Down
9 changes: 6 additions & 3 deletions viz-core/src/middleware/otel/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use opentelemetry::{
Context, KeyValue,
};
use opentelemetry_semantic_conventions::trace::{
CLIENT_ADDRESS, EXCEPTION_MESSAGE, HTTP_REQUEST_BODY_SIZE, HTTP_REQUEST_METHOD,
HTTP_RESPONSE_BODY_SIZE, HTTP_RESPONSE_STATUS_CODE, HTTP_ROUTE, NETWORK_PROTOCOL_VERSION,
SERVER_ADDRESS, SERVER_PORT, URL_PATH, URL_QUERY, URL_SCHEME, USER_AGENT_ORIGINAL,
CLIENT_ADDRESS, EXCEPTION_MESSAGE, HTTP_REQUEST_METHOD, HTTP_RESPONSE_STATUS_CODE, HTTP_ROUTE,
NETWORK_PROTOCOL_VERSION, SERVER_ADDRESS, SERVER_PORT, URL_PATH, URL_QUERY, URL_SCHEME,
USER_AGENT_ORIGINAL,
};

use crate::{
Expand All @@ -23,6 +23,9 @@ use crate::{
Handler, IntoResponse, Request, RequestExt, Response, ResponseExt, Result, Transform,
};

const HTTP_REQUEST_BODY_SIZE: &str = "http.request.body.size";
const HTTP_RESPONSE_BODY_SIZE: &str = "http.response.body.size";

/// `OpenTelemetry` tracing config.
#[derive(Debug)]
pub struct Config<T> {
Expand Down

0 comments on commit 46abc57

Please sign in to comment.