DataDog / dd-sdk-android

Datadog SDK for Android (Compatible with Kotlin and Java)
Apache License 2.0
157 stars 60 forks source link

Logging: setNetworkInfoEnabled(false) doesn't seem to take effect #1923

Closed Ostkontentitan closed 7 months ago

Ostkontentitan commented 8 months ago

Describe the bug

Configuring a logger with setNetworkInfoEnabled(false) produces logs with network info.

network{ client{ geoip { ....

Got tracing configured too where setNetworkInfoEnabled(false) takes effect. Got logging hooked up to timber.

Reproduction steps

    val logsConfig = LogsConfiguration.Builder()
      .build()
    Logs.enable(logsConfig)

    val logger = Logger.Builder()
      .setNetworkInfoEnabled(false)
      .setLogcatLogsEnabled(true)
      .setRemoteSampleRate(100f)
      .setBundleWithTraceEnabled(true)
      .setBundleWithRumEnabled(false)
      .setService(SERVICE_NAME)
      .build()

    logger.e(Log.ERROR, "networkinfo test")

Logcat logs

No response

Expected behavior

No network info present in the logs on datadog.

Affected SDK versions

2.6.2

Latest working SDK version

unknown

Did you confirm if the latest SDK version fixes the bug?

No

Kotlin / Java version

1.9.22

Gradle / AGP version

8.6 / 8.3.1

Other dependencies versions

okhttp 4.12.0 timber 5.0.1

datadogTracing = { group = "com.datadoghq", name = "dd-sdk-android-trace", version.ref = "datadog" } datadogLogging = { group = "com.datadoghq", name = "dd-sdk-android-logs", version.ref = "datadog" } datadogTimber = { group = "com.datadoghq", name = "dd-sdk-android-timber", version.ref = "datadog" } datadogOkhttp = { group = "com.datadoghq", name = "dd-sdk-android-okhttp", version.ref = "datadog" } datadogRum = { group = "com.datadoghq", name = "dd-sdk-android-rum", version.ref = "datadog" } ( all use 2.6.2 )

Device Information

Pixel 7 emulator API 34 powered / full network

Other relevant information

No response

mariusc83 commented 8 months ago

Hi @Ostkontentitan, the method in the Public API will only disable the information for the network state. The other part of information regarding the network is automatically added by our backend pipeline based on the GeoIp and you can easily disable it when you create your RUM application in the config dashboard: https://docs.datadoghq.com/real_user_monitoring/mobile_and_tv_monitoring/setup/android/?tab=kotlin

Please let us know if this helped.

Ostkontentitan commented 8 months ago

Thank you for your quick reply @mariusc83

So far we don't have the RUM feature configured at all as we are careful not to pass any user-data whatsoever. I was following the example given here: https://github.com/DataDog/dd-sdk-ios/issues/1716#issuecomment-1991040704

    grantedCore = Datadog.initialize(
      context = context,
      configuration = configuration,
      trackingConsent = TrackingConsent.GRANTED
    )

    configureLogging()
    configureTracing()

The goal would be to introduce tracing and logs in a compliant way not carrying any user data into it. I assume carrier information and geoIp are likely sensitive thats why i am looking for ways not to send them.

Do you think this is achievable?

mariusc83 commented 8 months ago

So basically you are not using a RUM application, you are only using the Logs API ? In that case I don't think it is an easy way except if you modify your logs pipeline and try to add a regEx to remove the Network information: https://docs.datadoghq.com/logs/log_configuration/pipelines/?tab=source

mariusc83 commented 8 months ago

There is also this issue opened by another person a while ago in our iOS sdk repository you could look into on the same topic: https://github.com/DataDog/dd-sdk-ios/issues/1403#issuecomment-1660228559

0xnm commented 7 months ago

Hello @Ostkontentitan! I hope your question was answered, so I'm closing this issue. Don't hesitate to re-open it if needed.