[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73DJVP6BQ97ERA4F4427H3E":3,"skill-same:01M73DJVP6BQ97ERA4F4427H3E":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":47,"ownerHtmlUrl":48,"ownerBlogUrl":49,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M73DJVP6BQ97ERA4F4427H3E","logging-observability",null,"Production logging — structlog, structured JSON logs, correlation IDs, log levels, OpenTelemetry traces, no print()","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Flogging-observability\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: logging-observability\ndescription: Production logging — structlog, structured JSON logs, correlation IDs, log levels, OpenTelemetry traces, no print()\ntriggers:\n  - logging best practice\n  - structlog\n  - structured logging\n  - correlation id logging\n  - log levels\n  - no print logging\n  - production logging python\n  - observability logging\n  - log context\n  - opentelemetry traces\ndo_not_use_for:\n  - LLM-specific observability — use langfuse\n  - metrics\u002Fdashboards — use prometheus\u002Fgrafana\n  - error handling — use error-handling-patterns\nsee_also:\n  - ai-code-maintainability\n  - error-handling-patterns\n---\n\n# Logging & Observability\n\n## Setup: structlog (Recommended)\n\n```python\nimport logging\nimport structlog\n\ndef configure_logging(env: str = \"production\") -> None:\n    shared_processors = [\n        structlog.contextvars.merge_contextvars,\n        structlog.processors.add_log_level,\n        structlog.processors.TimeStamper(fmt=\"iso\"),\n        structlog.processors.StackInfoRenderer(),\n    ]\n\n    if env == \"development\":\n        # Human-readable in dev\n        processors = shared_processors + [\n            structlog.dev.ConsoleRenderer()\n        ]\n    else:\n        # JSON in prod — parseable by Loki\u002FCloudWatch\u002FDatadog\n        processors = shared_processors + [\n            structlog.processors.dict_tracebacks,\n            structlog.processors.JSONRenderer(),\n        ]\n\n    structlog.configure(\n        processors=processors,\n        wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),\n        context_class=dict,\n        logger_factory=structlog.PrintLoggerFactory(),\n    )\n\nlog = structlog.get_logger()\n```\n\n## Correlation ID Middleware\n\n```python\nimport uuid\nfrom starlette.middleware.base import BaseHTTPMiddleware\nfrom starlette.requests import Request\nimport structlog\n\nclass CorrelationIdMiddleware(BaseHTTPMiddleware):\n    async def dispatch(self, request: Request, call_next):\n        correlation_id = request.headers.get(\"X-Correlation-ID\", str(uuid.uuid4()))\n        structlog.contextvars.clear_contextvars()\n        structlog.contextvars.bind_contextvars(\n            correlation_id=correlation_id,\n            path=request.url.path,\n            method=request.method,\n        )\n        response = await call_next(request)\n        response.headers[\"X-Correlation-ID\"] = correlation_id\n        return response\n\n# All log calls in this request now automatically include correlation_id\n```\n\n## Log Levels Guide\n\n```python\nlog = structlog.get_logger(__name__)\n\n# DEBUG — detailed diagnostic, only in dev\nlog.debug(\"processing_chunk\", chunk_index=3, chunk_size=512)\n\n# INFO — normal operations, business events\nlog.info(\"user_registered\", user_id=user.id, plan=\"free\")\nlog.info(\"payment_completed\", order_id=order.id, amount=99.0, currency=\"USD\")\n\n# WARNING — unexpected but recoverable\nlog.warning(\"retry_attempt\", attempt=2, max=3, service=\"stripe\")\nlog.warning(\"cache_miss\", key=\"user:123\", fallback=\"db\")\n\n# ERROR — operation failed, action needed\nlog.error(\"payment_failed\", order_id=order.id, error=str(e), code=e.code)\n\n# CRITICAL — system-level failure, immediate attention\nlog.critical(\"database_unreachable\", host=db_host, elapsed_ms=5000)\n```\n\n## Structured Log Fields (Standard)\n\n```python\n# Always include in service logs\nlog.info(\n    \"event_name\",                   # snake_case event\n    user_id=\"u-123\",               # who\n    resource_type=\"order\",          # what\n    resource_id=\"o-456\",           # which one\n    action=\"create\",               # what action\n    duration_ms=42,                # how long\n    status=\"success\",              # outcome\n    environment=\"production\",      # where\n)\n# → {\"event\": \"event_name\", \"user_id\": \"u-123\", ...}\n```\n\n## OpenTelemetry Traces\n\n```python\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import BatchSpanProcessor\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\n\n# Setup\nprovider = TracerProvider()\nprovider.add_span_processor(\n    BatchSpanProcessor(OTLPSpanExporter(endpoint=\"http:\u002F\u002Fotel-collector:4318\u002Fv1\u002Ftraces\"))\n)\ntrace.set_tracer_provider(provider)\n\ntracer = trace.get_tracer(\"my-service\", \"1.0.0\")\n\n# Instrument code\ndef process_order(order_id: str) -> None:\n    with tracer.start_as_current_span(\"process_order\") as span:\n        span.set_attribute(\"order.id\", order_id)\n        try:\n            result = _do_work(order_id)\n            span.set_attribute(\"order.status\", result.status)\n        except Exception as e:\n            span.record_exception(e)\n            span.set_status(trace.StatusCode.ERROR, str(e))\n            raise\n```\n\n## Log Sampling (high-volume)\n\n```python\nimport structlog\n\n# Don't log every request at INFO in prod — sample at 10%\nimport random\n\ndef log_if_sample(log, rate: float = 0.1, **kwargs) -> None:\n    if random.random() \u003C rate:\n        log.info(**kwargs)\n\n# Or use structured sampling based on user\ndef should_log_detailed(user_id: str) -> bool:\n    return int(user_id[-4:], 16) % 100 \u003C 5   # 5% of users get detailed logs\n```\n\n## Anti-Fake-Pass Checks\n\n- `print()` in server code = invisible in prod log aggregators (CloudWatch, Loki)\n- Logging PII (emails, passwords, tokens) = GDPR\u002Fcompliance violation\n- `log.exception()` includes stack trace — use only for unexpected errors\n- `structlog.contextvars` is thread-local + async-safe — don't bind to regular dict\n- OpenTelemetry `BatchSpanProcessor` is async — call `provider.shutdown()` on app exit\n- Log the error, not the exception message alone — include context (user_id, resource_id)\n- `logging.DEBUG` level in production = performance hit and log flooding\n","# Logging & Observability\n\n## Setup: structlog (Recommended)\n\n```python\nimport logging\nimport structlog\n\ndef configure_logging(env: str = \"production\") -> None:\n    shared_processors = [\n        structlog.contextvars.merge_contextvars,\n        structlog.processors.add_log_level,\n        structlog.processors.TimeStamper(fmt=\"iso\"),\n        structlog.processors.StackInfoRenderer(),\n    ]\n\n    if env == \"development\":\n        # Human-readable in dev\n        processors = shared_processors + [\n            structlog.dev.ConsoleRenderer()\n        ]\n    else:\n        # JSON in prod — parseable by Loki\u002FCloudWatch\u002FDatadog\n        processors = shared_processors + [\n            structlog.processors.dict_tracebacks,\n            structlog.processors.JSONRenderer(),\n        ]\n\n    structlog.configure(\n        processors=processors,\n        wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),\n        context_class=dict,\n        logger_factory=structlog.PrintLoggerFactory(),\n    )\n\nlog = structlog.get_logger()\n```\n\n## Correlation ID Middleware\n\n```python\nimport uuid\nfrom starlette.middleware.base import BaseHTTPMiddleware\nfrom starlette.requests import Request\nimport structlog\n\nclass CorrelationIdMiddleware(BaseHTTPMiddleware):\n    async def dispatch(self, request: Request, call_next):\n        correlation_id = request.headers.get(\"X-Correlation-ID\", str(uuid.uuid4()))\n        structlog.contextvars.clear_contextvars()\n        structlog.contextvars.bind_contextvars(\n            correlation_id=correlation_id,\n            path=request.url.path,\n            method=request.method,\n        )\n        response = await call_next(request)\n        response.headers[\"X-Correlation-ID\"] = correlation_id\n        return response\n\n# All log calls in this request now automatically include correlation_id\n```\n\n## Log Levels Guide\n\n```python\nlog = structlog.get_logger(__name__)\n\n# DEBUG — detailed diagnostic, only in dev\nlog.debug(\"processing_chunk\", chunk_index=3, chunk_size=512)\n\n# INFO — normal operations, business events\nlog.info(\"user_registered\", user_id=user.id, plan=\"free\")\nlog.info(\"payment_completed\", order_id=order.id, amount=99.0, currency=\"USD\")\n\n# WARNING — unexpected but recoverable\nlog.warning(\"retry_attempt\", attempt=2, max=3, service=\"stripe\")\nlog.warning(\"cache_miss\", key=\"user:123\", fallback=\"db\")\n\n# ERROR — operation failed, action needed\nlog.error(\"payment_failed\", order_id=order.id, error=str(e), code=e.code)\n\n# CRITICAL — system-level failure, immediate attention\nlog.critical(\"database_unreachable\", host=db_host, elapsed_ms=5000)\n```\n\n## Structured Log Fields (Standard)\n\n```python\n# Always include in service logs\nlog.info(\n    \"event_name\",                   # snake_case event\n    user_id=\"u-123\",               # who\n    resource_type=\"order\",          # what\n    resource_id=\"o-456\",           # which one\n    action=\"create\",               # what action\n    duration_ms=42,                # how long\n    status=\"success\",              # outcome\n    environment=\"production\",      # where\n)\n# → {\"event\": \"event_name\", \"user_id\": \"u-123\", ...}\n```\n\n## OpenTelemetry Traces\n\n```python\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import BatchSpanProcessor\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\n\n# Setup\nprovider = TracerProvider()\nprovider.add_span_processor(\n    BatchSpanProcessor(OTLPSpanExporter(endpoint=\"http:\u002F\u002Fotel-collector:4318\u002Fv1\u002Ftraces\"))\n)\ntrace.set_tracer_provider(provider)\n\ntracer = trace.get_tracer(\"my-service\", \"1.0.0\")\n\n# Instrument code\ndef process_order(order_id: str) -> None:\n    with tracer.start_as_current_span(\"process_order\") as span:\n        span.set_attribute(\"order.id\", order_id)\n        try:\n            result = _do_work(order_id)\n            span.set_attribute(\"order.status\", result.status)\n        except Exception as e:\n            span.record_exception(e)\n            span.set_status(trace.StatusCode.ERROR, str(e))\n            raise\n```\n\n## Log Sampling (high-volume)\n\n```python\nimport structlog\n\n# Don't log every request at INFO in prod — sample at 10%\nimport random\n\ndef log_if_sample(log, rate: float = 0.1, **kwargs) -> None:\n    if random.random() \u003C rate:\n        log.info(**kwargs)\n\n# Or use structured sampling based on user\ndef should_log_detailed(user_id: str) -> bool:\n    return int(user_id[-4:], 16) % 100 \u003C 5   # 5% of users get detailed logs\n```\n\n## Anti-Fake-Pass Checks\n\n- `print()` in server code = invisible in prod log aggregators (CloudWatch, Loki)\n- Logging PII (emails, passwords, tokens) = GDPR\u002Fcompliance violation\n- `log.exception()` includes stack trace — use only for unexpected errors\n- `structlog.contextvars` is thread-local + async-safe — don't bind to regular dict\n- OpenTelemetry `BatchSpanProcessor` is async — call `provider.shutdown()` on app exit\n- Log the error, not the exception message alone — include context (user_id, resource_id)\n- `logging.DEBUG` level in production = performance hit and log flooding\n",{"name":5,"see_also":24,"triggers":27,"description":7,"do_not_use_for":38},[25,26],"ai-code-maintainability","error-handling-patterns",[28,29,30,31,32,33,34,35,36,37],"logging best practice","structlog","structured logging","correlation id logging","log levels","no print logging","production logging python","observability logging","log context","opentelemetry traces",[39,40,41],"LLM-specific observability — use langfuse","metrics\u002Fdashboards — use prometheus\u002Fgrafana","error handling — use error-handling-patterns","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Flogging-observability",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill logging-observability",{"tool":58,"command":59},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill logging-observability",{"tool":61,"command":62},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill logging-observability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Flogging-observability\u002FSKILL.md",true,[],[67,75,82,90,98,106],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":86,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":94,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":102,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]