Skip to content

Instantly share code, notes, and snippets.

View jessitron's full-sized avatar
🚀
"I'm in"

Jessica Kerr jessitron

🚀
"I'm in"
View GitHub Profile
@jessitron
jessitron / dataset-name.sh
Created October 4, 2024 03:39
Add a column for dataset name. Requires 'jq' and 'curl', and HONEYCOMB_API_KEY set to a configuration key with 'Manage columns' perm
#!/bin/bash
# create a derived column called 'dc.dataset' in each dataset, containing the name of the dataset.
# Then, query in Honeycomb: all datasets, count, group by dc.dataset
# and find out where they are!
# set -x
# Check if HONEYCOMB_API_KEY is set
if [ -z "$HONEYCOMB_API_KEY" ]; then
@jessitron
jessitron / self-updating-version.sh
Created June 16, 2024 20:16
updating the version number after the deploy, by editing the deploy script
#!/bin/sh
# do something with a version number, and then increment the version number in this script.
# Is this a good idea? No claims made.
set -e # exit on fail
set -x # print what you're doing
me=$0 # name of this script
@jessitron
jessitron / collector_config_with_attribution.yaml
Last active February 16, 2024 17:46
An OpenTelemetry collector configuration that adds attributes to each telemetry event, saying which receiver and collector it came through. For this post: https://opentelemetryinpractice.net/collector-best-practices-where-did-this-telemetry-come-from/
exporters:
otlp:
endpoint: api.honeycomb.io:443
headers:
x-honeycomb-team: ${HONEYCOMB_API_KEY}
otlp/logging:
endpoint: api.honeycomb.io:443
headers:
x-honeycomb-dataset: all-the-logs
x-honeycomb-team: ${HONEYCOMB_API_KEY}
@jessitron
jessitron / test_otel_baggage.ts
Created January 1, 2024 18:21
Setting baggage replaces baggage
/* I read the docs on getting started with Jest and TypeScript, and fuck it, I just want to run some code */
import { context, Context, propagation, Baggage, BaggageEntry } from "@opentelemetry/api";
// I don't feel like getting TypeScript to realize it has the Node assert method in scope
function assert(test: boolean) {
if (!test) {
throw new Error();
}
}
@jessitron
jessitron / sample-span.json
Created September 9, 2023 15:51
Minimal OTLP trace span, useful for testing connectivity.
{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "otel-test-pod"
}
# This bucket is for putting ALB logs into
# If the bucket already exists, add it to your state like this:
# terraform import aws_s3_bucket.alb_log_bucket otel-demo-alb-access-logs
resource "aws_s3_bucket" "alb_log_bucket" {
bucket = "otel-demo-alb-access-logs"
tags = {
Notes = "debug 502s from the collector endpoint"
}
}
@jessitron
jessitron / CoreWebVitals.ts
Last active March 26, 2023 21:39
OpenTelemetry instrumentation for JavaScript in the Browser: it sends a trace with a span for each CWV (Core Web Vitals) metric. By Purvi Kanal
import { onFID, onLCP, onCLS, onINP, onTTFB } from 'web-vitals'; // you'll need to install this
import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
import { trace, context } from '@opentelemetry/api';
import { hrTime } from '@opentelemetry/core';
export class WebVitalsInstrumentation extends InstrumentationBase {
constructor() {
super('web-vitals-instrumentation', 'v0.1.0');
}
protected init(): void | InstrumentationModuleDefinition<any> | InstrumentationModuleDefinition<any>[] {
@jessitron
jessitron / values.yaml
Created July 8, 2022 18:04
Configure the opentelemetry-collector helm chart to receive traces from a front end and send them to Honeycomb
mode: deployment
config:
exporters:
otlp/honeycomb:
endpoint: api.honeycomb.io:443
headers:
"x-honeycomb-team": YOUR-HONEYCOMB-API-KEY-HERE
logging:
loglevel: debug
@jessitron
jessitron / package.json
Created June 2, 2022 23:03
Send Node.js instrumentation to Honeycomb
{ ...
"dependencies": {
"@grpc/grpc-js": "^1.5.7",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/core": "^1.1.1",
"@opentelemetry/exporter-trace-otlp-grpc": "^0.27.0",
"@opentelemetry/instrumentation": "^0.27.0",
"@opentelemetry/instrumentation-express": "^0.28.0",
"@opentelemetry/instrumentation-http": "^0.27.0",
"@opentelemetry/resources": "^1.1.1",
@jessitron
jessitron / fix-stderr.ps1
Last active March 17, 2021 20:28
Unwrapping STDERR in Powershell
<#
.Synopsis
STDERR strings get wrapped in an ErrorRecord. Unwrap those back into strings.
#>
function Convert-StderrString {
# Why can this not be an advanced function with [CmdletBinding()] ?
# Somehow it doesn't work if I put that in.