alot more changes
Build and Publish / Metadata (push) Successful in 8s
Build and Publish / BuildAndDeployAmd64 (push) Failing after 36s

This commit is contained in:
mats committed 2026-09-21 18:59:13 +02:00
1 parent 23243ddbdc
commit 0ed2935f04
40 files changed
+2889 -115

No files matched your search

+52 -3
View File
@@ -22,6 +22,7 @@ import (
"git.tornberg.me/go-otel/internal/websocket"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
@@ -42,6 +43,7 @@ type Collector struct {
ingestLimiter *ipRateLimiter
ingestKey string
sourceMapKey string
notifyIssuesFn func()
@@ -49,6 +51,7 @@ type Collector struct {
// The stats endpoints return 501 when it's nil so the UI can hide those
// views instead of erroring.
statsQuerier storage.StatsQuerier
sourceIPs storage.SourceIPQuerier
sourceMaps *sourcemaps.Resolver
kubeWatcher *kube.Watcher
prometheus *prometheus.Client
@@ -111,6 +114,9 @@ func (c *Collector) SetIngestKey(key string) {
c.ingestKey = key
}
// SetSourceMapKey sets the shared key required to upload source maps.
func (c *Collector) SetSourceMapKey(key string) { c.sourceMapKey = key }
// HoneypotRecorder receives suspicious request observations extracted from
// telemetry. It is intentionally a small interface so the collector does not
// depend on the HTTP honeypot implementation.
@@ -390,7 +396,9 @@ func (c *Collector) ConsumeTraces(ctx context.Context, td ptrace.Traces) error {
Data: buf,
}
c.broadcaster.Broadcast(&entry)
if c.broadcaster != nil {
c.broadcaster.Broadcast(&entry)
}
return nil
}
@@ -411,7 +419,9 @@ func (c *Collector) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) erro
Data: buf,
}
c.broadcaster.Broadcast(&entry)
if c.broadcaster != nil {
c.broadcaster.Broadcast(&entry)
}
return nil
}
@@ -436,11 +446,50 @@ func (c *Collector) ConsumeLogs(ctx context.Context, ld plog.Logs) error {
Data: buf,
}
c.broadcaster.Broadcast(&entry)
if c.broadcaster != nil {
c.broadcaster.Broadcast(&entry)
}
return nil
}
// EmitInternalLog records a diagnostic generated by this server as an OTLP
// log. Keeping these in the same pipeline as customer telemetry makes deploy
// and ingestion problems visible in the UI's Logs view. Values are deliberately
// limited to scalar attributes so callers cannot accidentally attach payloads.
func (c *Collector) EmitInternalLog(ctx context.Context, severity plog.SeverityNumber, body string, attrs map[string]any, traceID pcommon.TraceID, spanID pcommon.SpanID) error {
logs := plog.NewLogs()
rl := logs.ResourceLogs().AppendEmpty()
rl.Resource().Attributes().PutStr("service.name", "go-otel")
rl.Resource().Attributes().PutStr("telemetry.sdk.name", "go-otel-internal")
sl := rl.ScopeLogs().AppendEmpty()
sl.Scope().SetName("git.tornberg.me/go-otel/internal")
record := sl.LogRecords().AppendEmpty()
record.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
record.SetObservedTimestamp(pcommon.NewTimestampFromTime(time.Now()))
record.SetSeverityNumber(severity)
record.Body().SetStr(body)
if !traceID.IsEmpty() {
record.SetTraceID(traceID)
}
if !spanID.IsEmpty() {
record.SetSpanID(spanID)
}
for key, value := range attrs {
switch value := value.(type) {
case string:
record.Attributes().PutStr(key, value)
case int:
record.Attributes().PutInt(key, int64(value))
case int64:
record.Attributes().PutInt(key, value)
case bool:
record.Attributes().PutBool(key, value)
}
}
return c.ConsumeLogs(ctx, logs)
}
// Capabilities returns the capabilities of the collector.
func (c *Collector) Capabilities() consumer.Capabilities {
return consumer.Capabilities{MutatesData: false}