Add ServerOptions to initial server startup logs (#794)

### What

Add ServerOptions to initial server startup logs.

![image](https://github.com/hasura/v3-engine/assets/358550/33e49344-a7d8-44be-8bce-b6c8b11a06ec)

### Update

Use json, as well as a span field rather than an event:

![image](https://github.com/hasura/v3-engine/assets/358550/724bcdf4-8125-4a5e-83aa-db7de1229e3a)

V3_GIT_ORIGIN_REV_ID: 28d0c8edd70357b3460a4fbea389f5fa801fd4bf
This commit is contained in:
Philip Lykke Carlsen 2024-07-05 10:09:26 +02:00 committed by hasura-bot
parent 62e76aac67
commit 9910df8154
2 changed files with 20 additions and 4 deletions

View File

@ -18,11 +18,12 @@ use pre_execution_plugin::{
configuration::PrePluginConfig, execute::pre_execution_plugins_handler,
};
use reqwest::header::CONTENT_TYPE;
use serde::Serialize;
use tower_http::cors::CorsLayer;
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_attribute_on_active_span, set_status_on_current_span,
ErrorVisibility, SpanVisibility, TraceableError, TraceableHttpResponse,
};
use base64::engine::Engine;
@ -52,7 +53,7 @@ const DEFAULT_PORT: u16 = 3000;
const MB: usize = 1_048_576;
#[allow(clippy::struct_excessive_bools)] // booleans are pretty useful here
#[derive(Parser)]
#[derive(Parser, Serialize)]
#[command(version = VERSION)]
struct ServerOptions {
/// The path to the metadata file, used to construct the schema.g
@ -385,6 +386,12 @@ async fn start_engine(server: &ServerOptions) -> Result<(), StartupError> {
println!("{log}");
add_event_on_active_span(log);
set_attribute_on_active_span(
tracing_util::AttributeVisibility::Internal,
"server_options",
serde_json::to_string_pretty(server).unwrap_or_else(|err| err.to_string()),
);
// run it with hyper on `addr`
axum::Server::bind(&address)
.serve(engine_router.into_make_service())

View File

@ -4,7 +4,16 @@
/// If we want to start offering user control of these, they should move out of here and into the
/// flags in Metadata, nothing here should be depended on.
#[derive(
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum, serde::Deserialize,
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
clap::ValueEnum,
serde::Deserialize,
serde::Serialize,
)]
#[serde(rename_all = "snake_case")]
pub enum UnstableFeature {