Skip to content

Instantly share code, notes, and snippets.

View keithchambers's full-sized avatar

Keith Chambers keithchambers

View GitHub Profile
receivers:
otlp:
protocols:
grpc: {}
http: {}
processors:
transform/normalise_keys:
error_mode: ignore
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "AWS Bedrock OpenTelemetry (OTLP/JSON) Schema",
"description": "Validation schema covering resource and span attributes required for instrumenting Amazon Bedrock calls using OpenTelemetry Gen-AI semantic conventions.",
"type": "object",
"properties": {
"resource": {
"type": "object",
"properties": {
"attributes": { "$ref": "#/$defs/ResourceAttributes" }
@keithchambers
keithchambers / main.go
Created May 2, 2025 13:05
OTEL Harrier DQL
// Package genaicleaner provides an OpenTelemetry Collector *processor* that
// sanitises Gen-AI spans in-flight.
//
// The processor performs three operations, all entirely in-memory:
//
// 1. **Validation** – incoming spans are checked against Harrier’s
// *authoritative* allow-lists (derived from OTEP ≥ 1.43).
// 2. **Cleaning / Forking**
// • A *clean* copy is forwarded on the same pipeline and tagged
// `messaging.kafka.destination="input"` so the kafkaexporter can map
{
"resourceSpans": [
{
"resource": {
"attributes": [
{ "key": "service.name", "value": { "stringValue": "autonomous_trading_system" } },
{ "key": "service.namespace", "value": { "stringValue": "trading" } },
{ "key": "service.version", "value": { "stringValue": "3.2.0" } },
{ "key": "service.instance.id", "value": { "stringValue": "instance-001" } },
{ "key": "deployment.environment","value":{ "stringValue": "prod" } }
{
"resourceSpans": [
{
"resource": {
"attributes": [
{ "key": "service.name", "value": { "stringValue": "genai-demo-app" } },
{ "key": "deployment.environment", "value": { "stringValue": "prod" } }
]
},
"schema_url": "https://opentelemetry.io/schemas/1.5.0",
@keithchambers
keithchambers / OTEL.json
Last active April 20, 2025 07:48
OTEL JSON
{
"resourceSpans": [{
"schemaUrl": "https://opentelemetry.io/schemas/1.25.0",
"resource": {
"attributes": [{
"key": "service.name", "value": { "stringValue": "llm-gateway" }},{
"key": "deployment.environment", "value": { "stringValue": "prod" }}]},
"scopeSpans": [{
"scope": { "name": "ai.request.pipeline", "version": "2.3.0" },
"spans": [{
@keithchambers
keithchambers / setup.sh
Created April 15, 2025 19:49
Kafka Batch File Upload System
#!/bin/bash
set -e # Exit on error. Use `set -eux` for debugging to print commands and expand variables.
REPO_NAME="kafka-batch-upload"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # Get dir where setup.sh is
KAFKA_IMAGE="bitnami/kafka:3.7" # Define Kafka image once
echo "Setting up the Kafka Batch Upload project in ./${REPO_NAME}"
echo "This will create all necessary files and directories."
echo "Attempting to automate KRaft Cluster ID generation..."
@keithchambers
keithchambers / main.go
Last active April 14, 2025 16:02
OTEL Agentic Event Gen
// Package main implements a load tester for sending OpenTelemetry (OTLP) data
// via HTTP JSON or gRPC Protobuf, with an option to output generated data to a
// file instead of sending it over the network.
package main
import (
"bytes"
"context"
"crypto/tls"
"encoding/hex"
#!/bin/bash
# Create directory structure
echo "Creating project directories..."
# Replaced nginx with traefik, added traefik config dir
mkdir -p otel-kafka-clickhouse-stack/{traefik/conf,otel-collector,clickhouse-init,kafka-data,clickhouse-data}
cd otel-kafka-clickhouse-stack || exit 1 # Exit if cd fails
# Create .env file for secrets and configs
#!/usr/bin/env python3
import argparse
import logging
import numpy as np
import pandas as pd
import pyarrow.parquet as pq
from pathlib import Path
from typing import Union
import random