-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upsteam/main' into service-provider-cal…
…lbacks
- Loading branch information
Showing
71 changed files
with
3,027 additions
and
796 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,3 +345,6 @@ ASALocalRun/ | |
/.sonarqube | ||
|
||
/src/LastMajorVersionBinaries | ||
|
||
# Tempo files | ||
tempo-data/ |
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
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,99 @@ | ||
# Using Exemplars in OpenTelemetry .NET | ||
|
||
Exemplars are example data points for aggregated data. They provide specific | ||
context to otherwise general aggregations. One common use case is to gain | ||
ability to correlate metrics to traces (and logs). While OpenTelemetry .NET | ||
supports Exemplars, it is only useful if the telemetry backend also supports the | ||
capabilities. This tutorial uses well known open source backends to demonstrate | ||
the concept. The following are the components involved: | ||
|
||
* Test App - We use existing example app from the repo. This app is already | ||
instrumented with OpenTelemetry for logs, metrics and traces, and is configured | ||
to export them to the configured OTLP end point. | ||
* OpenTelemetry Collector - An instance of collector is run, which receives | ||
telemetry from the above app using OTLP. The collector then exports metrics to | ||
Prometheus, traces to Tempo. | ||
* Prometheus - Prometheus is used as the Metric backend. | ||
* Tempo - Tempo is used as the Tracing backend. | ||
* Grafana - UI to query metrics from Prometheus, traces from Tempo, and to | ||
navigate between metrics and traces using Exemplar. | ||
|
||
All these components except the test app require additional configuration to | ||
enable Exemplar feature. To make it easy for users, these components are | ||
pre-configured to enable Exemplars, and a docker-compose is provided to spun | ||
them all up, in the required configurations. | ||
|
||
## Pre-requisite | ||
|
||
Install docker: <https://docs.docker.com/get-docker/> | ||
|
||
## Setup | ||
|
||
As mentioned in the intro, this tutorial uses OTel Collector, Prometheus, Tempo, | ||
and Grafana, and they must be up and running before proceeding. The following | ||
spins all of them with the correct configurations to support Exemplars. | ||
|
||
Navigate to current directory and run the following: | ||
|
||
```sh | ||
docker-compose up -d | ||
``` | ||
|
||
If the above step succeeds, all dependencies would be spun up and ready now. To | ||
test, navigate to Grafana running at: "http://localhost:3000/". | ||
|
||
## Run test app | ||
|
||
Now that the required dependencies are ready, lets run the demo app. | ||
This tutorial is using the existing ASP.NET Core app from the repo. | ||
|
||
Navigate to [Example Asp.Net Core App](../../../examples/AspNetCore/Program.cs) | ||
directory and run the following command: | ||
|
||
```sh | ||
dotnet run | ||
``` | ||
|
||
Once the application is running, navigate to | ||
[http://localhost:5000/weatherforecast]("http://localhost:5000/weatherforecast") | ||
from a web browser. You may use the following Powershell script to generate load | ||
to the application. | ||
|
||
```powershell | ||
while($true) | ||
{ | ||
Invoke-WebRequest http://localhost:5000/weatherforecast | ||
Start-Sleep -Milliseconds 500 | ||
} | ||
``` | ||
|
||
## Use Exemplars to navigate from Metrics to Traces | ||
|
||
The application sends metrics (with exemplars), and traces to the OTel | ||
Collector, which export metrics and traces to Prometheus and Tempo | ||
respectively. | ||
|
||
Please wait for 2 minutes before continuing so that enough data is generated | ||
and exported. | ||
|
||
Open Grafana, select Explore, and select Prometheus as the source. Select the | ||
metric named "http_server_duration_bucket", and plot the chart. Toggle on the | ||
"Exemplar" option from the UI and hit refresh. | ||
|
||
![Enable Exemplar](https://user-images.githubusercontent.com/16979322/218627781-9886f837-11ae-4d52-94d3-f1821503209c.png) | ||
|
||
The Exemplars appear as special "diamond shaped dots" along with the metric | ||
charts in the UI. Select any Exemplar to see the exemplar data, which includes | ||
the timestamp when the measurement was recorded, the raw value, and trace | ||
context when the recording was done. The "trace_id" enables jumping to the | ||
tracing backed (tempo). Click on the "Query with Tempo" button next to the | ||
"trace_id" field to open the corresponding `Trace` in Tempo. | ||
|
||
![Navigate to trace with exemplar](https://user-images.githubusercontent.com/16979322/218629999-1d1cd6ba-2385-4683-975a-d4797df8361a.png) | ||
|
||
## References | ||
|
||
* [Exemplar specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplar) | ||
* [Exemplars in Prometheus](https://prometheus.io/docs/prometheus/latest/feature_flags/#exemplars-storage) | ||
* [Exemplars in Grafana](https://grafana.com/docs/grafana/latest/fundamentals/exemplars/) | ||
* [Tempo](https://github.com/grafana/tempo) |
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,51 @@ | ||
version: "3" | ||
services: | ||
|
||
# OTEL Collector to receive logs, metrics and traces from the application | ||
otel-collector: | ||
image: otel/opentelemetry-collector:0.70.0 | ||
command: [ "--config=/etc/otel-collector.yaml" ] | ||
volumes: | ||
- ./otel-collector.yaml:/etc/otel-collector.yaml | ||
ports: | ||
- "4317:4317" | ||
- "4318:4318" | ||
- "9201:9201" | ||
|
||
# Exports Traces to Tempo | ||
tempo: | ||
image: grafana/tempo:latest | ||
command: [ "-config.file=/etc/tempo.yaml" ] | ||
volumes: | ||
- ./tempo.yaml:/etc/tempo.yaml | ||
- ./tempo-data:/tmp/tempo | ||
ports: | ||
- "3200" # tempo | ||
- "4317" # otlp grpc | ||
- "4318" # otlp http | ||
|
||
# Exports Metrics to Prometheus | ||
prometheus: | ||
image: prom/prometheus:latest | ||
command: | ||
- --config.file=/etc/prometheus.yaml | ||
- --web.enable-remote-write-receiver | ||
- --enable-feature=exemplar-storage | ||
volumes: | ||
- ./prometheus.yaml:/etc/prometheus.yaml | ||
ports: | ||
- "9090:9090" | ||
|
||
# UI to query traces and metrics | ||
grafana: | ||
image: grafana/grafana:9.3.2 | ||
volumes: | ||
- ./grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml | ||
environment: | ||
- GF_AUTH_ANONYMOUS_ENABLED=true | ||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | ||
- GF_AUTH_DISABLE_LOGIN_FORM=true | ||
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor | ||
ports: | ||
- "3000:3000" | ||
|
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,33 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Prometheus | ||
type: prometheus | ||
uid: prometheus | ||
access: proxy | ||
orgId: 1 | ||
url: http://prometheus:9090 | ||
basicAuth: false | ||
isDefault: true | ||
version: 1 | ||
editable: false | ||
jsonData: | ||
httpMethod: GET | ||
exemplarTraceIdDestinations: | ||
- name: trace_id | ||
datasourceUid: Tempo | ||
- name: Tempo | ||
type: tempo | ||
access: proxy | ||
orgId: 1 | ||
url: http://tempo:3200 | ||
basicAuth: false | ||
isDefault: false | ||
version: 1 | ||
editable: false | ||
apiVersion: 1 | ||
uid: tempo | ||
jsonData: | ||
httpMethod: GET | ||
serviceMap: | ||
datasourceUid: prometheus |
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,30 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
|
||
exporters: | ||
logging: | ||
loglevel: debug | ||
prometheus: | ||
endpoint: ":9201" | ||
send_timestamps: true | ||
metric_expiration: 180m | ||
enable_open_metrics: true | ||
otlp: | ||
endpoint: tempo:4317 | ||
tls: | ||
insecure: true | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
exporters: [logging,otlp] | ||
metrics: | ||
receivers: [otlp] | ||
exporters: [logging,prometheus] | ||
logs: | ||
receivers: [otlp] | ||
exporters: [logging] |
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,8 @@ | ||
global: | ||
scrape_interval: 15s | ||
evaluation_interval: 15s | ||
|
||
scrape_configs: | ||
- job_name: 'otel' | ||
static_configs: | ||
- targets: [ 'otel-collector:9201' ] |
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,17 @@ | ||
server: | ||
http_listen_port: 3200 | ||
|
||
distributor: | ||
receivers: | ||
otlp: | ||
protocols: | ||
http: | ||
grpc: | ||
|
||
storage: | ||
trace: | ||
backend: local | ||
wal: | ||
path: /tmp/tempo/wal | ||
local: | ||
path: /tmp/tempo/blocks |
Oops, something went wrong.