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

Added Metrics Examples Page #9922

Closed
wants to merge 12 commits into from
Closed

Added Metrics Examples Page #9922

wants to merge 12 commits into from

Conversation

ale-cota
Copy link
Contributor

@ale-cota ale-cota commented May 4, 2024

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.

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs
  • PR was reviewed and approved by a member of the Sentry docs team

Description of changes

Did my best, looks like this.
Screenshot 2024-05-06 at 15 02 59

Added Examples Page with use cases
Copy link

vercel bot commented May 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 1:13pm

Copy link

codecov bot commented May 4, 2024

Bundle Report

Changes will increase total bundle size by 156 bytes ⬆️

Bundle name Size Change
sentry-docs-server 7.16MB 165 bytes ⬆️
sentry-docs-edge-server 427.92kB 3 bytes ⬇️
sentry-docs-client 5.77MB 6 bytes ⬇️

Added examples to tables
docs/product/metrics/metrics-examples.mdx Outdated Show resolved Hide resolved
docs/product/metrics/metrics-examples.mdx Outdated Show resolved Hide resolved
docs/product/metrics/metrics-examples.mdx Outdated Show resolved Hide resolved
@ale-cota ale-cota changed the title Added Examples Page Added MetricsExamples Page May 6, 2024
@ale-cota ale-cota changed the title Added MetricsExamples Page Added Metrics Examples Page May 6, 2024
@ale-cota ale-cota marked this pull request as ready for review May 6, 2024 13:40
@ale-cota ale-cota requested review from a team May 6, 2024 13:41
@vivianyentran vivianyentran self-requested a review May 6, 2024 17:28

## Frontend Examples

| **Use Case** | **Metric Type** | **Example** |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| **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 />&nbsp;`tags: { browser: "Firefox", subpage: "signup" }`<br />`});` |
| Number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br />&nbsp;`tags: { plan_type: “freemium” }`<br />`});` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br />&nbsp;`tags: { plan_type: “freemium” }`<br />`});` |
| Count number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br />&nbsp;`tags: { plan_type: “freemium” }`<br />`});` |

| -------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Count button clicks on subpages | counter | `Sentry.metrics.increment("button_click", 1, {`<br />&nbsp;`tags: { browser: "Firefox", subpage: "signup" }`<br />`});` |
| Number of user signups | counter | `Sentry.metrics.increment("signups", 1, {`<br />&nbsp;`tags: { plan_type: “freemium” }`<br />`});` |
| Measure UX improvement to signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br />&nbsp;`tags: { subpage: “signup” },`<br />&nbsp;`unit: “second”`<br />`});` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Measure UX improvement to signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br />&nbsp;`tags: { subpage: “signup” },`<br />&nbsp;`unit: “second”`<br />`});` |
| Measure the UX improvement to a signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br />&nbsp;`tags: { subpage: “signup” },`<br />&nbsp;`unit: “second”`<br />`});` |

| Measure UX improvement to signup form | distribution | `Sentry.metrics.distribution("login.time_to_finish_form", 14.3, {`<br />&nbsp;`tags: { subpage: “signup” },`<br />&nbsp;`unit: “second”`<br />`});` |
| Track the loading times for a component | distribution | `Sentry.metrics.distribution("component_load_time", 15.0, {`<br />&nbsp;`tags: { type: "important" },`<br />&nbsp;`unit: "millisecond"`<br />`});` |
| Track API request payloads | distribution | `Sentry.metrics.distribution("api_request_payload", 136.3, {`<br />&nbsp;`tags: { api_name: “maps_provider”, subpage: “signup” },`<br />&nbsp;`unit: “kilobyte”`<br />`});` |
| Count concurrent users in application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br />&nbsp;`tags: { browser: "Firefox" }`<br />`});` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Count concurrent users in application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br />&nbsp;`tags: { browser: "Firefox" }`<br />`});` |
| Count concurrent users in the application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br />&nbsp;`tags: { browser: "Firefox" }`<br />`});` |

| Count concurrent users in application | gauge | `Sentry.metrics.gauge("concurrent_users", 10, {`<br />&nbsp;`tags: { browser: "Firefox" }`<br />`});` |
| Track the number of items in a shopping cart | gauge | `Sentry.metrics.gauge("shopping_cart_item_count", itemCount, {`<br />&nbsp;`tags: { platform: "web" }`<br />`});` |
| Count the unique number of users on a page | set | `Sentry.metrics.set("user_view", "jane", {`<br />&nbsp;`tags: {"page": "/home" }`<br />`});` |
| Count unique number of user sessions | set | `Sentry.metrics.set("unique_active_sessions", sessionId, {`<br />&nbsp;`tags: { platform: "mobile" }`<br />`});` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Count unique number of user sessions | set | `Sentry.metrics.set("unique_active_sessions", sessionId, {`<br />&nbsp;`tags: { platform: "mobile" }`<br />`});` |
| Count the unique number of user sessions | set | `Sentry.metrics.set("unique_active_sessions", sessionId, {`<br />&nbsp;`tags: { platform: "mobile" }`<br />`});` |

| Track CPU usage over time | gauge | `sentry_sdk.metrics.gauge(`<br />&nbsp;`key=”cpu_usage”,`<br />&nbsp;`value=94,`<br />&nbsp;`unit=”percent”`<br />`)` |
| Track cache hit ratio | gauge | `sentry_sdk.metrics.gauge(`<br />&nbsp;`key=”cache_hit_ratio”,`<br />&nbsp;`value=85,`<br />&nbsp;`unit=”percent”`<br />`)` |
| Count unique server ids running a software version | set | `sentry_sdk.metrics.set(`<br />&nbsp;`key=”server_ids_running”,`<br />&nbsp;`value=“server_id”,`<br />&nbsp;`tags={"software_version": software_version}`<br />`)` |
| Track number of unique DB queries executed | set | `sentry_sdk.metrics.set(`<br />&nbsp;`key=”db_queries”,`<br />&nbsp;`value=query,`<br />&nbsp;`tags={"query_type": "read"}`<br />`)` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Track number of unique DB queries executed | set | `sentry_sdk.metrics.set(`<br />&nbsp;`key=”db_queries”,`<br />&nbsp;`value=query,`<br />&nbsp;`tags={"query_type": "read"}`<br />`)` |
| Track the number of unique DB queries executed | set | `sentry_sdk.metrics.set(`<br />&nbsp;`key=”db_queries”,`<br />&nbsp;`value=query,`<br />&nbsp;`tags={"query_type": "read"}`<br />`)` |


| **Use Case** | **Metric Type** | **Example** |
| -------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Count button clicks on subpages | counter | `Sentry.metrics.increment("button_click", 1, {`<br />&nbsp;`tags: { browser: "Firefox", subpage: "signup" }`<br />`});` |
Copy link
Contributor

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?

Suggested change
| Count button clicks on subpages | counter | `Sentry.metrics.increment("button_click", 1, {`<br />&nbsp;`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 />&nbsp;`tags: { browser: "Firefox", subpage: "signup" }`<br />`});` |

---
title: "Example Use Cases"
sidebar_order: 18
description: "Example Use Cases for custom metrics."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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** |
Copy link
Contributor

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

@ale-cota
Copy link
Contributor Author

Decided to go with another approach with collapsable list items.
#10000

@ale-cota ale-cota closed this May 13, 2024
@ale-cota ale-cota deleted the ale-cota-patch-4 branch May 13, 2024 13:21
@github-actions github-actions bot locked and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants