Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: runtime metric API #264

Merged
merged 2 commits into from
Feb 13, 2024
Merged

feat: runtime metric API #264

merged 2 commits into from
Feb 13, 2024

Conversation

nyannyacha
Copy link
Collaborator

What kind of change does this PR introduce?

Feature

Description

This PR exposes an API to get runtime metrics.

Note: This API is only exposed in the main worker.

Note 2: The number of pending requests is the difference between the number of handled requests and the number of received requests, so I didn’t include it in the metric.

Usage

serve(async () => {
    ...
	if (pathname === '/_internal/metric') {
		const metric = await EdgeRuntime.getRuntimeMetrics();
		return Response.json(metric);
	}
    ...
})

Sample output

{
    "mainWorkerHeapStats": {
        "totalHeapSize": 11730944,
        "totalHeapExecutable": 524288,
        "totalPhysicalSize": 11165696,
        "totalAvailableSize": 1508889368,
        "totalGlobalHandlesSize": 16384,
        "usedGlobalHandlesSize": 10144,
        "usedHeapSize": 10273032,
        "mallocedMemory": 278632,
        "externalMemory": 79991,
        "peakMallocedMemory": 139480
    },
    "eventWorkerHeapStats": {
        "totalHeapSize": 11468800,
        "totalHeapExecutable": 262144,
        "totalPhysicalSize": 10174464,
        "totalAvailableSize": 1509473792,
        "totalGlobalHandlesSize": 16384,
        "usedGlobalHandlesSize": 9504,
        "usedHeapSize": 9473440,
        "mallocedMemory": 278632,
        "externalMemory": 79991,
        "peakMallocedMemory": 173088
    },
    "activeUserWorkersCount": 1,
    "retiredUserWorkersCount": 2,
    "receivedRequestsCount": 17,
    "handledRequestsCount": 17
}

@nyannyacha nyannyacha marked this pull request as ready for review February 12, 2024 03:55
@laktek
Copy link
Contributor

laktek commented Feb 12, 2024

@nyannyacha Is it possible to squash the stamp commits? Will keep the commit history clean :)

@nyannyacha
Copy link
Collaborator Author

@laktek hold a moment 😋

@nyannyacha
Copy link
Collaborator Author

@laktek done

@laktek laktek merged commit 705db6e into supabase:main Feb 13, 2024
3 checks passed
Copy link

🎉 This PR is included in version 1.35.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@nyannyacha nyannyacha deleted the feat-metric-api branch February 13, 2024 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants