syn2mas/
telemetry.rs

1use std::sync::LazyLock;
2
3use opentelemetry::{InstrumentationScope, metrics::Meter};
4use opentelemetry_semantic_conventions as semcov;
5
6static SCOPE: LazyLock<InstrumentationScope> = LazyLock::new(|| {
7    InstrumentationScope::builder(env!("CARGO_PKG_NAME"))
8        .with_version(env!("CARGO_PKG_VERSION"))
9        .with_schema_url(semcov::SCHEMA_URL)
10        .build()
11});
12
13pub static METER: LazyLock<Meter> =
14    LazyLock::new(|| opentelemetry::global::meter_with_scope(SCOPE.clone()));
15
16/// Attribute key for syn2mas.entity metrics representing what entity.
17pub const K_ENTITY: &str = "entity";
18
19/// Attribute value for syn2mas.entity metrics representing users.
20pub const V_ENTITY_USERS: &str = "users";
21/// Attribute value for syn2mas.entity metrics representing devices.
22pub const V_ENTITY_DEVICES: &str = "devices";
23/// Attribute value for syn2mas.entity metrics representing threepids.
24pub const V_ENTITY_THREEPIDS: &str = "threepids";
25/// Attribute value for syn2mas.entity metrics representing external IDs.
26pub const V_ENTITY_EXTERNAL_IDS: &str = "external_ids";
27/// Attribute value for syn2mas.entity metrics representing non-refreshable
28/// access token entities.
29pub const V_ENTITY_NONREFRESHABLE_ACCESS_TOKENS: &str = "nonrefreshable_access_tokens";
30/// Attribute value for syn2mas.entity metrics representing refreshable
31/// access/refresh token pairs.
32pub const V_ENTITY_REFRESHABLE_TOKEN_PAIRS: &str = "refreshable_token_pairs";