Skip to main content

otel_paypal 0.1.0 copy "otel_paypal: ^0.1.0" to clipboard
otel_paypal: ^0.1.0 copied to clipboard

OpenTelemetry instrumentation for paypal by Dartastic.io. Adds standard OpenTelemetry observability to applications that use paypal.

example/main.dart

// Licensed under the Apache License, Version 2.0
// Copyright 2025-2026 Mindful Software LLC d/b/a Dartastic.io, All rights reserved.

import 'package:dartastic_opentelemetry/dartastic_opentelemetry.dart';
import 'package:otel_paypal/otel_paypal.dart';

/// Traces Paypal calls with OpenTelemetry.
///
/// `otel_paypal` depends on the OpenTelemetry API only, so the application
/// initializes an SDK once at startup. Wrap each Paypal call in
/// [tracedPaypal]; the `invoke` callback makes the real call and reports what
/// came back, which is recorded on the span.
Future<void> main() async {
  await OTel.initialize(serviceName: 'paypal-example');

  // Wraps any PayPal REST API call in a CLIENT span.
  final paypalId = await tracedPaypal<String>(
    resource: 'orders',
    action: 'create',
    orderId: 'order_8f3a2c',
    captureId: 'capture_8f3a2c',
    subscriptionId: 'subscription_8f3a2c',
    environment: 'example',
    invoke: () async {
      // Make the Paypal call here, then report what it returned.
      return 'paypal_8f3a2c';
    },
  );
  OTelLog.info('tracedPaypal returned $paypalId');

  // Calls that should not be traced, such as health checks, run inside
  // runWithoutPaypalInstrumentationAsync.
  await runWithoutPaypalInstrumentationAsync(
    () => tracedPaypal<String>(
      resource: 'orders',
      action: 'create',
      orderId: 'order_8f3a2c',
      captureId: 'capture_8f3a2c',
      subscriptionId: 'subscription_8f3a2c',
      environment: 'example',
      invoke: () async {
        return 'paypal_8f3a2c';
      },
    ),
  );

  await OTel.shutdown();
}
0
likes
160
points
0
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

OpenTelemetry instrumentation for paypal by Dartastic.io. Adds standard OpenTelemetry observability to applications that use paypal.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry_api

More

Packages that depend on otel_paypal