observability

package
v0.0.0-...-1a39f93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package observability provides unified observability initialization for Go platform According to SPEC.md: "統一可觀察性系統(Console、Prometheus、OTLP 導出器)" "應用端僅輸出 OTLP 至 Alloy/Collector;憑證與 API Key 僅配置於 Alloy"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMeter

func GetMeter(name string) metric.Meter

GetMeter returns a meter for the Go platform with standard naming

func GetTracer

func GetTracer(name string) trace.Tracer

GetTracer returns a tracer for the Go platform with standard naming

func InitFromConfig

func InitFromConfig(cfg interface{}) (func(), error)

InitFromConfig initializes unified observability according to SPEC.md requirements - Single OTLP exporter endpoint (to Alloy/Collector) - JSON structured logs to stdout (collected by Alloy) - Resource attributes as required by SPEC.md

func TraceFields

func TraceFields(ctx context.Context) []zap.Field

TraceFields 會從 context 擷取目前 Span 的 trace_id/span_id,並以 zap 欄位回傳。 用法:otelzap.Ctx(ctx).Info("handled", TraceFields(ctx)...)

Types

type LoggerClose

type LoggerClose func() error

func InitZapLoggerToFile

func InitZapLoggerToFile(path string) (*otelzap.Logger, LoggerClose, error)

InitZapLoggerToFile 建議在 process 啟動時呼叫一次 path 例如: ./var/log/detectviz/detectviz.log 說明: - 採用 zap ConsoleEncoder(非 JSON),輸出格式接近 Alloy:ts level caller msg key=value ... - 仍使用 lumberjack 進行檔案輪轉,並雙寫至 stdout,供 Alloy file tail 轉發至雲端。 - 自動建立必要的目錄結構

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL