mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-13 11:07:11 +03:00
use git commit sha as version in traces (#287)
V3_GIT_ORIGIN_REV_ID: 9f0ff932d432802ddb9b6688ba7c0b738e2af201
This commit is contained in:
parent
e88ddcdbe4
commit
0c4d0e7341
@ -2,6 +2,7 @@
|
||||
name = "engine"
|
||||
version = "3.0.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@ -20,8 +20,8 @@ use std::path::PathBuf;
|
||||
use std::{fmt::Display, sync::Arc};
|
||||
use tower_http::trace::TraceLayer;
|
||||
use tracing_util::{
|
||||
add_event_on_active_span, set_status_on_current_span, ErrorVisibility, SpanVisibility,
|
||||
TraceableError, TraceableHttpResponse,
|
||||
add_event_on_active_span, set_status_on_current_span, AttributeVisibility, ErrorVisibility,
|
||||
SpanVisibility, TraceableError, TraceableHttpResponse,
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
@ -42,6 +42,11 @@ struct EngineState {
|
||||
auth_config: AuthConfig,
|
||||
}
|
||||
|
||||
const GIT_HASH_VERSION: &str = env!(
|
||||
"GIT_HASH",
|
||||
"Unable to start engine: unable to fetch the current git hash to use as trace version"
|
||||
);
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let server = ServerOptions::parse();
|
||||
@ -159,6 +164,11 @@ async fn graphql_request_tracing_middleware<B: Send>(
|
||||
|
||||
Ok(tracer
|
||||
.in_span_async(path, SpanVisibility::User, || {
|
||||
tracing_util::set_attribute_on_active_span(
|
||||
AttributeVisibility::Internal,
|
||||
"version",
|
||||
GIT_HASH_VERSION,
|
||||
);
|
||||
Box::pin(async move {
|
||||
let response = next.run(request).await;
|
||||
TraceableHttpResponse::new(response, path)
|
||||
|
10
v3/engine/build.rs
Normal file
10
v3/engine/build.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let output = Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.unwrap();
|
||||
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
|
||||
}
|
Loading…
Reference in New Issue
Block a user