Giter Club home page Giter Club logo

Comments (12)

fuzzybinary avatar fuzzybinary commented on July 17, 2024

Hi @rohith-alphanso thanks for reporting!

2.1.0 added a finalizer to Loggers to remove them when Dart no longer can reach them. I'm curious why the finalizer is working differently on the iPhone SE simulator....

Is this reproducable with a simple case? Can you give me a simple example project to see if I can figure out why Dart might be finalizing the logger?

from dd-sdk-flutter.

rohith-alphanso avatar rohith-alphanso commented on July 17, 2024

Hi @rohith-alphanso thanks for reporting!

2.1.0 added a finalizer to Loggers to remove them when Dart no longer can reach them. I'm curious why the finalizer is working differently on the iPhone SE simulator....

Is this reproducable with a simple case? Can you give me a simple example project to see if I can figure out why Dart might be finalizing the logger?

We are facing this exception, with 2.0.0 as well, we will try to have a simple repro

from dd-sdk-flutter.

fuzzybinary avatar fuzzybinary commented on July 17, 2024

@rohith-alphanso That is incredibly strange, as prior to 2.1.0 we didn't remove loggers from the registry. I'll continue looking into this but please let me know if you find a simple repro.

from dd-sdk-flutter.

fuzzybinary avatar fuzzybinary commented on July 17, 2024

@rohith-alphanso I can't reproduce here with my simple examples. I'm wondering if there's something weird in your initialization. Are you awaiting DatadogSdk.initialize before creating a logger?

from dd-sdk-flutter.

rohith-alphanso avatar rohith-alphanso commented on July 17, 2024

@rohith-alphanso I can't reproduce here with my simple examples. I'm wondering if there's something weird in your initialization. Are you awaiting DatadogSdk.initialize before creating a logger?

yes,

final datadogConfiguration = DatadogUtils.getDatadogSdkConfiguration();
  await DatadogSdk.instance
      .initialize(datadogConfiguration, TrackingConsent.granted);

from dd-sdk-flutter.

rohith-alphanso avatar rohith-alphanso commented on July 17, 2024

@rohith-alphanso I can't reproduce here with my simple examples. I'm wondering if there's something weird in your initialization. Are you awaiting DatadogSdk.initialize before creating a logger?

static final _datadogLogger = DatadogLogger(
   InternalLogger(),
   DatadogLoggerConfiguration(
     networkInfoEnabled: true,
   ),
 );

 static DatadogConfiguration getDatadogSdkConfiguration() {
   final datadogEnvironment = _getDatadogEnvironment();

   return DatadogConfiguration(
     service: 'XXXXX',
     clientToken: _clientToken,
     env: datadogEnvironment,
     site: _datadogSite,
     nativeCrashReportEnabled: true,
     firstPartyHosts: _firstPartyHosts,
     uploadFrequency: UploadFrequency.frequent,
     rumConfiguration: DatadogRumConfiguration(
       applicationId: _applicationId,
       viewEventMapper: DatadogSessionIdRetriever.viewEventMapper,
     ),
   )..enableHttpTracking();
 }; 
 
 final datadogConfiguration = getDatadogSdkConfiguration();
 await DatadogSdk.instance
     .initialize(datadogConfiguration, TrackingConsent.granted);
  • This is how we are defining logger in our application

from dd-sdk-flutter.

fuzzybinary avatar fuzzybinary commented on July 17, 2024

@rohith-alphanso I'll confirm, but my guess is that the static initialization of _datadogLogger is running before DatadogSdk.instance.initialize, which means that the MethodChannels aren't available to create the actual logger when you call DatadogSdk.instance.logs?.createLogger. I'm not 100% sure how you get an logger Id in this scenario, but I'll try to recreate and see.

Hopefully your call to DatadogSdk.instance.initialize in main?

from dd-sdk-flutter.

fuzzybinary avatar fuzzybinary commented on July 17, 2024

Oh, actually, this is improper usage of this API. InternalLogger in an internal type (and marked as such in the documentation). The constructor for DatadogLogger is also internal, but not marked as so via attributes (I will fix that).

To create loggers, it's expected you will call DatadogSdk.instance.logs?.createLogger after initializing Datadog.

from dd-sdk-flutter.

rohith-alphanso avatar rohith-alphanso commented on July 17, 2024

@rohith-alphanso I'll confirm, but my guess is that the static initialization of _datadogLogger is running before DatadogSdk.instance.initialize, which means that the MethodChannels aren't available to create the actual logger when you call DatadogSdk.instance.logs?.createLogger. I'm not 100% sure how you get an logger Id in this scenario, but I'll try to recreate and see.

Hopefully your call to DatadogSdk.instance.initialize in main?

yes

Future<void> initializeApp() async {
  WidgetsFlutterBinding.ensureInitialized();

  final datadogConfiguration = DatadogUtils.getDatadogSdkConfiguration();
  await DatadogSdk.instance
      .initialize(datadogConfiguration, TrackingConsent.granted);

  FlutterError.onError = (final details) {
    FlutterError.presentError(details);
    DatadogSdk.instance.rum?.handleFlutterError(details);
  };

  PlatformDispatcher.instance.onError = (final error, final stackTrace) {
    DatadogSdk.instance.rum?.addErrorInfo(
      error.toString(),
      RumErrorSource.source,
      stackTrace: stackTrace,
    );
    return true;
  };
 }

This initializeApp is called in the main method

from dd-sdk-flutter.

fuzzybinary avatar fuzzybinary commented on July 17, 2024

@rohith-alphanso See above though. You cannot create a DatadogLogger from it's constructor. It should be marked as @internal. Use DatadogSdk.instance.logs?.createLogger instead after Datadog is initialized.

from dd-sdk-flutter.

fuzzybinary avatar fuzzybinary commented on July 17, 2024

@rohith-alphanso Did you ever get this resolved?

from dd-sdk-flutter.

rohith-alphanso avatar rohith-alphanso commented on July 17, 2024

from dd-sdk-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.