Skip to content

Instantly share code, notes, and snippets.

View jasonnerothin's full-sized avatar
🎯
Focusing

Jason Nerothin jasonnerothin

🎯
Focusing
  • Hands Dirty Engineering
  • At large
View GitHub Profile
@jasonnerothin
jasonnerothin / telemetry_init.py
Created November 7, 2025 19:19
Unified OTLP Resource Naming
"""
Common telemetry initialization utilities.
Provides standardized resource attribute creation for logging, metrics, and tracing
across all DWS components.
"""
import os
from typing import Optional
@jasonnerothin
jasonnerothin / end-to-end-lock-trace-flow.txt
Created November 6, 2025 20:04
Lock Request Trace Flow
═══════════════════════════════════════════════════════════════════════════════
LOCK REQUEST TRACE (traceparent: 00-ABC123...-001-01)
Services: 4 (fpv-ops, tower-sidecar, striker, drone-cmd)
═══════════════════════════════════════════════════════════════════════════════
[1] fpv-ops: publish_lock_request_striker (PRODUCER) ✅ ROOT
│ User selected option 1 from fpv-ops UI
│ Creates trace root with new trace ID
│ Injects traceparent into Redis message envelope
│ Publishes to: striker_control_channel
@jasonnerothin
jasonnerothin / redis_tracer.py
Created November 6, 2025 18:28
redis transport layer otlp trace provider
"""
Redis Tracer - Distributed tracing for Redis pub/sub messaging
Provides utilities to publish and subscribe to Redis channels with
W3C Trace Context propagation via message envelopes.
"""
import json
import time
from typing import Optional, Dict, Any, Callable
@jasonnerothin
jasonnerothin / https_tracer.py
Created November 6, 2025 18:27
stack agnostic http trace provider
"""
HTTPS Tracer - Distributed tracing for HTTPS client/server communication
Client-side: Uses standard requests library (no framework dependency)
Server-side: Provides generic patterns adaptable to any HTTP framework
"""
from typing import Optional, Dict, Any, Callable
import requests
@jasonnerothin
jasonnerothin / redis_channel_monitor.py
Created November 6, 2025 18:07
redis sidecar supporting otlp metrics and traces
#!/usr/bin/env python3
"""
Tower Sidecar - Unified Metrics and Distributed Tracing Bridge
Monitors Redis channels and provides:
1. Metrics: Message throughput, rates (existing functionality)
2. Traces: Distributed trace context propagation (new functionality)
Implements the three-span pattern for async messaging while maintaining
metrics collection.
@jasonnerothin
jasonnerothin / redis_channel_monitor.py
Last active November 4, 2025 18:29
Redis side car - message counter
#!/usr/bin/env python3
"""
Redis Channel Monitor - Monitors message throughput on Redis channels
and reports metrics to OpenTelemetry Collector.
"""
import os
import sys
import time
import logging
@jasonnerothin
jasonnerothin / docker-compose.yml
Last active November 4, 2025 18:33
Elasticstack Docker Compose config for Edot Collector with docker_stats daemon
configs:
# This is the minimal yaml configuration needed to listen on all interfaces
# for OTLP logs, metrics and traces, exporting to Elasticsearch.
edot-collector-config:
content: |
receivers:
# Receives data from other Collectors in Agent mode
otlp:
protocols:
grpc:
"""
Thread-safe Death Telemetry Metrics Module (Multi-Drone Version)
This module provides observable gauges for death data including:
- drone id
- drone id position (latitude and longitude)
The module uses callbacks to pull the latest data from shared state when
the OTLP exporter requests metric values. It includes staleness checking
to prevent reporting outdated data.
import numpy as np
from scipy.optimize import linear_sum_assignment
def best_intercepts_hungarian(
all_intercepts: List[Dict[str, Any]],
strikers: List[Dict[str, Any]],
optimization_metric: str = 'intercept_time'
) -> Dict[str, Dict[str, Any]]:
"""
Use Hungarian algorithm to find globally optimal striker-target assignments.
@jasonnerothin
jasonnerothin / threadsafe_oltp_traces.py
Created October 17, 2025 22:28
threadsafe oltp tracing module
import os
import threading
from typing import Optional
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.sdk.resources import Resource
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter