mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-24 00:42:18 +00:00
✨ add wasm coverage and trace context
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
---
|
||||
name: async-logger-with-trace-context
|
||||
group: api
|
||||
category: async
|
||||
update-time: 20260719
|
||||
description: Bind TraceContext fields before records enter an AsyncLogger queue.
|
||||
key-word:
|
||||
- async
|
||||
- trace
|
||||
- context
|
||||
---
|
||||
|
||||
## Async-logger-with-trace-context
|
||||
|
||||
```moonbit
|
||||
let contextual = logger.with_trace_context(
|
||||
@bitlogger.trace_context("trace-1", "span-1"),
|
||||
)
|
||||
```
|
||||
|
||||
The helper stores the mapped fields on the returned async logger and preserves its queue, lifecycle, target, and threshold state. Context is added before records are enqueued.
|
||||
@@ -31,6 +31,7 @@ BitLogger API navigation.
|
||||
- [logger-with-timestamp.md](./logger-with-timestamp.md)
|
||||
- [logger-with-context-fields.md](./logger-with-context-fields.md)
|
||||
- [logger-bind.md](./logger-bind.md)
|
||||
- [logger-with-trace-context.md](./logger-with-trace-context.md)
|
||||
- [logger-with-filter.md](./logger-with-filter.md)
|
||||
- [logger-with-patch.md](./logger-with-patch.md)
|
||||
- [logger-with-queue.md](./logger-with-queue.md)
|
||||
@@ -99,6 +100,10 @@ BitLogger API navigation.
|
||||
- [fields.md](./fields.md)
|
||||
- [text-formatter-config-type.md](./text-formatter-config-type.md)
|
||||
|
||||
## Observability
|
||||
|
||||
- [trace-context.md](./trace-context.md)
|
||||
|
||||
## Record and level
|
||||
|
||||
- [record.md](./record.md)
|
||||
@@ -266,6 +271,7 @@ BitLogger API navigation.
|
||||
- [async-logger-with-min-level.md](./async-logger-with-min-level.md)
|
||||
- [async-logger-with-timestamp.md](./async-logger-with-timestamp.md)
|
||||
- [async-logger-with-context-fields.md](./async-logger-with-context-fields.md)
|
||||
- [async-logger-with-trace-context.md](./async-logger-with-trace-context.md)
|
||||
- [async-logger-with-filter.md](./async-logger-with-filter.md)
|
||||
- [async-logger-with-patch.md](./async-logger-with-patch.md)
|
||||
|
||||
@@ -322,6 +328,7 @@ BitLogger API navigation.
|
||||
- [library-logger-child.md](./library-logger-child.md)
|
||||
- [library-logger-with-context-fields.md](./library-logger-with-context-fields.md)
|
||||
- [library-logger-bind.md](./library-logger-bind.md)
|
||||
- [library-logger-with-trace-context.md](./library-logger-with-trace-context.md)
|
||||
- [library-logger-is-enabled.md](./library-logger-is-enabled.md)
|
||||
- [library-logger-log.md](./library-logger-log.md)
|
||||
- [library-logger-info.md](./library-logger-info.md)
|
||||
@@ -341,6 +348,7 @@ BitLogger API navigation.
|
||||
- [library-async-logger-child.md](./library-async-logger-child.md)
|
||||
- [library-async-logger-with-context-fields.md](./library-async-logger-with-context-fields.md)
|
||||
- [library-async-logger-bind.md](./library-async-logger-bind.md)
|
||||
- [library-async-logger-with-trace-context.md](./library-async-logger-with-trace-context.md)
|
||||
- [library-async-logger-is-enabled.md](./library-async-logger-is-enabled.md)
|
||||
- [library-async-logger-log.md](./library-async-logger-log.md)
|
||||
- [library-async-logger-info.md](./library-async-logger-info.md)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
name: library-async-logger-with-trace-context
|
||||
group: api
|
||||
category: facade
|
||||
update-time: 20260719
|
||||
description: Bind TraceContext fields through the restricted LibraryAsyncLogger facade.
|
||||
key-word:
|
||||
- library
|
||||
- async
|
||||
- trace
|
||||
---
|
||||
|
||||
## Library-async-logger-with-trace-context
|
||||
|
||||
`LibraryAsyncLogger::with_trace_context(...)` returns a derived library facade with `trace_id`, `span_id`, `trace_flags`, and optional `trace_state` attached to each later record. It does not start a worker or change lifecycle state.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: library-logger-with-trace-context
|
||||
group: api
|
||||
category: facade
|
||||
update-time: 20260719
|
||||
description: Bind TraceContext fields through the restricted LibraryLogger facade.
|
||||
key-word:
|
||||
- library
|
||||
- trace
|
||||
- context
|
||||
---
|
||||
|
||||
## Library-logger-with-trace-context
|
||||
|
||||
```moonbit
|
||||
let logger = LibraryLogger::new(console_sink())
|
||||
.with_trace_context(trace_context("trace-1", "span-1"))
|
||||
```
|
||||
|
||||
The derived facade preserves its library-facing API while wrapping the sink with context fields. Use `to_logger()` only when broader composition is required.
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: logger-with-trace-context
|
||||
group: api
|
||||
category: logger
|
||||
update-time: 20260719
|
||||
description: Bind a TraceContext to every record from a synchronous Logger.
|
||||
key-word:
|
||||
- logger
|
||||
- trace
|
||||
- context
|
||||
---
|
||||
|
||||
## Logger-with-trace-context
|
||||
|
||||
```moonbit
|
||||
pub fn[S] Logger::with_trace_context(
|
||||
self : Logger[S],
|
||||
context : TraceContext,
|
||||
) -> Logger[ContextSink[S]]
|
||||
```
|
||||
|
||||
Returns a derived logger that prepends the context fields to every record. The original logger is unchanged. This is equivalent to `with_context_fields(context.as_fields())`, while making trace intent explicit.
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: trace-context
|
||||
group: api
|
||||
category: observability
|
||||
update-time: 20260719
|
||||
description: Represent and bind distributed trace metadata using stable structured-log fields.
|
||||
key-word:
|
||||
- trace
|
||||
- context
|
||||
- observability
|
||||
---
|
||||
|
||||
## Trace-context
|
||||
|
||||
`TraceContext` carries the standard log fields used to correlate records with distributed traces: `trace_id`, `span_id`, `trace_flags`, and optional `trace_state`.
|
||||
|
||||
```moonbit
|
||||
let context = trace_context(
|
||||
"4bf92f3577b34da6a3ce929d0e0e4736",
|
||||
"00f067aa0ba902b7",
|
||||
trace_state="vendor=value",
|
||||
)
|
||||
```
|
||||
|
||||
Use `context.as_fields()` when integrating with a custom carrier, or pass the value to a logger's `with_trace_context(...)` helper. BitLogger does not parse HTTP headers or export OTLP data; an application-owned tracing library remains responsible for propagation and sampling.
|
||||
Reference in New Issue
Block a user