Skip to content

Instantly share code, notes, and snippets.

@MadVikingGod
MadVikingGod / out.txt
Last active July 3, 2024 15:07
Output of weaver json schema validation
$ weaver -V
weaver 0.4.0
$ weaver registry json-schema -o semconv.schema.json
$ go install github.com/neilpa/yajsv@latest
$ yajsv -s semconv.schema.json *.yaml
session.yaml: fail: (root): registry_url is required
session.yaml: fail: groups.0.attributes.0: brief is required
session.yaml: fail: groups.0.attributes.0: name is required
session.yaml: fail: groups.0.attributes.0: type is required
session.yaml: fail: groups.0.attributes.0: Additional property ref is not allowed
@MadVikingGod
MadVikingGod / bench-dup.txt
Created February 14, 2024 15:53
Comparision of otel benchmarks
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv
cpu: AMD EPYC 7763 64-Core Processor
BenchmarkHTTPServerRequest-2 1353092 874.0 ns/op 1540 B/op 2 allocs/op
BenchmarkHTTPServerRequest-2 1627888 735.7 ns/op 1540 B/op 2 allocs/op
BenchmarkHTTPServerRequest-2 1556690 820.0 ns/op 1540 B/op 2 allocs/op
BenchmarkHTTPServerRequest-2 1347495 752.0 ns/op 1540 B/op 2 allocs/op
BenchmarkHTTPServerRequest-2 1502954 769.7 ns/op 1540 B/op 2 allocs/op
BenchmarkHTTPServerRequest-2 1501928 816.1 ns/op 1540 B/op 2 allocs/op
@MadVikingGod
MadVikingGod / main.go
Created February 1, 2024 16:17
Self Running demo of http.Request Host behavior
package main
import (
"fmt"
"net/http"
"net/http/httptest"
)
func main() {
11:cpuset:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249ae8506/58a77afcbf0b16959d526758f6696677c862517acc97a562dc5c5b09afbf5236
10:hugetlb:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249ae8506/58a77afcbf0b16959d526758f6696677c862517acc97a562dc5c5b09afbf5236
9:pids:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249ae8506/58a77afcbf0b16959d526758f6696677c862517acc97a562dc5c5b09afbf5236
8:memory:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249ae8506/58a77afcbf0b16959d526758f6696677c862517acc97a562dc5c5b09afbf5236
7:net_cls,net_prio:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249ae8506/58a77afcbf0b16959d526758f6696677c862517acc97a562dc5c5b09afbf5236
6:perf_event:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249ae8506/58a77afcbf0b16959d526758f6696677c862517acc97a562dc5c5b09afbf5236
5:blkio:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249ae8506/58a77afcbf0b16959d526758f6696677c862517acc97a562dc5c5b09afbf5236
4:devices:/kubepods/besteffort/pod28478e30-384f-41e5-9d85-eae249a
@MadVikingGod
MadVikingGod / Error
Created November 21, 2022 21:48
Attribute test
--- FAIL: TestIncorrectCast (0.00s)
--- FAIL: TestIncorrectCast/Float64 (0.00s)
kv_test.go:169:
Error Trace: /home/aaron/projects/opentelemetry-go/attribute/kv_test.go:169
Error: func (assert.PanicTestFunc)(0x6c0e40) should not panic
Panic value: reflect: call of reflect.Value.Type on zero Value
Panic stack: goroutine 48 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x65
github.com/stretchr/testify/assert.didPanic.func1()

Metric Test Cases

This is a list of language independent test cases to help validate an SDK's behavior. It's intended to enumerate some of the interactions of different parts of the specification.

Async Counters with Attribute Filters

Instrument

Async Counter

@MadVikingGod
MadVikingGod / example.md
Created August 19, 2022 16:07
otel AssertEqual outputs

This is an example of how test data compares when using different levels of metricdatatest.AssertEqual.

Asserting at the Metrics level

var tt.want metricsdata.Metrics
var rm metricsdata.ResourceMetrics // This was from Collect()

require.Len(t, rm.ScopeMetrics, 1)
sm := rm.ScopeMetrics[0]
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
benchstat bench-old bench-new
name old time/op new time/op delta
Int64Sum/count-10-4 7.81µs ±37% 3.29µs ± 5% -57.85% (p=0.000 n=10+10)
Int64Sum/count-50-4 36.1µs ±31% 15.6µs ± 7% -56.85% (p=0.000 n=10+10)
Int64Sum/count-100-4 64.7µs ± 5% 31.0µs ± 4% -52.17% (p=0.000 n=8+10)
Float64Sum/count-10-4 8.22µs ±31% 3.50µs ± 2% -57.45% (p=0.000 n=10+10)
Float64Sum/count-50-4 36.2µs ±29% 16.6µs ± 5% -54.13% (p=0.000 n=9+10)
Float64Sum/count-100-4 69.9µs ±15% 33.3µs ± 4% -52.37% (p=0.000 n=8+10)
Int64SumParallel-4 11.4ms ±19% 0.0ms ±51% -99.59% (p=0.000 n=9+10)
Float64SumParallel-4 12.3ms ±31% 0.1ms ±60% -99.57% (p=0.000 n=10+10)
@MadVikingGod
MadVikingGod / main.go
Created June 7, 2022 15:06
example of #2946
package main
import (
"context"
"fmt"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
"go.opentelemetry.io/otel/sdk/trace"