-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Using catalog from root project for tests * Creating android-test catalog * Providing agent version on tests * Fixing tests * Clean up * Moving dependencies to the catalog * Clean up * Adding support for kotlin and junit5 * Setting up robolectric tests * Initializing test instance * Adding all resource attr names * Rename .java to .kt * Making device id configurable * Setting android env values * Setting android env values * Passing agent version from build file * Providing version code in tests * Using latest sdk in tests * Validating all signals' resources * Renaming test file * Adding global attributes test * Making global attr tests pass * Fixing tests * Adding cell network attr to tests * Enhancing tests * Adding carrier info global attr tests * Clean up * Clean up * Renaming packages * Updating notice file
- Loading branch information
1 parent
54b2b32
commit 54814cc
Showing
30 changed files
with
461 additions
and
846 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
dependencies.hash=116B097450368CFACC99BF27198E0C94 | ||
dependencies.hash=FC395F744DC7E6D0DFA00982EDA59801 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
...id-sdk/src/main/java/co/elastic/apm/android/sdk/attributes/resources/DeviceIdVisitor.java
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
android-sdk/src/main/java/co/elastic/apm/android/sdk/attributes/resources/DeviceIdVisitor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package co.elastic.apm.android.sdk.attributes.resources | ||
|
||
import co.elastic.apm.android.sdk.attributes.AttributesVisitor | ||
import co.elastic.apm.android.sdk.internal.services.Service | ||
import co.elastic.apm.android.sdk.internal.services.ServiceManager | ||
import co.elastic.apm.android.sdk.internal.services.preferences.PreferencesService | ||
import io.opentelemetry.api.common.AttributesBuilder | ||
import io.opentelemetry.semconv.ResourceAttributes | ||
import java.util.function.Supplier | ||
|
||
class DeviceIdVisitor(private val deviceIdGenerator: Supplier<String>) : AttributesVisitor { | ||
|
||
override fun visit(builder: AttributesBuilder) { | ||
builder.put(ResourceAttributes.DEVICE_ID, getId()) | ||
} | ||
|
||
private fun getId(): String { | ||
val preferences = | ||
ServiceManager.get() | ||
.getService<PreferencesService>( | ||
Service.Names.PREFERENCES | ||
) | ||
var deviceId = | ||
preferences.retrieveString(DEVICE_ID_KEY) | ||
|
||
if (deviceId == null) { | ||
deviceId = deviceIdGenerator.get() | ||
preferences.store(DEVICE_ID_KEY, deviceId) | ||
} | ||
|
||
return deviceId | ||
} | ||
|
||
companion object { | ||
private const val DEVICE_ID_KEY = "device_id" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.