Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Unable to send logs #64

Closed
vytautas-pranskunas- opened this issue Jan 14, 2022 · 5 comments
Closed

Unable to send logs #64

vytautas-pranskunas- opened this issue Jan 14, 2022 · 5 comments

Comments

@vytautas-pranskunas-
Copy link

vytautas-pranskunas- commented Jan 14, 2022

I have checked with datadog support team - configuration looks good howver no logs are landing in datadog: logs, route observation, network observations, errors, nothing.
My log service looks like this:

import 'package:datadog_flutter/datadog_flutter.dart';
import 'package:datadog_flutter/datadog_logger.dart';
import 'package:datadog_flutter/datadog_observer.dart';
import 'package:datadog_flutter/datadog_rum.dart';
import 'package:datadog_flutter/datadog_tracing.dart';
import 'package:senio_assist/infrastructure/env_variables.dart';
import 'package:logging/logging.dart';

class LoggingService {
  DatadogObserver getNavigationObserver() => DatadogObserver();
  DatadogRum get instance => DatadogRum.instance;
  static final _logger = DatadogLogger(loggerName: 'Root Logger');

  static init() async {
    await DatadogFlutter.initialize(
      clientToken: EnvVariables.datadogKey,
      serviceName: 'MyApp',
      environment: EnvVariables.env,
      iosRumApplicationId: 'MyApp',
      androidRumApplicationId: 'MyApp',
      trackingConsent: TrackingConsent.granted,
      useEUEndpoints: true,
    );

    await DatadogTracing.initialize();
    Logger.root.onRecord.listen(_logger.onRecordCallback);
    // FlutterError.onError = DatadogRum.instance.addFlutterError;
  }

  DatadogTracingHttpClient? httpClient() {
    return DatadogTracingHttpClient();
  }

  log(String name, {level = Level.INFO}) {
    _logger.log(name, level);
  }

  addUserAction(
    String name, {
    RUMAction action = RUMAction.custom,
    Map<String, dynamic> attributes = const <String, dynamic>{},
  }) {
    instance.addUserAction(name, action: action, attributes: attributes);
  }

  onAuth(String userId) async {
    await DatadogFlutter.setUserInfo(id: userId);
    _logger.addAttribute('hostname', userId);
    await instance.addAttribute('hostname', userId);
  }
}

I call init() in main before any activity

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  DevHttpOverrides.init();
  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarBrightness: Brightness.light,
      statusBarIconBrightness: Brightness.dark));

  ...
  await LoggingService.init();

  runZonedGuarded<Future<void>>(() async {

any ideas why i am not able to send logs?

@vytautas-pranskunas-
Copy link
Author

After talking to datadog chat logs are sent (i did nothing.. thay somehow enealed something) but I am facing another problems

  1. I am not able to see error logs in datadog but i am using: DatadogRum.instance.addError(error, stackTrace)
  2. I am not able to see request body (while seeing requests) by passing http client to graphql package
  3. I am seeing this message in conole:
    A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.
    W/Datadog ( 7907): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.

@tshedor
Copy link
Contributor

tshedor commented Jan 14, 2022

@vytautas-pranskunas- you won't see the request body in the APM traces. This is a deliberate; sensitive information could be in the body.

As to your first and third messages, please use the DatadogObserver

@vytautas-pranskunas-
Copy link
Author

vytautas-pranskunas- commented Jan 15, 2022

  1. I am using DatadogObserver, unless I cannot use few observers because i also using firebase analytics observer.
  2. regarding request body tracing - I am using graphql i sensetive data is passed in variables, i need to log body because i do not know what request it was...

p.p.s I am trying to build my own link to track requests but i see following error:
Screenshot 2022-01-15 at 11 32 54

i think you ened to change documentation to DatadogRum.instance.startResourceLoading

however when I am trying to call via instance i get this error:
Screenshot 2022-01-15 at 11 49 41

@vytautas-pranskunas-
Copy link
Author

I was able to solve #2 problem above almost excet fact that when i am callingDatadogRum.instance.stopResourceLoading(requestId) I am getting error about 'fetch' contstant
Screenshot 2022-01-15 at 16 56 45

Still sturgling to make DatadogObserver to work

@vytautas-pranskunas-
Copy link
Author

@tshedor Any help would be awesome! Because i cannot complete datadog integration.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants