1use bevy::prelude::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, Serialize, Deserialize)]
6pub struct OtlpConfig {
7 pub use_http_json: bool,
12
13 pub resource_attributes: std::collections::HashMap<String, String>,
15}
16
17impl Default for OtlpConfig {
18 fn default() -> Self {
19 Self {
20 use_http_json: true,
21 resource_attributes: std::collections::HashMap::new(),
22 }
23 }
24}
25
26#[derive(Clone, Debug, Resource, Serialize, Deserialize)]
28pub struct FleetConfig {
29 pub app_id: String,
31
32 pub app_name: String,
34
35 pub app_version: String,
37
38 pub aggregation_url: String,
40
41 pub enabled: bool,
43
44 pub publish_interval_secs: u64,
46
47 pub max_queue_size: usize,
49
50 pub otlp_config: OtlpConfig,
52}
53
54impl Default for FleetConfig {
55 fn default() -> Self {
56 Self {
57 app_id: "bevy-app".to_string(),
58 app_name: "bevy-fleet".to_string(),
59 app_version: get_default_app_version(),
60 aggregation_url: "http://localhost:4318/v1/metrics".to_string(),
61 enabled: true,
62 publish_interval_secs: 60,
63 max_queue_size: 100,
64 otlp_config: OtlpConfig::default(),
65 }
66 }
67}
68
69fn get_default_app_version() -> String {
71 #[cfg(feature = "git-version")]
72 {
73 git_version::git_version!(args = ["--always", "--dirty=-modified"], fallback = "unknown")
74 .to_string()
75 }
76
77 #[cfg(not(feature = "git-version"))]
78 {
79 "unknown".to_string()
80 }
81}
82
83#[derive(Clone, Default)]
85pub struct FleetPlugin {
86 pub config: FleetConfig,
87}