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

Flutter plugin for the Elastic Distribution of OpenTelemetry (EDOT) mobile Agents.

example/README.md

inoxth_edot_flutter examples #

Two steps: start the plugin, then hand MaterialApp the observer. Everything after that - spans, logs, metrics, traced requests - is tagged with the screen it came from without any further wiring.

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:inoxth_edot_flutter/inoxth_edot_flutter.dart';

// Wraps the client the app already uses; a plain one here.
final client = EdotHttpClient(http.Client());

Future<void> main() async {
  await Edot.start(
    EdotConfig(
      serviceName: 'my-app',
      serviceVersion: '1.0.0',
      deploymentEnvironment: 'development',
      serverUrl: 'http://localhost:4318',
      // Every request through the client above is traced. This decides which of
      // them also carry W3C Trace Context, so the service on the other end can
      // join the trace.
      tracePropagationTargets: [RegExp(r'^https://api\.example\.com')],
    ),
  );

  runApp(const ExampleApp());
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // Screen Spans, and the screen attributes every other signal is tagged
      // with, come from this observer.
      navigatorObservers: [EdotNavigatorObserver()],
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              Edot.log(EdotSeverity.info, 'Order list opened');
              await client.get(Uri.https('api.example.com', '/orders'));
            },
            child: const Text('Send a traced request'),
          ),
        ),
      ),
    );
  }
}

That button produces a log record and one client span named GET, both carrying the Elastic Mobile Attribute Set and the attributes of whichever screen was visible at the time.

package:http is your dependency. EdotHttpClient wraps an http.Client, so add http to your own pubspec.yaml to construct one. If the app uses Dio instead, add inoxth_edot_flutter_dio and skip this.

Nothing emitted before Edot.start is lost. It is held in a bounded queue and replayed once the Agent is up, so instrumentation does not have to wait for startup to finish.

The example apps #

Three of them, each a complete Flutter app that integrates the plugin a different way. Pick the one whose navigation matches your app - they share the same demo screens through the shared package, so the only real difference between them is how each wires EdotNavigatorObserver.

Flavor Navigation What to copy from it
basic None - one screen The smallest integration: start the Agent from .env, then emit a span, a metric, a log, a reported error, and read the Session identifier. No navigation, no network.
navigator Flutter Navigator (named routes) The reference flavor. Home / Demos / Settings, a screen per telemetry area (logs at every severity, all three network paths, an interaction span, an in-page views screen tracked by EdotViewObserver, more), a parametric route that normalizes its Screen Name, and EdotNavigatorObserver on MaterialApp.navigatorObservers. Also hosts the Seam 2 tests.
go_router go_router The same demo routed with go_router - EdotNavigatorObserver via GoRouter.observers, context.push to open a screen.

shared is not a flavor: it holds the demo screens and primitives the three apps reuse, which is why each main.dart reads as little more than the navigation wiring.

Reading these from pub.dev? They ship in the published package, but they will not run from it. Each flavor depends on shared through the pub workspace, and the workspace root is not part of the tarball - so extracted on its own, none of them resolves. Clone the repository to run them; from pub.dev they are worked examples to read.

Common setup #

Every flavor reads its configuration from a .env file (via flutter_dotenv). Copy the template, point it at your collector, and run:

cd basic            # or navigator, or go_router
cp .env.example .env
flutter run

Set EDOT_SERVER_URL in .env to your collector's OTLP/HTTP endpoint. On an Android emulator the collector on your host machine is usually http://10.0.2.2:4318. With no EDOT_SERVER_URL set, an app shows a "Missing .env" screen instead of starting the Agent, so a fresh clone runs without configuration. Beyond the server URL and identity fields, .env can also set the OTLP transport (EDOT_EXPORT_PROTOCOL, http or grpc) and the session sampling rate (EDOT_SESSION_SAMPLING_RATE, 0.0-1.0). See each flavor's .env.example for the full set of keys.

0
likes
160
points
61
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for the Elastic Distribution of OpenTelemetry (EDOT) mobile Agents.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on inoxth_edot_flutter

Packages that implement inoxth_edot_flutter