// SPDX-License-Identifier: Apache-2.0 //! Generated entity types, attribute constants, and enum types. //! //! DO NOT EDIT — this file is generated by Weaver from `model/live_check.yaml`. //! To regenerate, run from the repository root: //! //! ```sh //! weaver registry generate \ //! --registry crates/weaver_live_check/model/ \ //! --templates crates/weaver_live_check/templates/ \ //! --v2 \ //! rust \ //! crates/weaver_live_check/src/ //! ``` #[allow(unused_imports)] use serde::{Deserialize, Serialize}; use opentelemetry::KeyValue; // --- service entity --- // Attribute key constants /// Logical name of the service. pub const SERVICE_NAME: &str = "service.name"; /// The operational criticality of the service. pub const SERVICE_CRITICALITY: &str = "service.criticality"; /// The version string of the service component. The format is not defined by these conventions. pub const SERVICE_VERSION: &str = "service.version"; /// A logical unit of an application or system that performs a specific function. /// /// A service is a logical component used in a system, product or application. Examples include a microservice, a database, a Kubernetes deployment. #[derive(Debug, Clone)] pub struct Service { /// Logical name of the service. pub name: String, /// The operational criticality of the service. pub criticality: Option, /// The version string of the service component. The format is not defined by these conventions. pub version: Option, } impl Service { /// Convert this entity's attributes to OpenTelemetry resource attributes. #[must_use] pub fn to_resource_attributes(&self) -> Vec { let mut attrs = Vec::new(); attrs.push(KeyValue::new(SERVICE_NAME, self.name.clone())); if let Some(val) = &self.criticality { attrs.push(KeyValue::new(SERVICE_CRITICALITY, val.to_string())); } if let Some(val) = &self.version { attrs.push(KeyValue::new(SERVICE_VERSION, val.clone())); } attrs } } /// The operational criticality of the service. /// /// Application developers are encouraged to set `service.criticality` to express the operational importance of their services. Telemetry consumers MAY use this attribute to optimize telemetry collection or improve user experience. #[derive( Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, strum::Display, strum::EnumString, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum ServiceCriticality { /// Service is business-critical; downtime directly impacts revenue, user experience, or core functionality. Critical, /// Service is important but has degradation tolerance or fallback mechanisms. High, /// Service provides supplementary functionality; degradation has limited user impact. Medium, /// Service is non-essential to core operations; used for background tasks or internal tools. Low, } // --- telemetry.sdk entity --- // Attribute key constants /// The language of the telemetry SDK. pub const TELEMETRY_SDK_LANGUAGE: &str = "telemetry.sdk.language"; /// The name of the telemetry SDK as defined above. pub const TELEMETRY_SDK_NAME: &str = "telemetry.sdk.name"; /// The version string of the telemetry SDK. pub const TELEMETRY_SDK_VERSION: &str = "telemetry.sdk.version"; /// The telemetry SDK used to capture data recorded by the instrumentation libraries. #[derive(Debug, Clone)] pub struct TelemetrySdk { /// The language of the telemetry SDK. pub language: SdkLanguage, /// The name of the telemetry SDK as defined above. pub name: String, /// The version string of the telemetry SDK. pub version: Option, } impl TelemetrySdk { /// Convert this entity's attributes to OpenTelemetry resource attributes. #[must_use] pub fn to_resource_attributes(&self) -> Vec { let mut attrs = Vec::new(); attrs.push(KeyValue::new( TELEMETRY_SDK_LANGUAGE, self.language.to_string(), )); attrs.push(KeyValue::new(TELEMETRY_SDK_NAME, self.name.clone())); if let Some(val) = &self.version { attrs.push(KeyValue::new(TELEMETRY_SDK_VERSION, val.clone())); } attrs } } /// The language of the telemetry SDK. /// /// #[derive( Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, strum::Display, strum::EnumString, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum SdkLanguage { /// `cpp` Cpp, /// `dotnet` Dotnet, /// `erlang` Erlang, /// `go` Go, /// `java` Java, /// `nodejs` Nodejs, /// `php` Php, /// `python` Python, /// `ruby` Ruby, /// `rust` Rust, /// `swift` Swift, /// `webjs` Webjs, }