silk.trace.record.

Bounded recording of OpenTelemetry spans and their parent contexts.

Import as Recorder with import silk.trace.record { Recorder }.

Public declarations: 5.

Config#

silk
pub struct Config

The OTel resource, root sampling probability and fixed storage budget.

Field serviceName#

silk
pub serviceName: string<'static>

Value of the OpenTelemetry service.name resource attribute.

Field serviceVersion#

silk
pub serviceVersion: string<'static>

Value of service.version. An empty value omits this attribute.

Field sampleRatio#

silk
pub sampleRatio: f64

Fraction of new roots to record. Child spans inherit the parent’s sampled bit.

Field openCapacity#

silk
pub openCapacity: usize

Maximum number of sampled spans simultaneously open in the recorder.

Field threadCapacity#

silk
pub threadCapacity: usize

Number of preallocated producer pages in each signal buffer pool.

Field bufferCapacity#

silk
pub bufferCapacity: usize

Maximum records per page. A full pool counts additional observations as drops.

Implementation Copy for Config#

silk
impl Copy for Config

Implementation Config#

silk
impl Config

Associated function make#

silk
pub fn make(name: string<'static>) -> Self

Records all roots with 64 open spans and eight buffers of eight finished spans each.

SpanEvent#

silk
pub struct SpanEvent

A timed event and its captured fields.

Field name#

silk
pub name: string<'static>

The event name supplied by the instrumented code.

Field time#

silk
pub time: u64

The event time in Unix nanoseconds.

Field attributes#

silk
pub attributes: Attributes

The captured event fields.

Implementation Copy for SpanEvent#

silk
impl Copy for SpanEvent

Implementation SpanEvent#

silk
impl SpanEvent

Associated function empty#

silk
pub fn empty() -> Self

An empty event.

Span#

silk
pub struct Span

A complete span with owned attributes, events and links. Times are Unix nanoseconds.

Field context#

silk
pub context: SpanContext

Identifiers and flags of this span.

Field parent#

silk
pub parent: SpanContext

Parent identifiers and flags. A zero parent span ID denotes a root.

Field name#

silk
pub name: string<'static>

Name supplied at the span site.

Field kind#

silk
pub kind: SpanKind

The OpenTelemetry kind of this span.

Field place#

silk
pub place: Place

Source and instrumentation scope for a decorated declaration.

Field start#

silk
pub start: u64

Span start time, in Unix nanoseconds.

Field end#

silk
pub end: u64

Span completion time, in Unix nanoseconds.

Field error#

silk
pub error: bool

Whether this span ended with an error status.

Field cancelled#

silk
pub cancelled: bool

Whether cancellation closed this span.

Field errorType#

silk
pub errorType: string<'static>

Static identity of the failure type on an effect failure exit.

Field attributes#

silk
pub attributes: Attributes

Captured span attributes.

Field events#

silk
pub events: [SpanEvent; 4]

Event storage. The first eventCount elements are initialized events.

Field eventCount#

silk
pub eventCount: usize

Number of captured events.

Field droppedEvents#

silk
pub droppedEvents: u64

Number of events omitted at the per-span limit.

silk
pub links: [SpanContext; 4]

Links to other spans. Only the first linkCount entries are live.

Field linkCount#

silk
pub linkCount: usize

Number of captured links.

silk
pub droppedLinks: u64

Number of links omitted at the per-span limit.

Implementation Copy for Span#

silk
impl Copy for Span

Implementation Span#

silk
impl Span

Associated function empty#

silk
pub fn empty() -> Self

Returns an empty record with no parent, events or links.

Recorder#

silk
pub struct Recorder

Owns all recording storage. Its ambient operations reserve disjoint slots without parking.

Field signals#

silk
pub signals: SignalState

Log buffers and metric instruments shared by this recorder’s providers.

Implementation Concurrent for Recorder#

silk
impl Concurrent for Recorder

Implementation Transferable for Recorder#

silk
impl Transferable for Recorder

Implementation Recorder#

silk
impl Recorder

Associated function make#

silk
pub effect fn make(config: Config) -> Self ! OutOfMemoryError ? &mut Allocator

Allocates every recording cell and reads the clock bases and an OS random seed.

Method serviceName#

silk
pub fn serviceName(self: &Self) -> string<'static>

Returns the OTel service name of this resource.

Method serviceVersion#

silk
pub fn serviceVersion(self: &Self) -> string<'static>

Returns the OTel service version of this resource.

Method now#

silk
pub fn now(self: &Self) -> u64

Returns the current Unix nanoseconds on the recorder's monotonic time base.

Method droppedSpans#

silk
pub fn droppedSpans(self: &Self) -> u64

Returns the total number of spans lost to pool or buffer exhaustion or export failure.

Method countDroppedSpans#

silk
pub fn countDroppedSpans(self: &Self, count: u64) -> ()

Adds terminal export or recording losses to the resource's drop count.

Method takeSpan#

silk
pub fn takeSpan(self: &Self) -> Option<Span>

Takes one finished span. When a producer is writing a slot, draining skips that slot.

Implementation Meter for Recorder#

silk
impl Meter for Recorder

Operation add#

silk
effect fn add<Args>(self: &Self, static name: string<'static>, amount: u64, args: &Args) -> ()

Operation adjust#

silk
effect fn adjust<Args>(self: &Self, static name: string<'static>, amount: i64, args: &Args) -> ()

Operation gauge#

silk
effect fn gauge<Args>(self: &Self, static name: string<'static>, value: f64, args: &Args) -> ()

Operation record#

silk
effect fn record<Args>(self: &Self, static name: string<'static>, value: f64, args: &Args) -> ()

Implementation Tracer for Recorder#

silk
impl Tracer for Recorder

Operation enter#

silk
effect fn enter<Args>(self: &Self, static name: string<'static>, static kind: SpanKind, static place: Place,
    args: &Args, remote: Option<SpanContext>) -> ()

Operation exit#

silk
effect fn exit(self: &Self) -> ()

Operation cancelled#

silk
effect fn cancelled(self: &Self) -> ()

Operation failed#

silk
effect fn failed(self: &Self, static error: string<'static>) -> ()

Operation attribute#

silk
effect fn attribute<V>(self: &Self, static key: string<'static>, value: &V) -> ()

Operation recordError#

silk
effect fn recordError<V>(self: &Self, value: &V) -> ()

Operation event#

silk
effect fn event<Args>(self: &Self, static name: string<'static>, args: &Args) -> ()
silk
effect fn link(self: &Self, context: &SpanContext) -> ()

Implementation Recorder#

silk
impl Recorder

Method finishedCapacity#

silk
pub fn finishedCapacity(self: &Self) -> usize

The maximum number of completed spans the recorder can retain.

Memory#

silk
pub struct Memory

An owned collection of exported telemetry records.

Implementation Memory#

silk
impl Memory

Associated function make#

silk
pub fn make() -> Self

Creates an empty collector.

Method spans#

silk
pub fn spans(self: &Self) -> &[Span]

Borrows the spans in their drain order.

Method logs#

silk
pub fn logs(self: &Self) -> &[LogRecord]

Borrows the delivered log records.

Method metrics#

silk
pub fn metrics(self: &Self) -> &[MetricPoint]

Borrows the delivered metric snapshots.

Method appendSpans#

silk
pub effect fn appendSpans(self: &mut Self, values: &[Span]) -> () ! OutOfMemoryError ? &mut Allocator

Appends one span batch.

Method appendLogs#

silk
pub effect fn appendLogs(self: &mut Self, values: &[LogRecord]) -> () ! OutOfMemoryError ? &mut Allocator

Appends one log batch.

Method appendMetrics#

silk
pub effect fn appendMetrics(self: &mut Self, values: &[MetricPoint]) -> () ! OutOfMemoryError ? &mut Allocator

Appends one cumulative metric batch.

Method drain#

silk
pub effect fn drain(self: &mut Self, recorder: &Recorder) -> () ! OutOfMemoryError ? &mut Allocator

Collects at most one recorder capacity of completed spans, reserving space before removal.

Implementation Recorder#

silk
impl Recorder

Method flush#

silk
pub effect fn flush<E, ?R, S: Sink<E ? R>>(self: &Self, sink: &mut S) -> ()
  ! E | OutOfMemoryError ? R | &mut Allocator

Drains the current buffers to a sink, including logs and cumulative metric snapshots.

Method exportBatches#

silk
pub effect fn exportBatches<E, ?R, S: Sink<E ? R>>(self: &Self, sink: &mut S) -> ()
  ! E | OutOfMemoryError ? R | &mut Allocator | &mut MonotonicClock

Periodically flushes the recorder until cancellation or a sink failure.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.

View the source of this page