Skip to content

Commit

Permalink
Logging config
Browse files Browse the repository at this point in the history
  • Loading branch information
bryn committed Nov 8, 2023
1 parent 7f55f46 commit 00b5864
Show file tree
Hide file tree
Showing 9 changed files with 586 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2414,40 +2414,6 @@ expression: "&schema"
"description": "Logging configuration",
"type": "object",
"properties": {
"display_filename": {
"description": "Display the filename in the logs",
"default": false,
"type": "boolean"
},
"display_line_number": {
"description": "Display the line number in the logs",
"default": false,
"type": "boolean"
},
"display_target": {
"description": "Display the target in the logs",
"default": false,
"type": "boolean"
},
"format": {
"description": "Log format",
"oneOf": [
{
"description": "Pretty text format (default if you're running from a tty)",
"type": "string",
"enum": [
"pretty"
]
},
{
"description": "Json log format",
"type": "string",
"enum": [
"json"
]
}
]
},
"when_header": {
"description": "Log configuration to log request and response for subgraphs and supergraph",
"type": "array",
Expand Down Expand Up @@ -2517,6 +2483,238 @@ expression: "&schema"
},
"additionalProperties": false
},
"logging": {
"description": "Logging configuration.",
"type": "object",
"properties": {
"common": {
"description": "Common configuration",
"type": "object",
"properties": {
"resource": {
"description": "The Open Telemetry resource",
"default": {},
"type": "object",
"additionalProperties": {
"anyOf": [
{
"description": "bool values",
"type": "boolean"
},
{
"description": "i64 values",
"type": "integer",
"format": "int64"
},
{
"description": "f64 values",
"type": "number",
"format": "double"
},
{
"description": "String values",
"type": "string"
},
{
"description": "Array of homogeneous values",
"anyOf": [
{
"description": "Array of bools",
"type": "array",
"items": {
"type": "boolean"
}
},
{
"description": "Array of integers",
"type": "array",
"items": {
"type": "integer",
"format": "int64"
}
},
{
"description": "Array of floats",
"type": "array",
"items": {
"type": "number",
"format": "double"
}
},
{
"description": "Array of strings",
"type": "array",
"items": {
"type": "string"
}
}
]
}
]
}
},
"service_name": {
"description": "Set a service.name resource in your metrics",
"default": null,
"type": "string",
"nullable": true
},
"service_namespace": {
"description": "Set a service.namespace attribute in your metrics",
"default": null,
"type": "string",
"nullable": true
}
},
"additionalProperties": false
},
"stdout": {
"description": "Settings for logging to stdout.",
"type": "object",
"properties": {
"enabled": {
"description": "Set to true to log to stdout.",
"default": true,
"type": "boolean"
},
"format": {
"description": "The format to log to stdout.",
"oneOf": [
{
"description": "https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/format/struct.Json.html",
"type": "object",
"required": [
"json"
],
"properties": {
"json": {
"type": "object",
"properties": {
"display_current_span": {
"description": "Include the current span in this log event.",
"default": false,
"type": "boolean"
},
"display_filename": {
"description": "Include the filename with the log event.",
"default": false,
"type": "boolean"
},
"display_level": {
"description": "Include the level with the log event.",
"default": true,
"type": "boolean"
},
"display_line_number": {
"description": "Include the line number with the log event.",
"default": false,
"type": "boolean"
},
"display_span_list": {
"description": "Include all of the containing span information with the log event.",
"default": true,
"type": "boolean"
},
"display_target": {
"description": "Include the target with the log event.",
"default": true,
"type": "boolean"
},
"display_thread_id": {
"description": "Include the thread_id with the log event.",
"default": false,
"type": "boolean"
},
"display_thread_name": {
"description": "Include the thread_name with the log event.",
"default": false,
"type": "boolean"
},
"display_timestamp": {
"description": "Include the timestamp with the log event.",
"default": true,
"type": "boolean"
},
"flatten_event": {
"description": "Move all span attributes to the top level json object.",
"default": false,
"type": "boolean"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/format/struct.Full.html",
"type": "object",
"required": [
"text"
],
"properties": {
"text": {
"type": "object",
"properties": {
"ansi": {
"description": "Use ansi escape codes.",
"default": false,
"type": "boolean"
},
"display_filename": {
"description": "Include the filename with the log event.",
"default": false,
"type": "boolean"
},
"display_level": {
"description": "Include the level with the log event.",
"default": true,
"type": "boolean"
},
"display_line_number": {
"description": "Include the line number with the log event.",
"default": false,
"type": "boolean"
},
"display_location": {
"description": "Include the location with the log event.",
"default": false,
"type": "boolean"
},
"display_target": {
"description": "Include the target with the log event.",
"default": false,
"type": "boolean"
},
"display_thread_id": {
"description": "Include the thread_id with the log event.",
"default": false,
"type": "boolean"
},
"display_thread_name": {
"description": "Include the thread_name with the log event.",
"default": false,
"type": "boolean"
},
"display_timestamp": {
"description": "Include the timestamp with the log event.",
"default": true,
"type": "boolean"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"metrics": {
"description": "Metrics configuration",
"type": "object",
Expand Down
33 changes: 0 additions & 33 deletions apollo-router/src/plugins/telemetry/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub(crate) struct Conf {
#[serde(rename = "experimental_logging", default)]
pub(crate) logging: Logging,

#[cfg(feature = "telemetry_next")]
#[serde(rename = "logging", default)]
#[allow(dead_code)]
pub(crate) new_logging: config_new::logging::Logging,
Expand Down Expand Up @@ -167,14 +166,6 @@ pub(crate) struct Tracing {
#[derive(Clone, Debug, Deserialize, JsonSchema, Default)]
#[serde(deny_unknown_fields, default)]
pub(crate) struct Logging {
/// Log format
pub(crate) format: LoggingFormat,
/// Display the target in the logs
pub(crate) display_target: bool,
/// Display the filename in the logs
pub(crate) display_filename: bool,
/// Display the line number in the logs
pub(crate) display_line_number: bool,
/// Log configuration to log request and response for subgraphs and supergraph
pub(crate) when_header: Vec<HeaderLoggingCondition>,
}
Expand Down Expand Up @@ -711,10 +702,6 @@ mod tests {
#[test]
fn test_logging_conf_validation() {
let logging_conf = Logging {
format: LoggingFormat::default(),
display_target: false,
display_filename: false,
display_line_number: false,
when_header: vec![HeaderLoggingCondition::Value {
name: "test".to_string(),
value: String::new(),
Expand All @@ -726,10 +713,6 @@ mod tests {
logging_conf.validate().unwrap();

let logging_conf = Logging {
format: LoggingFormat::default(),
display_target: false,
display_filename: false,
display_line_number: false,
when_header: vec![HeaderLoggingCondition::Value {
name: "test".to_string(),
value: String::new(),
Expand All @@ -746,10 +729,6 @@ mod tests {
#[test]
fn test_logging_conf_should_log() {
let logging_conf = Logging {
format: LoggingFormat::default(),
display_target: false,
display_filename: false,
display_line_number: false,
when_header: vec![HeaderLoggingCondition::Matching {
name: "test".to_string(),
matching: Regex::new("^foo*").unwrap(),
Expand All @@ -764,10 +743,6 @@ mod tests {
assert_eq!(logging_conf.should_log(&req), (true, false));

let logging_conf = Logging {
format: LoggingFormat::default(),
display_target: false,
display_filename: false,
display_line_number: false,
when_header: vec![HeaderLoggingCondition::Value {
name: "test".to_string(),
value: String::from("foobar"),
Expand All @@ -778,10 +753,6 @@ mod tests {
assert_eq!(logging_conf.should_log(&req), (true, false));

let logging_conf = Logging {
format: LoggingFormat::default(),
display_target: false,
display_filename: false,
display_line_number: false,
when_header: vec![
HeaderLoggingCondition::Matching {
name: "test".to_string(),
Expand All @@ -800,10 +771,6 @@ mod tests {
assert_eq!(logging_conf.should_log(&req), (true, true));

let logging_conf = Logging {
format: LoggingFormat::default(),
display_target: false,
display_filename: false,
display_line_number: false,
when_header: vec![HeaderLoggingCondition::Matching {
name: "testtest".to_string(),
matching: Regex::new("^foo*").unwrap(),
Expand Down
Loading

0 comments on commit 00b5864

Please sign in to comment.