diff --git a/.dictionary b/.dictionary index 1f070bd431..197f334705 100644 --- a/.dictionary +++ b/.dictionary @@ -1,4 +1,4 @@ -personal_ws-1.1 en 282 utf-8 +personal_ws-1.1 en 283 utf-8 AAR AARs ABI @@ -175,6 +175,7 @@ html iMacs illumos init +initializer inlined instrumentations integrations diff --git a/CHANGELOG.md b/CHANGELOG.md index 006834ef6a..2b4e19de7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ [Full changelog](https://github.com/mozilla/glean/compare/v60.3.0...main) +* General + * Bump the string length limit to 255 characters ([#2857](https://github.com/mozilla/glean/pull/2857)) * Android + * Delay log init until Glean is getting initialized ([#2858](https://github.com/mozilla/glean/pull/2858)) * Update to Gradle v8.8 ([#2860](https://github.com/mozilla/glean/pull/2860)) * Updated Kotlin to version 1.9.24 ([#2861](https://github.com/mozilla/glean/pull/2861)) diff --git a/docs/dev/SUMMARY.md b/docs/dev/SUMMARY.md index 873b6bfbb4..23b729d0ea 100644 --- a/docs/dev/SUMMARY.md +++ b/docs/dev/SUMMARY.md @@ -10,6 +10,7 @@ - [Android bindings](android/index.md) - [Setup Build Environment](android/setup-android-build-environment.md) - [Android SDK/NDK versions](android/sdk-ndk-versions.md) + - [Logging](android/logging.md) - [Development with android-components](android/development-with-android-components.md) - [Locally-published components in Fenix](android/locally-published-components-in-fenix.md) - [Substituting glean_parser](android/glean-parser-substitution.md) diff --git a/docs/dev/android/logging.md b/docs/dev/android/logging.md new file mode 100644 index 0000000000..075b1822f8 --- /dev/null +++ b/docs/dev/android/logging.md @@ -0,0 +1,12 @@ +# Logging + +Logs from `glean-core` are only passed through to the Android logging framework when `Glean.initialize` is called for the first time. +This means any logging that might happen before that, e.g. from early metric collection will not be collected. + +If these logs are needed for debugging add the following initializer to `Glean.kt`: + +```kotlin +init { + gleanEnableLogging() +} +``` diff --git a/docs/user/reference/metrics/string.md b/docs/user/reference/metrics/string.md index d9b034be6c..15a24282bc 100644 --- a/docs/user/reference/metrics/string.md +++ b/docs/user/reference/metrics/string.md @@ -121,7 +121,8 @@ Glean.searchDefault.name.set("wikipedia"); #### Limits -* Fixed maximum string length: 100. Longer strings are truncated. This is measured in the number of bytes when the string is encoded in UTF-8. +* Fixed maximum string length: 255. Longer strings are truncated. This is measured in the number of bytes when the string is encoded in UTF-8. + * Prior to Glean v60.4.0 the limit was 100 bytes. ## Testing API diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/Glean.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/Glean.kt index 3b77cee4e7..68f03dbf1c 100644 --- a/glean-core/android/src/main/java/mozilla/telemetry/glean/Glean.kt +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/Glean.kt @@ -149,10 +149,6 @@ open class GleanInternalAPI internal constructor() { internal var isCustomDataPath: Boolean = false - init { - gleanEnableLogging() - } - /** * Initialize the Glean SDK. * @@ -185,6 +181,8 @@ open class GleanInternalAPI internal constructor() { configuration: Configuration = Configuration(), buildInfo: BuildInfo, ) { + gleanEnableLogging() + configuration.dataPath?.let { safeDataPath -> // When the `dataPath` is provided, we need to make sure: // 1. The database path provided is not `glean_data`. diff --git a/glean-core/android/src/test/java/mozilla/telemetry/glean/private/StringMetricTypeTest.kt b/glean-core/android/src/test/java/mozilla/telemetry/glean/private/StringMetricTypeTest.kt index 05113e0d4f..0af5f76630 100644 --- a/glean-core/android/src/test/java/mozilla/telemetry/glean/private/StringMetricTypeTest.kt +++ b/glean-core/android/src/test/java/mozilla/telemetry/glean/private/StringMetricTypeTest.kt @@ -124,7 +124,7 @@ class StringMetricTypeTest { ), ) - stringMetric.set("0123456789".repeat(11)) + stringMetric.set("0123456789".repeat(26)) assertEquals(1, stringMetric.testGetNumRecordedErrors(ErrorType.INVALID_OVERFLOW)) } diff --git a/glean-core/ios/GleanTests/Metrics/StringMetricTests.swift b/glean-core/ios/GleanTests/Metrics/StringMetricTests.swift index 4042932843..25385478ae 100644 --- a/glean-core/ios/GleanTests/Metrics/StringMetricTests.swift +++ b/glean-core/ios/GleanTests/Metrics/StringMetricTests.swift @@ -88,7 +88,7 @@ class StringMetricTests: XCTestCase { disabled: false )) - stringMetric.set(String(repeating: "0123456789", count: 11)) + stringMetric.set(String(repeating: "0123456789", count: 26)) XCTAssertEqual(1, stringMetric.testGetNumRecordedErrors(.invalidOverflow)) } diff --git a/glean-core/python/tests/metrics/test_string.py b/glean-core/python/tests/metrics/test_string.py index cf53258dba..c5bc118454 100644 --- a/glean-core/python/tests/metrics/test_string.py +++ b/glean-core/python/tests/metrics/test_string.py @@ -79,7 +79,7 @@ def test_setting_a_long_string_records_an_error(): ) ) - string_metric.set("0123456789" * 11) + string_metric.set("0123456789" * 26) assert 1 == string_metric.test_get_num_recorded_errors(testing.ErrorType.INVALID_OVERFLOW) diff --git a/glean-core/src/metrics/string.rs b/glean-core/src/metrics/string.rs index a56ffab648..c36f33d51c 100644 --- a/glean-core/src/metrics/string.rs +++ b/glean-core/src/metrics/string.rs @@ -13,7 +13,7 @@ use crate::util::truncate_string_at_boundary_with_error; use crate::CommonMetricData; use crate::Glean; -const MAX_LENGTH_VALUE: usize = 100; +const MAX_LENGTH_VALUE: usize = 255; /// A string metric. /// @@ -166,7 +166,7 @@ mod test { dynamic_label: None, }); - let sample_string = "0123456789".repeat(11); + let sample_string = "0123456789".repeat(26); metric.set_sync(&glean, sample_string.clone()); let truncated = truncate_string_at_boundary(sample_string, MAX_LENGTH_VALUE); diff --git a/glean-core/tests/labeled.rs b/glean-core/tests/labeled.rs index 63a7f2ccc2..c8a2511c81 100644 --- a/glean-core/tests/labeled.rs +++ b/glean-core/tests/labeled.rs @@ -162,7 +162,7 @@ fn can_record_error_for_submetric() { ); let metric = labeled.get("label1"); - metric.set_sync(&glean, "01234567890".repeat(20)); + metric.set_sync(&glean, "01234567890".repeat(26)); // Make sure that the errors have been recorded assert_eq!( diff --git a/glean-core/tests/string.rs b/glean-core/tests/string.rs index 3ccfa8f494..0daa6e6e8c 100644 --- a/glean-core/tests/string.rs +++ b/glean-core/tests/string.rs @@ -104,12 +104,12 @@ fn long_string_values_are_truncated() { ..Default::default() }); - let test_sting = "01234567890".repeat(20); - metric.set_sync(&glean, test_sting.clone()); + let test_string = "01234567890".repeat(26); + metric.set_sync(&glean, test_string.clone()); // Check that data was truncated assert_eq!( - test_sting[..100], + test_string[..255], metric.get_value(&glean, "store1").unwrap() );