Skip to content

Commit 5e6cff3

Browse files
lucychen-grafanaevictoreroAgnesTouletdependabot[bot]adkinsjd
authored
Image Render: Support tracing (#612)
* Image Render: Support Tracing (#586) * Add tracing * changed url ingestion and tried to extract traceparent * removing unused code * remove unused packages and add logs * add tracing info to logs and tracing configuration * fix config override * fix argv.config * fix trace initialization and starting * remove custom log format * update json * change url to env * Apply suggestions from code review Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com> * fix yarn file * prettier lint * add custom trace for browser * propagate traces back to Grafana * Add tracing to plugin mode and improve config management (#602) * add tracing to plugin mode * update dev.json * update imports * add tracing in CSV endpoints * fix tests * fix and simplify config * fix test * update config for docker * add to readme * update readme * update readme * prettier * update tracing * change config and docs * Update src/plugin/v2/grpc_plugin.ts Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com> * create new docker-compose for tracing * add serviceName to config * update yarn * Apply suggestions from code review Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com> * remove env servicename --------- Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com> Co-authored-by: AgnesToulet <35176601+AgnesToulet@users.noreply.github.com> * add CORS allow * propagate traceparent only if tracing is enabled * propagate traceparent only if tracing is enabled * Chore: Update dompurify to fix CVE (#614) * update cve * remove libraries chromium has * Chore: Downgrade to Node 20 (#619) * Release 3.12.4 (#620) * Bump axios from 1.7.4 to 1.8.2 (#610) Bumps [axios](https://github.com/axios/axios) from 1.7.4 to 1.8.2. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](axios/axios@v1.7.4...v1.8.2) --- updated-dependencies: - dependency-name: axios dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Docker: Add chromium-swiftshader to support webGL (#623) * add swiftshader * add flag --------- Co-authored-by: Joshua Adkins <adkins@berkeley.edu> * Docker: Remove unused NPM files (#625) * Docker: Remove unused NPM files * cleanup * Docker: Fix typo in Debian Dockerfile (#624) * remove cors * yarn.lock * remove tracing headers for req to other hostnames * Reapply "Image Render: Support Tracing (#586)" (#609) This reverts commit 78f1d6e. * try catch block * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * swap order nest tracing in timinf * update yarn --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com> Co-authored-by: AgnesToulet <35176601+AgnesToulet@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joshua Adkins <adkins@berkeley.edu> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0edbf3c commit 5e6cff3

29 files changed

+1885
-610
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ scripts/tmp
4040

4141
tests/testdata/diff_*
4242

43-
cache
43+
cache
44+
45+
/devenv/docker/tracing/tempo-data/

README.md

+3-42
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ A Grafana backend plugin that handles rendering panels and dashboards to PNGs us
88
- Windows (x64)
99
- Mac OS X (x64)
1010

11+
For Mac ARM64, you need to [build the plugin from source](https://github.com/grafana/grafana-image-renderer/blob/master/docs/building_from_source.md) or use the [remote rendering installation](https://github.com/grafana/grafana-image-renderer?tab=readme-ov-file#remote-rendering-service-installation).
12+
1113
### Dependencies
1214

1315
This plugin is packaged in a single executable with [Node.js](https://nodejs.org/) runtime and [Chromium browser](https://www.chromium.org/Home).
@@ -132,45 +134,4 @@ For available configuration settings, please refer to [Grafana Image Rendering d
132134
## Troubleshooting
133135

134136
For troubleshooting help, refer to
135-
[Grafana Image Rendering troubleshooting documentation](https://grafana.com/docs/grafana/latest/image-rendering/troubleshooting/).
136-
137-
## Testing
138-
139-
In order to run the image-renderer automated test suites, you need to run the following command from the root folder:
140-
141-
```
142-
yarn test
143-
```
144-
145-
This will launch a Grafana instance in Docker and, then, run the test suites.
146-
147-
_Notes:_
148-
149-
If there are some expected changes in the reference image files (located in `/tests/testdata`), run `yarn test-update` and push the updated references.
150-
151-
If the tests are failing and you want to see the difference between the image you get and the reference image, run `yarn test-diff`. This will generate images (called `diff_<test case>.png`) containing the differences in the `/tests/testdata` folder.
152-
153-
### Fixing Drone issues
154-
155-
If tests are successful in your local environement but fail in Drone. You can follow these steps to run the tests in an environment similar to the Drone pipeline. This will mount your local files of the `grafana-image-renderer` repo in the Docker image so any change that happens in the Docker image will be available in your local environment. This allows you to run `yarn test-diff` and `yarn test-update` in Docker and see the results locally.
156-
157-
1. Run the Drone environment in Docker:
158-
159-
```
160-
cd ./devenv/docker/drone
161-
docker-compose up
162-
```
163-
164-
2. Open a terminal within the `drone-docker-puppeteer` container and run the following commands:
165-
166-
```
167-
cd /drone/src
168-
PUPPETEER_CACHE_DIR=/drone/src/cache yarn install --frozen-lockfile --no-progress
169-
PUPPETEER_CACHE_DIR=/drone/src/cache CI=true yarn test-ci
170-
```
171-
172-
_Notes:_
173-
The tests might take longer in the Docker container. If you run into timeout issues, you can run the test command with the `--testTimeout option`:
174-
```
175-
PUPPETEER_CACHE_DIR=/drone/src/cache CI=true yarn test-ci --testTimeout=10000
176-
```
137+
[Grafana Image Rendering troubleshooting documentation](https://grafana.com/docs/grafana/latest/image-rendering/troubleshooting/).

default.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858

5959
"verboseLogging": false,
6060
"dumpio": false,
61-
"timingMetrics": false
61+
"timingMetrics": false,
62+
63+
"tracing": {
64+
"url": "",
65+
"serviceName": ""
66+
}
6267
}
6368
}

dev.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555

5656
"verboseLogging": true,
5757
"dumpio": false,
58-
"timingMetrics": true
58+
"timingMetrics": true,
59+
60+
"tracing": {
61+
"url": "http://localhost:4318/v1/traces",
62+
"serviceName": ""
63+
}
5964
}
6065
}

devenv/docker/custom-config/config.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
},
4545

4646
"verboseLogging": false,
47-
"dumpio": false
47+
"dumpio": false,
48+
49+
"tracing": {
50+
"url": "",
51+
"serviceName": ""
52+
}
4853
}
4954
}

