littlefish_monitoring_sentry 1.2.0
littlefish_monitoring_sentry: ^1.2.0 copied to clipboard
The project for littlefish monitoring implementation of sentry performance monitoring
littlefish_monitoring_sentry #
The Sentry implementation of the littlefish monitoring package for performance monitoring and tracing.
Features #
- Performance tracing via Sentry transactions and spans
- HTTP request monitoring
- Custom trace attributes and metrics
Getting Started #
Add this package to your pubspec.yaml:
dependencies:
littlefish_monitoring_sentry: ^1.0.0
Usage #
import 'package:littlefish_monitoring_sentry/sentry_monitoring_service.dart';
// Initialize the service
final monitoringService = SentryMonitoringService();
await monitoringService.initailize(
settings: MonitoringSettings(
enabled: true,
mode: TraceMode.both,
),
);
// Create a trace
final trace = await monitoringService.createTrace(name: 'my_operation');
await trace.start();
// ... perform operation ...
await trace.stop();
// Create an HTTP trace
final httpMetric = await monitoringService.createHttpTrace(
name: 'api_call',
url: 'https://api.example.com/data',
method: MonitoringHttpMethod.GET,
);
await httpMetric.start();
// ... make HTTP request ...
httpMetric.setHttpResponseCode(200);
await httpMetric.stop();
Note #
Sentry must be initialized before using this service. You can either:
- Initialize Sentry via
littlefish_observability_sentryfirst - Initialize Sentry directly in your application using
SentryFlutter.init()
If Sentry is not initialized, the service will mark itself as not ready and tracing operations will be skipped.