-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Cobalt Telemetry for the Loader App (#2667)
A LoaderAppMetrics Starboard extension is added so that measurements taken by the Loader App can be reliably accessed by Cobalt once loaded. This PR just adds one metric for now, for b/329458881, but this pattern and extension can be used for b/329445690 and other Loader App metrics. b/329458881 Change-Id: I940d07b058d197afa2ad8b1160eba469f1055f8a (cherry picked from commit bf93736)
- Loading branch information
1 parent
7bffd2e
commit 35f90c6
Showing
10 changed files
with
248 additions
and
0 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
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,64 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed 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. | ||
|
||
#ifndef STARBOARD_EXTENSION_LOADER_APP_METRICS_H_ | ||
#define STARBOARD_EXTENSION_LOADER_APP_METRICS_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define kStarboardExtensionLoaderAppMetricsName \ | ||
"dev.cobalt.extension.LoaderAppMetrics" | ||
|
||
// These values are persisted to logs. Entries should not be renumbered and | ||
// numeric values should never be reused. Must be kept in sync with the | ||
// corresponding definition in | ||
// tools/metrics/histograms/metadata/cobalt/enums.xml. | ||
typedef enum CrashpadInstallationStatus { | ||
// The enumerators below this point were added in version 1 or later. | ||
kUnknown = 0, | ||
kSucceeded = 1, | ||
kFailedCrashpadHandlerBinaryNotFound = 2, | ||
kFailedDatabaseInitializationFailed = 3, | ||
kFailedSignalHandlerInstallationFailed = 4, | ||
kMaxValue = kFailedSignalHandlerInstallationFailed | ||
} CrashpadInstallationStatus; | ||
|
||
typedef struct StarboardExtensionLoaderAppMetricsApi { | ||
// Name should be the string |kStarboardExtensionLoaderAppMetricsName|. | ||
// This helps to validate that the extension API is correct. | ||
const char* name; | ||
|
||
// This specifies the version of the API that is implemented. | ||
uint32_t version; | ||
|
||
// The fields below this point were added in version 1 or later. | ||
|
||
// The accessors and mutators below are assumed to be called from the same | ||
// thread: Cobalt's application thread. | ||
|
||
void (*SetCrashpadInstallationStatus)(CrashpadInstallationStatus status); | ||
|
||
CrashpadInstallationStatus (*GetCrashpadInstallationStatus)(); | ||
|
||
} StarboardExtensionLoaderAppMetricsApi; | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // STARBOARD_EXTENSION_LOADER_APP_METRICS_H_ |
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
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,50 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed 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. | ||
|
||
#include "starboard/shared/starboard/loader_app_metrics.h" | ||
|
||
#include "starboard/extension/loader_app_metrics.h" | ||
|
||
namespace starboard { | ||
namespace shared { | ||
namespace starboard { | ||
|
||
namespace { | ||
|
||
// Thread safety isn't needed for this global variable since the extension's | ||
// interface specifies that all accesses and mutations must be from the same | ||
// thread. | ||
static CrashpadInstallationStatus g_crashpad_installation_status; | ||
|
||
void SetCrashpadInstallationStatus(CrashpadInstallationStatus status) { | ||
g_crashpad_installation_status = status; | ||
} | ||
|
||
CrashpadInstallationStatus GetCrashpadInstallationStatus() { | ||
return g_crashpad_installation_status; | ||
} | ||
|
||
const StarboardExtensionLoaderAppMetricsApi kLoaderAppMetricsApi = { | ||
kStarboardExtensionLoaderAppMetricsName, 1, &SetCrashpadInstallationStatus, | ||
&GetCrashpadInstallationStatus}; | ||
|
||
} // namespace | ||
|
||
const void* GetLoaderAppMetricsApi() { | ||
return &kLoaderAppMetricsApi; | ||
} | ||
|
||
} // namespace starboard | ||
} // namespace shared | ||
} // namespace starboard |
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,28 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed 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. | ||
|
||
#ifndef STARBOARD_SHARED_STARBOARD_LOADER_APP_METRICS_H_ | ||
#define STARBOARD_SHARED_STARBOARD_LOADER_APP_METRICS_H_ | ||
|
||
namespace starboard { | ||
namespace shared { | ||
namespace starboard { | ||
|
||
const void* GetLoaderAppMetricsApi(); | ||
|
||
} // namespace starboard | ||
} // namespace shared | ||
} // namespace starboard | ||
|
||
#endif // STARBOARD_SHARED_STARBOARD_LOADER_APP_METRICS_H_ |
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
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 |
---|---|---|
|
@@ -198,6 +198,17 @@ Always run the pretty print utility on this file after editing: | |
</summary> | ||
</histogram> | ||
|
||
<histogram name="Cobalt.LoaderApp.CrashpadInstallationStatus" | ||
enum="CrashpadInstallationStatus" expires_after="never"> | ||
<!-- expires-never: Needed for crash reporting system health metrics. --> | ||
|
||
<owner>[email protected]</owner> | ||
<owner>[email protected]</owner> | ||
<summary> | ||
Status of Crashpad installation by the Loader App. | ||
</summary> | ||
</histogram> | ||
|
||
</histograms> | ||
|
||
</histogram-configuration> |