devenv/docker/tracing/config.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"service": {
3+
"host": null,
4+
"port": 8081,
5+
6+
"metrics": {
7+
"enabled": true,
8+
"collectDefaultMetrics": true,
9+
"requestDurationBuckets": [1, 5, 7, 9, 11, 13, 15, 20, 30]
10+
},
11+
12+
"logging": {
13+
"level": "debug",
14+
"console": {
15+
"json": true,
16+
"colorize": false
17+
}
18+
}
19+
},
20+
"rendering": {
21+
"chromeBin": null,
22+
"args": [
23+
"--no-sandbox"
24+
],
25+
"ignoresHttpsErrors": false,
26+
27+
"timezone": null,
28+
"acceptLanguage": null,
29+
"width": 1000,
30+
"height": 500,
31+
"deviceScaleFactor": 1,
32+
"maxWidth": 3080,
33+
"maxHeight": 3000,
34+
"maxDeviceScaleFactor": 4,
35+
36+
"mode": "clustered",
37+
"clustering": {
38+
"mode": "context",
39+
"maxConcurrency": 5,
40+
"timeout": 30
41+
},
42+
43+
"verboseLogging": false,
44+
"dumpio": false,
45+
46+
"tracing": {
47+
"url": " http://tempo:4318/v1/traces",
48+
"serviceName": ""
49+
}
50+
}
51+
}
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
services:
2+
3+
# Tempo runs as user 10001, and docker compose creates the volume as root.
4+
# As such, we need to chown the volume in order for Tempo to start correctly.
5+
init:
6+
image: &tempoImage grafana/tempo:latest
7+
user: root
8+
entrypoint:
9+
- "chown"
10+
- "10001:10001"
11+
- "/var/tempo"
12+
volumes:
13+
- ./tempo-data:/var/tempo
14+
15+
memcached:
16+
image: memcached:1.6.29
17+
container_name: memcached
18+
ports:
19+
- "11211:11211"
20+
environment:
21+
- MEMCACHED_MAX_MEMORY=64m # Set the maximum memory usage
22+
- MEMCACHED_THREADS=4 # Number of threads to use
23+
24+
tempo:
25+
image: *tempoImage
26+
command: [ "-config.file=/etc/tempo.yaml" ]
27+
volumes:
28+
- ./tempo.yaml:/etc/tempo.yaml
29+
- ./tempo-data:/var/tempo
30+
ports:
31+
- "14268:14268" # jaeger ingest
32+
- "3200:3200" # tempo
33+
- "9095:9095" # tempo grpc
34+
- "4317:4317" # otlp grpc
35+
- "4318:4318" # otlp http
36+
- "9411:9411" # zipkin
37+
depends_on:
38+
- init
39+
- memcached
40+
41+
prometheus:
42+
image: prom/prometheus:latest
43+
command:
44+
- --config.file=/etc/prometheus.yaml
45+
- --web.enable-remote-write-receiver
46+
- --enable-feature=exemplar-storage
47+
- --enable-feature=native-histograms
48+
volumes:
49+
- ./prometheus.yaml:/etc/prometheus.yaml
50+
ports:
51+
- "9090:9090"
52+
53+
grafana:
54+
image: grafana/grafana:latest
55+
volumes:
56+
- ./grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
57+
environment:
58+
GF_RENDERING_SERVER_URL: http://renderer:8081/render
59+
GF_RENDERING_CALLBACK_URL: http://grafana:3000/
60+
GF_RENDERING_TRACING_URL: http://tempo:4318/v1/traces
61+
GF_LOG_FILTERS: rendering:debug
62+
GF_INSTALL_PLUGINS: https://storage.googleapis.com/integration-artifacts/grafana-exploretraces-app/grafana-exploretraces-app-latest.zip;grafana-traces-app
63+
GF_TRACING_OPENTELEMETRY_OTLP_ADDRESS: tempo:4317
64+
ports:
65+
- "3000:3000"
66+
renderer:
67+
image: grafana/grafana-image-renderer:latest
68+
ports:
69+
- 8081:8081
70+
volumes:
71+
- ./config.json:/usr/src/app/config.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: Prometheus
5+
type: prometheus
6+
uid: prometheus
7+
access: proxy
8+
orgId: 1
9+
url: http://prometheus:9090
10+
basicAuth: false
11+
isDefault: false
12+
version: 1
13+
editable: false
14+
jsonData:
15+
httpMethod: GET
16+
- name: Tempo
17+
type: tempo
18+
access: proxy
19+
orgId: 1
20+
url: http://tempo:3200
21+
basicAuth: false
22+
isDefault: true
23+
version: 1
24+
editable: false
25+
apiVersion: 1
26+
uid: tempo
27+
jsonData:
28+
httpMethod: GET
29+
serviceMap:
30+
datasourceUid: prometheus
31+
streamingEnabled:
32+
search: true
33+

devenv/docker/tracing/prometheus.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
global:
2+
scrape_interval: 15s
3+
evaluation_interval: 15s
4+
5+
scrape_configs:
6+
- job_name: 'prometheus'
7+
static_configs:
8+
- targets: [ 'localhost:9090' ]
9+
- job_name: 'tempo'
10+
static_configs:
11+
- targets: [ 'tempo:3200' ]

devenv/docker/tracing/tempo.yaml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
stream_over_http_enabled: true
2+
server:
3+
http_listen_port: 3200
4+
log_level: info
5+
6+
7+
cache:
8+
background:
9+
writeback_goroutines: 5
10+
caches:
11+
- roles:
12+
- frontend-search
13+
memcached:
14+
addresses: dns+memcached:11211
15+
16+
query_frontend:
17+
search:
18+
duration_slo: 5s
19+
throughput_bytes_slo: 1.073741824e+09
20+
metadata_slo:
21+
duration_slo: 5s
22+
throughput_bytes_slo: 1.073741824e+09
23+
trace_by_id:
24+
duration_slo: 100ms
25+
metrics:
26+
max_duration: 120h # maximum duration of a metrics query, increase for local setups
27+
query_backend_after: 5m
28+
duration_slo: 5s
29+
throughput_bytes_slo: 1.073741824e+09
30+
31+
distributor:
32+
receivers: # this configuration will listen on all ports and protocols that tempo is capable of.
33+
jaeger: # the receives all come from the OpenTelemetry collector. more configuration information can
34+
protocols: # be found there: https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver
35+
thrift_http: #
36+
endpoint: "tempo:14268" # for a production deployment you should only enable the receivers you need!
37+
grpc:
38+
endpoint: "tempo:14250"
39+
thrift_binary:
40+
endpoint: "tempo:6832"
41+
thrift_compact:
42+
endpoint: "tempo:6831"
43+
zipkin:
44+
endpoint: "tempo:9411"
45+
otlp:
46+
protocols:
47+
grpc:
48+
endpoint: "tempo:4317"
49+
http:
50+
endpoint: "tempo:4318"
51+
opencensus:
52+
endpoint: "tempo:55678"
53+
54+
ingester:
55+
max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally
56+
57+
compactor:
58+
compaction:
59+
block_retention: 24h # overall Tempo trace retention. set for demo purposes
60+
61+
metrics_generator:
62+
registry:
63+
external_labels:
64+
source: tempo
65+
cluster: docker-compose
66+
storage:
67+
path: /var/tempo/generator/wal
68+
remote_write:
69+
- url: http://prometheus:9090/api/v1/write
70+
send_exemplars: true
71+
traces_storage:
72+
path: /var/tempo/generator/traces
73+
processor:
74+
local_blocks:
75+
filter_server_spans: false
76+
flush_to_storage: true
77+
78+
storage:
79+
trace:
80+
backend: local # backend configuration to use
81+
wal:
82+
path: /var/tempo/wal # where to store the wal locally
83+
local:
84+
path: /var/tempo/blocks
85+
86+
overrides:
87+
defaults:
88+
metrics_generator:
89+
processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator
90+
generate_native_histograms: both
91+

docs/building_from_source.md

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ cd grafana-image-renderer
2424
# build and package for Darwin x64
2525
make build_package ARCH=darwin-x64-unknown
2626

27+
# build and package for Mac ARM64
28+
make build_package ARCH=darwin-arm64-unknown
29+
2730
# build and package without including Chromium
2831
make build_package ARCH=<ARCH> SKIP_CHROMIUM=true OUT=plugin-<ARCH>-no-chromium
2932
```

docs/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Use the following links for instructions on how to:
33

44
- [Build the image renderer from source](building_from_source.md)
55
- [Package plugin as a single executable](package_plugin_as_single_executable.md)
6-
- [Release and publish a new version](release_new_version.md)
6+
- [Release and publish a new version](release_new_version.md)
7+
- [Testing instructions](testing.md)

0 commit comments

Comments
 (0)