otel_loggy 0.2.0 copy "otel_loggy: ^0.2.0" to clipboard
otel_loggy: ^0.2.0 copied to clipboard

OpenTelemetry log bridge for package:loggy. Mirrors every Loggy record into the OTel logs pipeline, inheriting trace_id/span_id, while Loggy keeps rendering its own output.

otel_loggy #

OpenTelemetry log bridge for package:loggy.

Mirrors every Loggy record into the OpenTelemetry logs pipeline so structured records flow to your OTel backend while Loggy keeps rendering. Records inherit trace_id / span_id from the active span — log calls inside a Tracer.startActiveSpan block are auto-correlated.

Install #

dependencies:
  loggy: ^2.0.2
  otel_loggy: ^0.2.0

Use #

import 'package:dartastic_opentelemetry/dartastic_opentelemetry.dart';
import 'package:loggy/loggy.dart';
import 'package:otel_loggy/otel_loggy.dart';

Future<void> main() async {
  await OTel.initialize(
    serviceName: 'my-app',
  );

  Loggy.initLoggy(
    logPrinter: const OTelLoggyPrinter(),
    logOptions: const LogOptions(LogLevel.all),
  );

  logInfo('user signed in');
  logError('boom', StateError('out of stock'), StackTrace.current);
}

To also keep Loggy's own pretty-printer in the console, combine printers:

Loggy.initLoggy(
  logPrinter: const MultiPrinter([
    PrettyPrinter(),
    OTelLoggyPrinter(),
  ]),
);

Severity mapping #

Loggy LogLevel OTel severity_number
all TRACE
debug DEBUG
info INFO
warning WARN
error ERROR
off UNSPECIFIED
(other) INFO

Suppression #

runWithoutLoggyInstrumentation(() {
  logInfo('not exported to OTel');
});

License #

Apache 2.0 — copyright Mindful Software LLC.

0
likes
160
points
74
downloads

Documentation

API reference

Publisher

verified publisherdartastic.io

Weekly Downloads

OpenTelemetry log bridge for package:loggy. Mirrors every Loggy record into the OTel logs pipeline, inheriting trace_id/span_id, while Loggy keeps rendering its own output.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, loggy

More

Packages that depend on otel_loggy