-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added Metrics Examples Page #9922
Conversation
Added Examples Page with use cases
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bundle ReportChanges will increase total bundle size by 156 bytes ⬆️
|
Added examples to tables
|
||
## Frontend Examples | ||
|
||
| **Use Case** | **Metric Type** | **Example** | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| **Use Case** | **Metric Type** | **Example** | | |
| **Use Case** | **Metric Type** | **Example Javascript Implementation** | |
Are these examples all in javascript? It'd be good to call out what language it's in just so it's super clear to users whether they can copy/paste or not
| **Use Case** | **Metric Type** | **Example** | | ||
| -------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| Count button clicks on subpages | counter | `Sentry.metrics.increment("button_click", 1, {`<br /> `tags: { browser: "Firefox", subpage: "signup" }`<br />`});` | | ||
| Number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br /> `tags: { plan_type: “freemium” }`<br />`});` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br /> `tags: { plan_type: “freemium” }`<br />`});` | | |
| Count number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br /> `tags: { plan_type: “freemium” }`<br />`});` | |
| -------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| Count button clicks on subpages | counter | `Sentry.metrics.increment("button_click", 1, {`<br /> `tags: { browser: "Firefox", subpage: "signup" }`<br />`});` | | ||
| Number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br /> `tags: { plan_type: “freemium” }`<br />`});` | | ||
| Measure UX improvement to signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br /> `tags: { subpage: “signup” },`<br /> `unit: “second”`<br />`});` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Measure UX improvement to signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br /> `tags: { subpage: “signup” },`<br /> `unit: “second”`<br />`});` | | |
| Measure the UX improvement to a signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br /> `tags: { subpage: “signup” },`<br /> `unit: “second”`<br />`});` | |
| Measure UX improvement to signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br /> `tags: { subpage: “signup” },`<br /> `unit: “second”`<br />`});` | | ||
| Track the loading times for a component | distribution | `Sentry.metrics.distribution("component_load_time", 15.0, {`<br /> `tags: { type: "important" },`<br /> `unit: "millisecond"`<br />`});` | | ||
| Track API request payloads | distribution | `Sentry.metrics.distribution("api_request_payload", 136.3, {`<br /> `tags: { api_name: “maps_provider”, subpage: “signup” },`<br /> `unit: “kilobyte”`<br />`});` | | ||
| Count concurrent users in application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br /> `tags: { browser: "Firefox" }`<br />`});` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Count concurrent users in application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br /> `tags: { browser: "Firefox" }`<br />`});` | | |
| Count concurrent users in the application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br /> `tags: { browser: "Firefox" }`<br />`});` | |
| Count concurrent users in application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br /> `tags: { browser: "Firefox" }`<br />`});` | | ||
| Track the number of items in a shopping cart | gauge | `Sentry.metrics.gauge("shopping_cart_item_count", itemCount, {`<br /> `tags: { platform: "web" }`<br />`});` | | ||
| Count the unique number of users on a page | set | `Sentry.metrics.set("user_view", "jane", {`<br /> `tags: {"page": "/home" }`<br />`});` | | ||
| Count unique number of user sessions | set | `Sentry.metrics.set("unique_active_sessions", sessionId, {`<br /> `tags: { platform: "mobile" }`<br />`});` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Count unique number of user sessions | set | `Sentry.metrics.set("unique_active_sessions", sessionId, {`<br /> `tags: { platform: "mobile" }`<br />`});` | | |
| Count the unique number of user sessions | set | `Sentry.metrics.set("unique_active_sessions", sessionId, {`<br /> `tags: { platform: "mobile" }`<br />`});` | |
| Track CPU usage over time | gauge | `sentry_sdk.metrics.gauge(`<br /> `key=”cpu_usage”,`<br /> `value=94,`<br /> `unit=”percent”`<br />`)` | | ||
| Track cache hit ratio | gauge | `sentry_sdk.metrics.gauge(`<br /> `key=”cache_hit_ratio”,`<br /> `value=85,`<br /> `unit=”percent”`<br />`)` | | ||
| Count unique server ids running a software version | set | `sentry_sdk.metrics.set(`<br /> `key=”server_ids_running”,`<br /> `value=“server_id”,`<br /> `tags={"software_version": software_version}`<br />`)` | | ||
| Track number of unique DB queries executed | set | `sentry_sdk.metrics.set(`<br /> `key=”db_queries”,`<br /> `value=query,`<br /> `tags={"query_type": "read"}`<br />`)` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Track number of unique DB queries executed | set | `sentry_sdk.metrics.set(`<br /> `key=”db_queries”,`<br /> `value=query,`<br /> `tags={"query_type": "read"}`<br />`)` | | |
| Track the number of unique DB queries executed | set | `sentry_sdk.metrics.set(`<br /> `key=”db_queries”,`<br /> `value=query,`<br /> `tags={"query_type": "read"}`<br />`)` | |
|
||
| **Use Case** | **Metric Type** | **Example** | | ||
| -------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| Count button clicks on subpages | counter | `Sentry.metrics.increment("button_click", 1, {`<br /> `tags: { browser: "Firefox", subpage: "signup" }`<br />`});` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I wasn't sure whether the tags were part of how the metric is defined (as in this counts button clicks specifically for the subpage page signup on firefox browsers) or if they were providing additional context. I'm pretty sure it's additional context, but I think this would be even clearer if we called this out in the example by adding code comments like we have in the SDK docs. What do you think of adjusting these examples to something like this?
| Count button clicks on subpages | counter | `Sentry.metrics.increment("button_click", 1, {`<br /> `tags: { browser: "Firefox", subpage: "signup" }`<br />`});` | | |
| Count button clicks on subpages | counter | // Adds 1 to the button_click counter with additional context for the browser and subpage <br/> | |
`Sentry.metrics.increment("button_click", 1, {`<br /> `tags: { browser: "Firefox", subpage: "signup" }`<br />`});` | |
--- | ||
title: "Example Use Cases" | ||
sidebar_order: 18 | ||
description: "Example Use Cases for custom metrics." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Example Use Cases for custom metrics." | |
description: "Learn about some common use cases for using custom metrics." |
description: "Example Use Cases for custom metrics." | ||
--- | ||
|
||
If you're not sure where to start, here are a few examples of how you can use custom metrics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not sure where to start, here are a few examples of how you can use custom metrics. | |
You can emit custom metrics to help you track and measure the metrics you care about most. Here are some examples of what you can track with custom metrics. Once your metrics are in Sentry, you'll be able to query, monitor, and get alerted on them. |
|
||
## Backend Examples | ||
|
||
| **Use Case** | **Metric Type** | **Example** | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful to call out what language these examples are in
Decided to go with another approach with collapsable list items. |
Added Examples Page with use cases
Pre-merge checklist
If you work at Sentry, you're able to merge your own PR without review, but please don't unless there's a good reason.
Description of changes
Did my best, looks like this.
![Screenshot 2024-05-06 at 15 02 59](https://private-user-images.githubusercontent.com/26696515/328187543-85210798-c1de-4cab-a1ef-14b942b710e1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1ODcwMjcsIm5iZiI6MTcyMDU4NjcyNywicGF0aCI6Ii8yNjY5NjUxNS8zMjgxODc1NDMtODUyMTA3OTgtYzFkZS00Y2FiLWExZWYtMTRiOTQyYjcxMGUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzEwVDA0NDUyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM2YzgyYzBhMDg0NzEwNTEzMzc5OGJmMjAyM2Y2YTczMTdkYjZlMTcyZThkZTBmODhiYTMwODlkYjIxMWY2YzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jW8I19pj_9h9GEkgEi61-61jVOYFiPt3C0VEvtuo5gE)