HabitaNexus/monorepo / skills/system-reliability-engineering/observability-stack
observability-stack
Unverified| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 27.0 KB |
| scripts/README.md | markdown | 1.9 KB |
| scripts/nodejs/instrumentation.js | script | 2.1 KB |
| scripts/nodejs/package.json | manifest | 658 B |
| scripts/nodejs/userService.js | script | 1.5 KB |
| scripts/rust/Cargo.toml | manifest | 381 B |
| scripts/rust/src/lib.rs | script | 213 B |
| scripts/rust/src/main.rs | script | 787 B |
| scripts/rust/src/services/user_service.rs | script | 2.0 KB |
| scripts/rust/src/telemetry.rs | script | 2.4 KB |
scripts/rust/src/services/user_service.rs
View on GitHub//! User Service with Custom Spans
//!
//! Example service demonstrating custom spans and tracing in Rust.
use opentelemetry::trace::{Span, Status, Tracer};
use opentelemetry::global;
use opentelemetry::KeyValue;
use tracing::{error, instrument};
pub struct UserService;
#[derive(Debug)]
pub struct User {
pub id: String,
pub name: String,
pub email: String,
}
#[derive(Debug)]
pub struct ServiceError {
pub message: String,
}
impl UserService {
/// Get user by ID with custom span.
///
/// # Arguments
///
/// * `user_id` - User ID to fetch
///
/// # Returns
///
/// Result containing User or ServiceError
#[instrument(skip(self), fields(user.id = %user_id))]
pub async fn get_user_by_id(&self, user_id: String) -> Result<User, ServiceError> {
let tracer = global::tracer("user-service");
let mut span = tracer.start("getUserById");
span.set_attribute(KeyValue::new("user.id", user_id.clone()));
span.set_attribute(KeyValue::new("operation.type", "read"));
span.add_event("Fetching user from database", vec![]);
match self.fetch_user_from_db(&user_id).await {
Ok(user) => {
span.set_attribute(KeyValue::new("user.found", true));
span.set_status(Status::Ok);
span.end();
Ok(user)
}
Err(e) => {
span.set_status(Status::error(e.message.clone()));
span.record_exception(&e);
error!(error = %e.message, "Failed to fetch user");
span.end();
Err(e)
}
}
}
async fn fetch_user_from_db(&self, user_id: &str) -> Result<User, ServiceError> {
// Simulate database query
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
Ok(User {
id: user_id.to_string(),
name: "John Doe".to_string(),
email: "john@example.com".to_string(),
})
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |