Skip to content

Instantly share code, notes, and snippets.

View codefromthecrypt's full-sized avatar

Adrian Cole codefromthecrypt

View GitHub Profile
@codefromthecrypt
codefromthecrypt / main.py
Last active March 13, 2025 03:21
OpenAI Agents SDK with LogFire
import os
import httpx
import logfire
from agents import Agent, ModelSettings, OpenAIProvider, RunConfig, Runner, function_tool
from agents.tracing import GLOBAL_TRACE_PROVIDER
# Shut down the global tracer as it sends to the OpenAI "/traces/ingest"
# endpoint, which we aren't using and doesn't exist on alternative backends
# like Ollama.
#!/bin/sh
set -e
# guess OS_TYPE if not provided
if [ -z "$OS_TYPE" ]; then
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
cygwin_nt*|mingw*|msys_nt*)
OS_TYPE="windows"
;;
linux*)
@codefromthecrypt
codefromthecrypt / Dockerfile
Last active March 6, 2025 08:50
Elastic Distribution of OpenTelemetry (EDOT) .NET Automatic Instrumentation in Docker
ARG DOTNET_VERSION=9.0
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-alpine AS edot
ARG EDOT_VERSION=1.0.0-beta.1
ARG EDOT_INSTALL=https://github.com/elastic/elastic-otel-dotnet/releases/download/${EDOT_VERSION}/elastic-dotnet-auto-install.sh
ENV OTEL_DOTNET_AUTO_HOME=/edot
WORKDIR /edot
RUN sh -c "$(curl -fsSL ${EDOT_INSTALL})"
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-alpine AS app
@codefromthecrypt
codefromthecrypt / try-otel-openai-python.md
Created February 18, 2025 03:21
how to test a change not yet in otel openai python

Check out the PR branch, then update the tree of deps in one of the examples like this in requirements.txt

openai~=1.63.2

opentelemetry-api@git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-api&subdirectory=opentelemetry-api
opentelemetry-sdk@git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
opentelemetry-semantic-conventions@git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
opentelemetry-proto@git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-proto&subdirectory=opentelemetry-proto
opentelemetry-exporter-otlp-proto-common@git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-exporter-otlp-proto-common&subdirectory=exporter/opentelemetry-exporter-otlp-proto-common
@codefromthecrypt
codefromthecrypt / re-export.wat
Created June 2, 2023 00:05
work around for weird ABI that expect the host to export memory
(module $env
;; import and re-export logstr. the exported function has the same signature
;; and passes the parameters via local.get 0..n
(import "host" "logstr" (func $logstr (param i32)))
(func (export "logstr") (param i32)
(call $logstr (local.get 0)))
(memory (export "memory") 1)
)
karmem api;
struct ManagedFieldData table {
ApiVersion []char;
FieldsType []char;
Manager []char;
Operation []char;
@codefromthecrypt
codefromthecrypt / table.cc
Last active November 27, 2022 06:25
emscripten code which uses a wasm function table
#include <stdlib.h>
/* define a dynamic function */
int (*dynamicInt)();
/* import a function from the host */
extern int hostInt();
/* assign it to the next table offset (0) */
int (*hostIntPtr)() = &hostInt;
From https://github.com/tetratelabs/wazero/runs/6473296164?check_suite_focus=true
BenchmarkAllocation/Call-16
wazero-compiler 14039.84 ns/op
wasmedge 264615.55 ns/op
BenchmarkFactorial/Call-16
wazero-compiler 1600.76 ns/op
wasmedge 14359.72 ns/op
BenchmarkAllocation/Compile-2 3293992 358.9 ns/op
BenchmarkAllocation/Instantiate-2 391 3081906 ns/op
@codefromthecrypt
codefromthecrypt / main.go
Last active February 5, 2023 12:57
wazero devops win
package main
import (
"context"
_ "embed"
"fmt"
"log"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
@codefromthecrypt
codefromthecrypt / Snark.java
Created July 9, 2020 02:12
snarking on otel's tracer v0.6
import io.opentelemetry.common.AttributeValue;
import io.opentelemetry.exporters.logging.LoggingSpanExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
// This shows how you can add attributes to a span and print it to console using Java's logger.
//
// $ java -cp snark.jar Snark