跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Observability Instances

DefaultObservabilityInstance
defaultobservabilityinstance的直接链接

Default implementation of the ObservabilityInstance interface.

Constructor
Constructor的直接链接

new DefaultObservabilityInstance(config: ObservabilityInstanceConfig)

Creates a new DefaultObservabilityInstance with the specified configuration.

Properties
Properties的直接链接

Inherits all properties and methods from BaseObservabilityInstance.

BaseObservabilityInstance
baseobservabilityinstance的直接链接

Base class for custom ObservabilityInstance implementations.

Methods
Methods的直接链接

getConfig
getconfig的直接链接

getConfig(): Readonly<ObservabilityInstanceConfig>

Returns the current observability configuration.

getExporters
getexporters的直接链接

getExporters(): readonly ObservabilityExporter[]

Returns all configured exporters.

getSpanOutputProcessors
getspanoutputprocessors的直接链接

getSpanOutputProcessors(): readonly SpanOutputProcessor[]

Returns all configured span output processors.

getLogger
getlogger的直接链接

getLogger(): IMastraLogger

Returns the logger instance for exporters and other components.

startSpan
startspan的直接链接

startSpan<TType extends SpanType>(
options: StartSpanOptions<TType>
): Span<TType>

Start a new span of a specific SpanType. Creates the root span of a trace if no parent is provided.

shutdown
shutdown的直接链接

async shutdown(): Promise<void>

Shuts down all exporters and processors, cleaning up resources.

Custom implementation
Custom implementation的直接链接

To create a custom ObservabilityInstance implementation, extend BaseObservabilityInstance:

class CustomObservabilityInstance extends BaseObservabilityInstance {
constructor(config: ObservabilityInstanceConfig) {
super(config)
// Custom initialization
}

// Override methods as needed
startSpan<TType extends SpanType>(options: StartSpanOptions<TType>): Span<TType> {
// Custom span creation logic
return super.startSpan(options)
}
}

See also
See also的直接链接

Documentation
Documentation的直接链接

Exporters
Exporters的直接链接