-
Notifications
You must be signed in to change notification settings - Fork 45
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
External Logging #500
base: main
Are you sure you want to change the base?
External Logging #500
Conversation
crates/cdk-mintd/src/loggers.rs
Outdated
let api_key_header = api_key.map(|key| format!("ApiKey {}", key)); | ||
|
||
// Spawn an async task to process logs and send them to Elasticsearch. | ||
tokio::spawn(async move { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great to have the JoinHandle in the struct and to kill it on drop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea sorry for the delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to move the handle in the ElasticsearchLayer
object without wrapping it in a Option
because there is always a task in this case. Wdyt?
Not quite sure how to test the API key in the "Authentication" header, since ElasticSearch won't mint one for me. It says some bullshit about the current license... Currently only tested with http authentication embedded in the URL (e.g. |
Ok scrap that. Managed to get one. |
Should we gate this under a feature? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. I have a mild preference for putting this behind a feature, but since its in mintd and not cdk and only adds deps we mostly already have from cdk not a strong one.
Should we add elasticsearch search to the docker-compose file with a few lines of docs of how to run it? Or what is the recommended way to run with elasticsearch?
chrono = "0.4.39" | ||
serde_json = "1.0.133" | ||
reqwest = "0.12.9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chrono = "0.4.39" | |
serde_json = "1.0.133" | |
reqwest = "0.12.9" | |
chrono = "0.4.39" | |
serde_json = "1" | |
reqwest = "0.12" |
Since for MSRV we need 24.3 of reqwest we should not set the patch version, cargo will use the lastest one we can.
This change plus rebasing onto main should fix the MSRV CI errors
use chrono::Utc; | ||
use reqwest::Client; | ||
use serde::Serialize; | ||
use std::fmt::Write; | ||
use tokio::sync::mpsc::{self, Sender}; | ||
use tokio::task::JoinHandle; | ||
use tracing::field::{Field, Visit}; | ||
use tracing::Event; | ||
use tracing_subscriber::layer::{Context, Layer}; | ||
use tracing_subscriber::registry::LookupSpan; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use chrono::Utc; | |
use reqwest::Client; | |
use serde::Serialize; | |
use std::fmt::Write; | |
use tokio::sync::mpsc::{self, Sender}; | |
use tokio::task::JoinHandle; | |
use tracing::field::{Field, Visit}; | |
use tracing::Event; | |
use tracing_subscriber::layer::{Context, Layer}; | |
use tracing_subscriber::registry::LookupSpan; | |
use std::fmt::Write; | |
use chrono::Utc; | |
use reqwest::Client; | |
use serde::Serialize; | |
use tokio::sync::mpsc::{self, Sender}; | |
use tokio::task::JoinHandle; | |
use tracing::field::{Field, Visit}; | |
use tracing::Event; | |
use tracing_subscriber::layer::{Context, Layer}; | |
use tracing_subscriber::registry::LookupSpan; |
Std imports should be first, this will fix formatting ci
@@ -58,6 +58,7 @@ uuid = { version = "1", features = ["v4", "serde"] } | |||
# -Z minimal-versions | |||
sync_wrapper = "0.1.2" | |||
bech32 = "0.9.1" | |||
chrono = "0.4.39" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports under the -Z minimal-versions are for the case where a dep of ours does not properly define their minimum deps I don't think that is the case here.
Do we need the dep in cdk I don't see where it is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I forgot to remove it because previously was working on cdk crate not cdk-mintd so that's left over from that..
Description
Defines a
ElasticsearchLayer
which implementsLayer
and can subscribe to tracing events and transmit them to ElasticSearch (specifically, another service might require another apposite Layer)ElastiSearccLayer
creates a multi producer single consumer channel and spawns a task that continuously attempts to receive log messages. In theLayer
trait implementationon_event
is called everytime a thread logs message and it write that message to the channel.