obsx

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 4 Imported by: 0

README

obsx 包 Package

obsx 提供 logger、metrics、tracer 的无操作契约和敏感字符串遮蔽值。

The package defines boundaries for observability without importing a concrete logging or metrics framework.

Documentation

Overview

Package obsx 定义观测接口和脱敏工具,不绑定具体日志或指标 SDK。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Key   string
	Value any
}

type Logger

type Logger interface {
	Debug(context.Context, string, ...Field)
	Info(context.Context, string, ...Field)
	Warn(context.Context, string, ...Field)
	Error(context.Context, string, ...Field)
}

type Metrics

type Metrics interface {
	Count(context.Context, string, int64, ...Field)
	Observe(context.Context, string, float64, ...Field)
}

type NoopLogger

type NoopLogger struct{}

func (NoopLogger) Debug

func (NoopLogger) Debug(context.Context, string, ...Field)

func (NoopLogger) Error

func (NoopLogger) Error(context.Context, string, ...Field)

func (NoopLogger) Info

func (NoopLogger) Info(context.Context, string, ...Field)

func (NoopLogger) Warn

func (NoopLogger) Warn(context.Context, string, ...Field)

type NoopMetrics

type NoopMetrics struct{}

func (NoopMetrics) Count

func (NoopMetrics) Observe

func (NoopMetrics) Observe(context.Context, string, float64, ...Field)

type NoopSpan

type NoopSpan struct{}

func (NoopSpan) End

func (NoopSpan) End()

func (NoopSpan) RecordError

func (NoopSpan) RecordError(_ error)

func (NoopSpan) SetFields

func (NoopSpan) SetFields(...Field)

type NoopTracer

type NoopTracer struct{}

func (NoopTracer) Start

func (NoopTracer) Start(ctx context.Context, _ string, _ ...Field) (context.Context, Span)

type Sanitizer

type Sanitizer interface{ Sanitize() string }

Sanitizer 定义敏感数据脱敏接口。 实现应确保 Sanitize() 返回脱敏后的安全表示,不泄露原始值。

type SecretString

type SecretString string

func NewSecretString

func NewSecretString(value string) SecretString
Example
package main

import (
	"github.com/ZoneCNH/kernel/obsx"
)

func main() {
	secret := obsx.NewSecretString("token")
	_ = secret.Sanitize()
}

func (SecretString) Format added in v0.8.0

func (s SecretString) Format(state fmt.State, verb rune)

func (SecretString) GoString added in v0.8.0

func (s SecretString) GoString() string

func (SecretString) IsZero

func (s SecretString) IsZero() bool

func (SecretString) MarshalJSON

func (s SecretString) MarshalJSON() ([]byte, error)

func (SecretString) Reveal

func (s SecretString) Reveal() string

func (SecretString) Sanitize

func (s SecretString) Sanitize() string

func (SecretString) String

func (s SecretString) String() string

type Span

type Span interface {
	End()
	RecordError(error)
	SetFields(...Field)
}

type Tracer

type Tracer interface {
	Start(context.Context, string, ...Field) (context.Context, Span)
}

Jump to

Keyboard shortcuts

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