Skip to content

Commit ea5e58b

Browse files
committed
add a file for metric names
1 parent a61e884 commit ea5e58b

3 files changed

Lines changed: 47 additions & 6 deletions

File tree

common/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
import com.microsoft.identity.common.java.exception.UnsupportedBrokerException;
103103
import com.microsoft.identity.common.java.interfaces.IPlatformComponents;
104104
import com.microsoft.identity.common.java.opentelemetry.OTelUtility;
105+
import com.microsoft.identity.common.java.opentelemetry.OtelCountMetrics;
105106
import com.microsoft.identity.common.java.providers.microsoft.MicrosoftRefreshToken;
106107
import com.microsoft.identity.common.java.providers.microsoft.azureactivedirectory.ClientInfo;
107108
import com.microsoft.identity.common.java.providers.microsoft.microsoftsts.MicrosoftStsAccount;
@@ -153,10 +154,10 @@ public class BrokerMsalController extends BaseController {
153154

154155
private String mMaxMsalBrokerProtocolVersion;
155156

156-
// telemetry count metric for tracking getCurrentAccount() SDM failures
157-
private static final LongCounter sGetCurrentAccountFailedNoSDMCount = OTelUtility.createLongCounter(
158-
"get_current_account_failed_no_sdm_count",
159-
"Number of failed getCurrentAccount calls due to no SDM"
157+
// telemetry count metric for tracking getCurrentAccount() calls where no SDM is present
158+
private static final LongCounter sGetCurrentAccountWithNoSDMCount = OTelUtility.createLongCounter(
159+
OtelCountMetrics.get_current_account_with_no_sdm_count.name(),
160+
"Number of getCurrentAccount calls with no SDM present"
160161
);
161162

162163
public BrokerMsalController(@NonNull final Context applicationContext,
@@ -955,7 +956,7 @@ List<ICacheRecord> getCurrentAccount(final @NonNull CommandParameters parameters
955956

956957
if (!parameters.isSharedDevice()) {
957958
Logger.verbose(TAG + methodName, "Not a shared device, invoke getAccounts() instead of getCurrentAccount()");
958-
sGetCurrentAccountFailedNoSDMCount.add(1); // TODO: Any useful attributes? How is this emitted?
959+
sGetCurrentAccountWithNoSDMCount.add(1); // TODO: Any useful attributes to add? How is this emitted?
959960
return getAccounts(parameters);
960961
}
961962

common/src/main/java/com/microsoft/identity/common/internal/util/AndroidKeyStoreUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.microsoft.identity.common.java.logging.Logger;
2929
import com.microsoft.identity.common.java.opentelemetry.AttributeName;
3030
import com.microsoft.identity.common.java.opentelemetry.OTelUtility;
31+
import com.microsoft.identity.common.java.opentelemetry.OtelCountMetrics;
3132
import com.microsoft.identity.common.java.util.ThrowableUtil;
3233
import com.microsoft.identity.common.java.util.ported.DateUtilities;
3334

@@ -94,7 +95,7 @@ private AndroidKeyStoreUtil() {
9495
}
9596

9697
private static final LongCounter sFailedAndroidKeyStoreUnwrapOperationCount = OTelUtility.createLongCounter(
97-
"failed_keystore_key_unwrap_operation_count",
98+
OtelCountMetrics.failed_keystore_key_unwrap_operation_count.name(),
9899
"Number of failed Android KeyStore unwrap operations"
99100
);
100101

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
package com.microsoft.identity.common.java.opentelemetry
24+
25+
/**
26+
* Class containing the names of various Open Telemetry Metrics that we use in our code today, similar to AttributeName.
27+
* Creating this to have a central hub for tracking where metrics are used in our code base.
28+
*/
29+
enum class OtelCountMetrics {
30+
/**
31+
* Number of failed Android KeyStore unwrap operations
32+
*/
33+
failed_keystore_key_unwrap_operation_count,
34+
35+
/**
36+
* Number of getCurrentAccount calls with no SDM present
37+
*/
38+
get_current_account_with_no_sdm_count
39+
}

0 commit comments

Comments
 (0)