Move instrumentation to common crate
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

This commit is contained in:
Daniel Lundin 2024-12-16 18:46:14 +01:00
parent d8c8b7bb10
commit ffcea325f6
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
10 changed files with 67 additions and 15 deletions

31
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "addr2line"
@ -1558,6 +1558,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"patagia-common",
"progenitor",
"reqwest",
"schemars",
@ -1568,6 +1569,33 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "patagia-common"
version = "0.1.0"
dependencies = [
"anyhow",
"dropshot",
"http",
"once_cell",
"opentelemetry",
"opentelemetry-appender-tracing",
"opentelemetry-otlp",
"opentelemetry-semantic-conventions",
"opentelemetry-stdout",
"opentelemetry_sdk",
"schemars",
"serde",
"slog",
"slog-async",
"tokio",
"tracing",
"tracing-chrome",
"tracing-core",
"tracing-opentelemetry",
"tracing-slog",
"tracing-subscriber",
]
[[package]]
name = "patagia-controller"
version = "0.1.0"
@ -1583,6 +1611,7 @@ dependencies = [
"opentelemetry-semantic-conventions",
"opentelemetry-stdout",
"opentelemetry_sdk",
"patagia-common",
"schemars",
"serde",
"slog",

View file

@ -2,16 +2,17 @@
resolver = "2"
members = [
"agent",
"common",
"controller",
"xtask",
]
default-members = [
"agent",
"common",
"controller",
"xtask",
]
[workspace.package]
version = "0.2.0"
edition = "2021"

View file

@ -7,6 +7,7 @@ license = "MPL-2.0"
[dependencies]
anyhow.workspace = true
clap.workspace = true
patagia-common = { path = "../common" }
progenitor.workspace = true
reqwest.workspace = true
schemars.workspace = true

View file

@ -1,9 +1,9 @@
use anyhow::Result;
use clap::Parser;
use tokio::time::{sleep, Duration};
use tracing_subscriber::prelude::*;
mod patagia_api;
use patagia_common::instrumentation;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
@ -12,12 +12,7 @@ struct Cli {}
#[tokio::main]
async fn main() -> Result<()> {
let _args = Cli::parse();
let fmt_layer = tracing_subscriber::fmt::layer();
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::from_default_env())
.with(fmt_layer)
.init();
let _tracing = instrumentation::init_tracing_subscriber()?;
tracing::info!("Patagia Agent");

29
common/Cargo.toml Normal file
View file

@ -0,0 +1,29 @@
[package]
name = "patagia-common"
description = "Common control plane modules"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
[dependencies]
anyhow.workspace = true
dropshot.workspace = true
http.workspace = true
once_cell.workspace = true
opentelemetry-appender-tracing.workspace = true
opentelemetry-otlp.workspace = true
opentelemetry_sdk.workspace = true
opentelemetry-semantic-conventions.workspace = true
opentelemetry-stdout.workspace = true
opentelemetry.workspace = true
schemars.workspace = true
serde.workspace = true
slog-async.workspace = true
slog.workspace = true
tokio.workspace = true
tracing-chrome.workspace = true
tracing-core.workspace = true
tracing-opentelemetry.workspace = true
tracing-slog.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true

1
common/src/lib.rs Normal file
View file

@ -0,0 +1 @@
pub mod instrumentation;

View file

@ -17,6 +17,7 @@ opentelemetry_sdk.workspace = true
opentelemetry-semantic-conventions.workspace = true
opentelemetry-stdout.workspace = true
opentelemetry.workspace = true
patagia-common = { path = "../common" }
schemars.workspace = true
serde.workspace = true
slog-async.workspace = true
@ -28,7 +29,3 @@ tracing-opentelemetry.workspace = true
tracing-slog.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
#
# [[bin]]
# name = "patagia-controller"
# doc = false

View file

@ -9,9 +9,9 @@ use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
use patagia_common::instrumentation;
use patagia_controller::api;
use patagia_controller::context::ControllerContext;
use patagia_controller::instrumentation;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]

View file

@ -1,5 +1,4 @@
pub mod api;
pub mod context;
pub mod instrumentation;
mod version;