mirror of
https://github.com/hanzoai/ingress.git
synced 2026-10-20 15:07:40 +00:00
feat(logs): ingress logs ship over ZAP
NewLoggerProvider refused, because the only way to push logs was OTLP and OTLP carries protobuf and gRPC on either flavour. luxfi/log v1.6.0 added the third wire — a JSON LogBatch in a ZAP envelope, MsgLogBatch = 3 — so that sentence is no longer true and the refusal is replaced by the real exporter. Traces, metrics and logs now all leave this binary the same way.
This commit is contained in:
@@ -71,10 +71,10 @@ require (
|
||||
go.opentelemetry.io/contrib/bridges/otellogrus v0.13.0
|
||||
go.opentelemetry.io/contrib/propagators/autoprop v0.63.0
|
||||
go.opentelemetry.io/otel v1.44.0
|
||||
go.opentelemetry.io/otel/log v0.15.0
|
||||
go.opentelemetry.io/otel/log v0.20.0
|
||||
go.opentelemetry.io/otel/metric v1.44.0
|
||||
go.opentelemetry.io/otel/sdk v1.44.0
|
||||
go.opentelemetry.io/otel/sdk/log v0.14.0
|
||||
go.opentelemetry.io/otel/sdk/log v0.20.0
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0
|
||||
go.opentelemetry.io/otel/trace v1.44.0
|
||||
golang.org/x/crypto v0.52.0
|
||||
@@ -104,7 +104,7 @@ require (
|
||||
|
||||
require (
|
||||
github.com/hanzos3/go-sdk v1.0.2
|
||||
github.com/luxfi/log v1.4.3
|
||||
github.com/luxfi/log v1.6.0
|
||||
github.com/luxfi/metric v1.9.0
|
||||
github.com/luxfi/trace v1.4.0
|
||||
github.com/luxfi/zap v1.2.6
|
||||
|
||||
@@ -857,8 +857,8 @@ github.com/luxfi/accel v1.2.4 h1:5VbIHyEvvfobn2zBiTFODxDw1CeqxCepZOLlvkuf9yQ=
|
||||
github.com/luxfi/accel v1.2.4/go.mod h1:ISIwAX+ZfsL/S5nsP2JvfldXN6Nc+QzoWf6Jtaq+xsQ=
|
||||
github.com/luxfi/crypto v1.20.2 h1:L81WEsU/hs2A76F5PWBusG0yU74QqkDdUqqgexWUxh4=
|
||||
github.com/luxfi/crypto v1.20.2/go.mod h1:qYHOM0lO4PRh7LEaObxFQUIMjmT1/paVm/WgZkobT1k=
|
||||
github.com/luxfi/log v1.4.3 h1:xkUKRWvQ4ZwvlUC2e0/RTtHYZOYSMvSQ9W9lbjwBmiI=
|
||||
github.com/luxfi/log v1.4.3/go.mod h1:myIkufyiQomSQH34K981kbz6cG4WUoerRUh7F4XhlQI=
|
||||
github.com/luxfi/log v1.6.0 h1:BbV7kOAK9nrUcrpr4/yCw0ODaBtQOLR5Cjj/NLWwZqo=
|
||||
github.com/luxfi/log v1.6.0/go.mod h1:NWkRRwwXPPphCUwC0+UemY0eoedQEFmhSIZXTxdA9VQ=
|
||||
github.com/luxfi/mdns v0.1.1 h1:g2eRr9AXcziPkkcd24M+Qu9ApEpoKKjfI79QSNqv0rQ=
|
||||
github.com/luxfi/mdns v0.1.1/go.mod h1:dbp5f3h3aE7CGzwbaWzBM9cwdcekhmSrWhQevgYhhNA=
|
||||
github.com/luxfi/metric v1.9.0 h1:lBWO3EkE6jqUs3zHa5iySxsuoa0K53O0aZkS5LTfTJU=
|
||||
@@ -1410,8 +1410,8 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 h1:88Y4s2C8oTui1LGM6bT
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0/go.mod h1:Vl1/iaggsuRlrHf/hfPJPvVag77kKyvrLeD10kpMl+A=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 h1:3iZJKlCZufyRzPzlQhUIWVmfltrXuGyfjREgGP3UUjc=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0/go.mod h1:/G+nUPfhq2e+qiXMGxMwumDrP5jtzU+mWN7/sjT2rak=
|
||||
go.opentelemetry.io/otel/log v0.15.0 h1:0VqVnc3MgyYd7QqNVIldC3dsLFKgazR6P3P3+ypkyDY=
|
||||
go.opentelemetry.io/otel/log v0.15.0/go.mod h1:9c/G1zbyZfgu1HmQD7Qj84QMmwTp2QCQsZH1aeoWDE4=
|
||||
go.opentelemetry.io/otel/log v0.20.0 h1:/5i0vuHxCLWUfChWG41K9wkM0jafruPw9NU1/RCJirs=
|
||||
go.opentelemetry.io/otel/log v0.20.0/go.mod h1:wOcMcjsZpG8x7Bak7IhSi/lg8wscV2C1VdrKCLPlt0E=
|
||||
go.opentelemetry.io/otel/log/logtest v0.14.0 h1:BGTqNeluJDK2uIHAY8lRqxjVAYfqgcaTbVk1n3MWe5A=
|
||||
go.opentelemetry.io/otel/log/logtest v0.14.0/go.mod h1:IuguGt8XVP4XA4d2oEEDMVDBBCesMg8/tSGWDjuKfoA=
|
||||
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
|
||||
@@ -1420,8 +1420,8 @@ go.opentelemetry.io/otel/metric/x v0.66.0 h1:YkCrx1zLOChi9ZcZ6euupOcsgzbVlec7D/x
|
||||
go.opentelemetry.io/otel/metric/x v0.66.0/go.mod h1:d1+BDj9t96do0/1LoU1ayfCv79ZgNE41qbhBvnMOBZk=
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=
|
||||
go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=
|
||||
go.opentelemetry.io/otel/sdk/log v0.14.0 h1:JU/U3O7N6fsAXj0+CXz21Czg532dW2V4gG1HE/e8Zrg=
|
||||
go.opentelemetry.io/otel/sdk/log v0.14.0/go.mod h1:imQvII+0ZylXfKU7/wtOND8Hn4OpT3YUoIgqJVksUkM=
|
||||
go.opentelemetry.io/otel/sdk/log v0.20.0 h1:vM3xI7TQgKPiSghe6urZtAkyFY7SodrSpC83CffDFuY=
|
||||
go.opentelemetry.io/otel/sdk/log v0.20.0/go.mod h1:Knej2nmsTUzN79T2eeXdRsjjPcoxoq2pUyUHz9TFyyU=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
|
||||
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
luxlog "github.com/luxfi/log"
|
||||
"context"
|
||||
"github.com/hanzoai/ingress-parser/types"
|
||||
otelsdk "go.opentelemetry.io/otel/sdk/log"
|
||||
@@ -154,13 +157,38 @@ func (o *OTelLog) SetDefaults() {
|
||||
}
|
||||
|
||||
// NewLoggerProvider creates a new OpenTelemetry logger provider.
|
||||
func (o *OTelLog) NewLoggerProvider(ctx context.Context) (*otelsdk.LoggerProvider, error) {
|
||||
// Logs have no ZAP wire. Traces ride MsgSpanBatch and metrics ride the
|
||||
// MetricFamily batch, but nothing on the o11y side receives a log batch, so
|
||||
// the only way to push logs from here was OTLP — and OTLP carries protobuf
|
||||
// and gRPC on either flavour. ingress writes to stdout; the platform
|
||||
// collects it. Refuse rather than pretend to ship.
|
||||
return nil, errors.New("otel log export is not available: no ZAP log wire exists — ingress logs to stdout")
|
||||
func (o *OTelLog) NewLoggerProvider(_ context.Context) (*otelsdk.LoggerProvider, error) {
|
||||
// ZAP carries a JSON LogBatch to o11y/pkg/zaplogreceiver. The endpoint is
|
||||
// host:port — a scheme or path means nothing on this wire, so a URL-shaped
|
||||
// config value from the OTLP era is reduced to its host.
|
||||
endpoint := ""
|
||||
switch {
|
||||
case o.GRPC != nil && o.GRPC.Endpoint != "":
|
||||
endpoint = o.GRPC.Endpoint
|
||||
case o.HTTP != nil:
|
||||
endpoint = o.HTTP.Endpoint
|
||||
}
|
||||
endpoint = strings.TrimPrefix(strings.TrimPrefix(endpoint, "https://"), "http://")
|
||||
if i := strings.IndexByte(endpoint, '/'); i >= 0 {
|
||||
endpoint = endpoint[:i]
|
||||
}
|
||||
|
||||
serviceName := o.ServiceName
|
||||
if serviceName == "" {
|
||||
serviceName = OTelIngressServiceName
|
||||
}
|
||||
|
||||
exporter, err := luxlog.NewZAPExporter(luxlog.ZAPExporterConfig{
|
||||
Endpoint: endpoint,
|
||||
AppName: serviceName,
|
||||
Resource: o.ResourceAttributes,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("creating log exporter: %w", err)
|
||||
}
|
||||
return otelsdk.NewLoggerProvider(
|
||||
otelsdk.WithProcessor(otelsdk.NewBatchProcessor(exporter)),
|
||||
), nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user