Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example/metric : Add exponential_histogram README and reorganize fold…
…ers. (#821) * metric/exponential_histogram : Add README. * metric/export : Reorganize example/metric folders. * exponential_histogram: Change dashboard display name. * example: Remove binaries. * exponential_histogram: Improve README. * metric/example : Revert folder reorg. * example/metric : Create "dashboards" folder and organize. * Update copyright date. * exponential_histogram : Fix conflicting module name * example/metric : Improve README's. * exponential_histogram : Fix images path. * example/metric : Improve README's further. * sdk : Fix images path. * example/metric : Small README improvements. * example/metric : Make build and run instructions example agnostic.
- Loading branch information
1 parent
ed7ca96
commit 71d9493
Showing
11 changed files
with
124 additions
and
28 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
2 changes: 1 addition & 1 deletion
2
...tric/exponential_histogram/dashboard.json → ...ards/exponential_histogram_dashboard.json
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
File renamed without changes.
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,47 @@ | ||
# Google Cloud Monitoring exponential histogram example | ||
|
||
This example shows how to use [`go.opentelemetry.io/otel`](https://pkg.go.dev/go.opentelemetry.io/otel/) to instrument a simple Go application with metrics and export the metrics to [Google Cloud Monitoring](https://cloud.google.com/monitoring/) | ||
|
||
## Example details | ||
|
||
This example simulates server latency by sampling a [Log-Normal Distribution](https://en.wikipedia.org/wiki/Log-normal_distribution) with the parameters $\mu = 3.5 , 5.5$ and $\sigma = .5$. We generate the following three example of server latency : | ||
|
||
1. Latency with Log-Normal Distribution. | ||
2. Latency with Shifted Mean Distribution. | ||
3. Latency with Multimodal Distribution (mixture of 1. and 2.). | ||
|
||
We explore the resulting distributions with three types of histograms : | ||
|
||
1. Opentelemetry Default Linear Buckets Histogram. Buckets are `0, 5, 10, 25, 50, 75, 100, 250, 500, 1000` | ||
2. Opentelemetry Linear Buckets Histogram. Buckets are `0, 10, 20, 30, ..., 340, 350`. | ||
3. Opentelemetry Exponential Buckets Histogram with default parameters. | ||
|
||
## Build and run the application | ||
|
||
Go to the [example/metric/README.md](../README.md) instructions that describe how to build and run all examples. | ||
|
||
## Sample execution | ||
|
||
``` | ||
$ ./metrics | ||
2024/03/21 15:38:58 Sent Latency Data (Original Distribution): #points 1000 , mean 36.64255895183214, sdv 19.670797833645373 | ||
2024/03/21 15:38:58 Sent Latency Data (Shifted Distribution): #points 1000 , mean 277.70002931783233, sdv 143.59582355437485 | ||
2024/03/21 15:38:58 Sent Latency Data (Multimodal Distribution): #points 1000 , mean 151.49111863163805, sdv 159.2187295223318 | ||
... | ||
``` | ||
|
||
## Create dashboard | ||
|
||
When filling in the **Find resource type and metric box**, use the metric names with the prefix "workload.googleapis.com/latency_" to observe histogram metrics (for example "workload.googleapis.com/latency_a"). | ||
|
||
If you already know how to use Cloud Monitoring and would just like to confirm the data is properly received, you can run the dashboard creation script bundled in this directory. This command requires at least the [roles/monitoring.dashboardEditor](https://cloud.google.com/monitoring/access-control#dashboard_roles_desc) permissions to create a new dashboard. | ||
|
||
``` | ||
$ ./create_dashboard.sh | ||
``` | ||
|
||
This script creates a dashboard titled "OpenTelemetry - Exponential Histogram example". | ||
|
||
You should be able to view histogram charts like below once you create the dashboard. | ||
|
||
<img width="1200" alt="2 charts in dashboard" src="../images/exponential_histogram_charts.png?raw=true"/> |
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,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2024 Google LLC | ||
# | ||
# 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. | ||
|
||
# This dashboard is intended to show the metrics emit from the example | ||
# in the same directory. | ||
# https://cloud.google.com/monitoring/dashboards/api-dashboard | ||
gcloud monitoring dashboards create --config-from-file=--config-from-file=../dashboards/exponential_histogram_dashboard.json |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file not shown.
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,35 @@ | ||
# Google Cloud Monitoring exporter example | ||
|
||
This example shows how to use [`go.opentelemetry.io/otel`](https://pkg.go.dev/go.opentelemetry.io/otel/) to instrument a simple Go application with metrics and export the metrics to [Google Cloud Monitoring](https://cloud.google.com/monitoring/) | ||
|
||
## Build and run the application | ||
|
||
Go to the [example/metric/README.md](../README.md) instructions that describe how to build and run all examples. | ||
|
||
## Sample execution | ||
|
||
``` | ||
$ ./metrics | ||
2020/06/11 21:11:15 Most recent data: counter 110, observer 13.45 | ||
2020/06/11 21:11:15 Most recent data: counter 160, observer 16.02 | ||
2020/06/11 21:11:15 Most recent data: counter 134, observer 14.33 | ||
2020/06/11 21:11:15 Most recent data: counter 125, observer 15.12 | ||
... | ||
``` | ||
|
||
## Create dashboard | ||
|
||
When filling in the **Find resource type and metric box**, use the metric names "custom.googleapis.com/opentelemetry/counter-a" and "custom.googleapis.com/opentelemetry/observer-a". | ||
|
||
If you already know how to use Cloud Monitoring and would just like to confirm the data is properly received, you can run the dashboard creation script bundled in this directory. This command requires at least the [roles/monitoring.dashboardEditor](https://cloud.google.com/monitoring/access-control#dashboard_roles_desc) permissions to create a new dashboard. | ||
``` | ||
$ ./create_dashboard.sh | ||
``` | ||
|
||
This script creates a dashboard titled "OpenTelemetry exporter example/metric". | ||
|
||
You should be able to view line charts like below once you create the dashboard. | ||
|
||
*Note: This script is configured to create dashboard which displays the metrics generated via the `sdk` example.* | ||
|
||
<img width="1200" alt="2 charts in dashboard" src="../images/sdk_charts.png?raw=true"/> |
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