Sentry integration for gRPC package

package build pub likes popularity pub points
sentry_grpc build pub package likes popularity pub points

Integration for the gRPC package.

Usage

  • Sign up for a Sentry.io account and get a DSN at https://sentry.io.

  • Follow the installing instructions on pub.dev.

  • Initialize the Sentry SDK using the DSN issued by Sentry.io.

  • Call your client with the gRPC interceptor SentryGrpcInterceptor and you should get gRPC integration out of the box.

import 'package:grpc/grpc.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry_grpc/sentry_grpc.dart';

Future<void> main() async {
  await Sentry.init(
    (options) {
      options.dsn = 'https://example@sentry.io/example';
      options.tracesSampleRate = 1.0;
      options.captureFailedRequests = true;
    },
    appRunner: runApp,
  );
}

Future<void> runApp() async {
  final channel = ClientChannel(
    'api.example.com',
    options: const ChannelOptions(credentials: ChannelCredentials.secure()),
  );

  final client = MyServiceClient(
    channel,
    interceptors: [SentryGrpcInterceptor()],
  );

  // Calls are now automatically instrumented with Sentry tracing
  // and failed requests are captured as Sentry exceptions.
}

Resources

  • Flutter docs
  • Dart docs
  • Discussions
  • Discord Chat
  • Stack Overflow
  • Twitter Follow

Libraries

sentry_grpc