-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
115 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ pub mod tls; | |
|
||
mod acme; | ||
pub mod cors; | ||
mod otlp; | ||
pub mod service; | ||
pub mod static_file_filter; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
mod otlp; | ||
|
||
use tracing_core::Level; | ||
use tracing_subscriber::EnvFilter; | ||
use spa_server::config::Config; | ||
|
||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
let config = Config::load()?; | ||
let open_telemetry = &config.open_telemetry; | ||
if let Some(open_telemetry) = open_telemetry.as_ref() { | ||
otlp::init_otlp(open_telemetry.endpoint.clone())?; | ||
} else { | ||
tracing_subscriber::fmt() | ||
.with_env_filter( | ||
EnvFilter::builder() | ||
.with_default_directive(Level::INFO.into()) | ||
.from_env_lossy(), | ||
) | ||
.init(); | ||
} | ||
|
||
|
||
tracing::debug!("config load:{:?}", &config); | ||
spa_server::run_server_with_config(config).await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use opentelemetry::KeyValue; | ||
use opentelemetry_otlp::{ExportConfig, WithExportConfig}; | ||
use opentelemetry_sdk::{Resource, runtime}; | ||
use opentelemetry_sdk::trace::config; | ||
use opentelemetry_semantic_conventions::resource::SERVICE_NAME; | ||
use opentelemetry_semantic_conventions::trace::SERVICE_VERSION; | ||
use tracing_core::Level; | ||
use tracing_opentelemetry::OpenTelemetryLayer; | ||
use tracing_subscriber::EnvFilter; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::util::SubscriberInitExt; | ||
|
||
pub fn init_otlp(endpoint:String) -> anyhow::Result<()>{ | ||
let resource = Resource::new(vec![ | ||
KeyValue::new(SERVICE_NAME, "spa-server"), | ||
KeyValue::new(SERVICE_VERSION, env!("CARGO_PKG_VERSION")) | ||
]); | ||
let mut export_config = ExportConfig::default(); | ||
export_config.endpoint = endpoint; | ||
let exporter = opentelemetry_otlp::new_exporter().tonic() | ||
.with_export_config(export_config); | ||
|
||
let tracer = opentelemetry_otlp::new_pipeline() | ||
.tracing().with_exporter(exporter) | ||
.with_trace_config(config().with_resource(resource)) | ||
.install_batch(runtime::Tokio)?; | ||
|
||
let filter = EnvFilter::builder() | ||
.with_default_directive(Level::INFO.into()) | ||
.from_env_lossy(); | ||
tracing_subscriber::registry() | ||
.with(filter) | ||
.with(tracing_subscriber::fmt::layer().compact()) | ||
.with(OpenTelemetryLayer::new(tracer)) | ||
.init(); | ||
Ok(()) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters