Documentation
¶
Overview ¶
Package telemetryservice adapts an explicit telemetry runtime to the service lifecycle.
The adapter constructs and owns its runtime. Callers select global provider registration through telemetry.Config and choose whether initialization is required or best effort. Shutdown flushes and closes the runtime once using the bounded policy implemented by telemetry.Runtime. The adapter performs no retries and exposes the concrete runtime without hiding provider APIs.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidOptions = errors.New("invalid telemetry service options")
ErrInvalidOptions identifies invalid adapter construction.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter owns one telemetry runtime and its lifecycle state.
func New ¶
New validates and constructs an inert adapter.
Example ¶
package main
import (
"context"
"fmt"
"github.com/faustbrian/go-telemetry"
"github.com/faustbrian/go-telemetry/telemetryservice"
)
func main() {
config := telemetry.DefaultConfig("orders", "1.2.3")
config.RegisterGlobal = false
config.Traces.Enabled = false
config.Metrics.Enabled = false
adapter, err := telemetryservice.New(telemetryservice.Options{
Name: "telemetry",
Config: config,
Failure: telemetryservice.FailureRequired,
})
if err != nil {
fmt.Println("adapter setup failed")
return
}
component := adapter.Component()
_ = component.Start(context.Background())
runtime, active := adapter.Runtime()
_ = component.Stop(context.Background())
fmt.Println(runtime != nil, active)
}
Output: true true
func (*Adapter) InitializationError ¶
InitializationError returns a retained best-effort initialization failure.
type FailurePolicy ¶
type FailurePolicy string
FailurePolicy selects how initialization failure affects service startup.
const ( // FailureRequired prevents service startup when telemetry initialization // fails. FailureRequired FailurePolicy = "required" // FailureBestEffort permits service startup while retaining the // initialization failure for diagnostics. FailureBestEffort FailurePolicy = "best-effort" )
type InitializationError ¶
type InitializationError struct {
// Cause is the runtime construction failure.
Cause error
}
InitializationError preserves the runtime construction failure without formatting the potentially sensitive cause.
func (*InitializationError) Error ¶
func (*InitializationError) Error() string
Error returns a secret-safe startup diagnostic.
func (*InitializationError) Unwrap ¶
func (err *InitializationError) Unwrap() error
Unwrap preserves the runtime construction failure.
type Options ¶
type Options struct {
// Name is the secret-safe component name.
Name string
// Config defines the runtime and explicitly selects global registration.
Config telemetry.Config
// RuntimeOptions provide caller-owned exporters or test facilities.
RuntimeOptions []telemetry.Option
// Failure explicitly selects required or best-effort initialization.
Failure FailurePolicy
}
Options configure one telemetry lifecycle adapter.
type OptionsError ¶
type OptionsError struct {
// Field identifies the rejected option.
Field string
// Reason describes the safe failure category.
Reason string
}
OptionsError identifies one rejected option.
func (*OptionsError) Error ¶
func (err *OptionsError) Error() string
Error returns a secret-safe construction diagnostic.
func (*OptionsError) Unwrap ¶
func (err *OptionsError) Unwrap() error
Unwrap exposes the stable option classification.