Skip to content

Commit 9db1a44

Browse files
committed
feat: convert mermaid code blocks to svgs client side
1 parent 3b292c8 commit 9db1a44

File tree

2 files changed

+100
-7
lines changed

2 files changed

+100
-7
lines changed

develop-docs/application/architecture.mdx

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,31 @@ sidebar_order: 1
77

88
Edges represent service dependencies.
99

10-
![](https://mermaid.ink/svg/pako:eNqFU01PwzAM_StRTiDGeu8BCbQbcKFc0DwhN_XWqs2H0kQwtv13smSj1SrgFj8_v9gvzo4LXRHP-caiqdnrAhQas3zT3rJ7Y7pGoGu0WrHb2zu2LxaPe9aVu92Txoo9YIdKkD0cQHVlYgDvSTm7ndMnStPRXGiZoWkygOom6522lAHfM0sdbv8uO9IS-v5B5RJ4EQN2FaJr4CtQ_VaWOraobdQZ6KDiDRFtcd3iGLBUNX0o_2GnYuVLnKCSpEBRUzXJGN27jaWp0Fn-qDduYAAmDBGmaGvtewIV2RH90rolMmSnvZ5CbVuyY2sicHJnzPltliF5YcqQmM455MYvAApUnCM5yYDXzpk-z7JN42pfxlXYkEsqWbKbB1oR6QstvAypuG_Az1rp1f7RStt01HqJ9AstPuOSrMSmCou-A8UC0dUkCXgejhWt0XfueOchUNE7XWyV4LmznmbcmwodLRoMX0TyfI1dH9DgVpj5OX2e-IcO3z0YL2M)
11-
[diagram source](https://mermaid.live/edit#pako:eNqFU01PwzAM_StRTiDGeu8BCbQbcKFc0DwhN_XWqs2H0kQwtv13smSj1SrgFj8_v9gvzo4LXRHP-caiqdnrAhQas3zT3rJ7Y7pGoGu0WrHb2zu2LxaPe9aVu92Txoo9YIdKkD0cQHVlYgDvSTm7ndMnStPRXGiZoWkygOom6522lAHfM0sdbv8uO9IS-v5B5RJ4EQN2FaJr4CtQ_VaWOraobdQZ6KDiDRFtcd3iGLBUNX0o_2GnYuVLnKCSpEBRUzXJGN27jaWp0Fn-qDduYAAmDBGmaGvtewIV2RH90rolMmSnvZ5CbVuyY2sicHJnzPltliF5YcqQmM455MYvAApUnCM5yYDXzpk-z7JN42pfxlXYkEsqWbKbB1oR6QstvAypuG_Az1rp1f7RStt01HqJ9AstPuOSrMSmCou-A8UC0dUkCXgejhWt0XfueOchUNE7XWyV4LmznmbcmwodLRoMX0TyfI1dH9DgVpj5OX2e-IcO3z0YL2M)
12-
10+
```mermaid
11+
graph TD
12+
app[Your Application] --> |SDK| lb{{Load Balancer}}
13+
lb --> |"sentry.example.com/api/\d+/store/"| relay
14+
lb --> |"sentry.example.com"| sentry_web["Sentry (web)"]
15+
symbolicator --> sentry_web
16+
relay --> kafka
17+
relay --> redis
18+
sentry_web --> snuba
19+
sentry_web --> memcached
20+
sentry_web --> postgres
21+
sentry_web --> redis
22+
snuba --> kafka
23+
snuba --> redis
24+
snuba --> clickhouse
25+
kafka --> zookeeper
26+
sentry_web --> sentry_worker["Sentry (worker)"]
27+
sentry_worker --> memcached
28+
sentry_worker --> redis
29+
sentry_worker --> postgres
30+
sentry_worker --> symbolicator
31+
32+
click snuba "https://github.com/getsentry/snuba" "Snuba Documentation"
33+
click relay "https://github.com/getsentry/relay" "Relay Documentation"
34+
```
1335
## Event pipeline
1436

1537
How an event gets saved. Edges represent data flow through system.
@@ -25,8 +47,29 @@ This graph is extremely simplified mostly due to layout constraints. Missing fro
2547

2648
For more information read [Path of an event through Relay](https://getsentry.github.io/relay/relay_server/index.html#path-of-an-event-through-relay) and [Event Ingestion Pipeline](https://getsentry.github.io/event-ingestion-graph/).
2749

28-
![](https://mermaid.ink/svg/pako:eNp9UsFugzAM_ZUop1Uq4o6mXtbLNO3UXSbSgwluQUCC4qQaovz7QqArbdWdEtvPz_azey51jjzhRwNtwb62QgkFbZt-a2eY_9SlBFtqtWdRtGFnQpUTkwaoQDqzOut7dSzVzzAIVWcTJoa2jFVMVhuMz8xgDZ1Q4QmACg4VpC_v6ohk2cdorfZCBXcAlCESSa3INWhSwXeorOnmALsEBPdpd-BA0BpsjZZIFOHJp45DkcumGSXWaLor6WQzC1RRYGQP-YGU4IQXuieQu6LPiLom00HXBd-D8xnh_21drSmoXAbRLLifeDQnxV8zs3kJQLIGoVkJPi7Br_dGrECQzpmzOgvSRZHltkKZi4Nu0m72JP3AVaEd4djd25-16IWvuUc3UOb-SPuRR3BbYOMxif_meABXW8GFGjwUnNW7TkmeWONwzV2be0G3JfhpGp4coCbvxbz0t_k5HX64_-EXvdQVKA)
29-
[diagram source](https://mermaid.live/edit#pako:eNp9UsFugzAM_ZUop1Uq4o6mXtbLNO3UXSbSgwluQUCC4qQaovz7QqArbdWdEtvPz_azey51jjzhRwNtwb62QgkFbZt-a2eY_9SlBFtqtWdRtGFnQpUTkwaoQDqzOut7dSzVzzAIVWcTJoa2jFVMVhuMz8xgDZ1Q4QmACg4VpC_v6ohk2cdorfZCBXcAlCESSa3INWhSwXeorOnmALsEBPdpd-BA0BpsjZZIFOHJp45DkcumGSXWaLor6WQzC1RRYGQP-YGU4IQXuieQu6LPiLom00HXBd-D8xnh_21drSmoXAbRLLifeDQnxV8zs3kJQLIGoVkJPi7Br_dGrECQzpmzOgvSRZHltkKZi4Nu0m72JP3AVaEd4djd25-16IWvuUc3UOb-SPuRR3BbYOMxif_meABXW8GFGjwUnNW7TkmeWONwzV2be0G3JfhpGp4coCbvxbz0t_k5HX64_-EXvdQVKA)
50+
```mermaid
51+
graph TD
52+
53+
app[Your application] --> |sends crashes| lb{{nginx}}
54+
lb --> |/api/n/store/| relay
55+
relay --> kafka[(Ingest Kafka)]
56+
kafka --> ingest-consumer["Sentry ingest consumer"]
57+
ingest-consumer --> preprocess-event
58+
59+
subgraph celery["Sentry celery tasks"]
60+
preprocess-event --> save-event
61+
preprocess-event --> process-event
62+
preprocess-event --> symbolicate-event
63+
symbolicate-event --> process-event
64+
process-event --> save-event
65+
save-event --> snuba-kafka[("Snuba Kafka<br>(eventstream)")]
66+
end
67+
68+
subgraph snuba["Snuba"]
69+
snuba-kafka --> snuba-consumer["Snuba consumers"]
70+
snuba-consumer --> clickhouse[("Clickhouse")]
71+
end
72+
```
3073

3174
## Multi-Region
3275

@@ -71,8 +114,26 @@ In addition to the siloed modes, there also exists a **Monolith** mode. In monol
71114

72115
### Multi-region architecture
73116

74-
![multi-region architecture](https://mermaid.ink/svg/pako:eNp1UctqwzAQ_JVFpxSSH_ChUOoUeiiEuD5JOajS2hbIktGjJYT8e1dumjotvS2zs_NgT0x5jaxinfUfapAhwWstnHDZ8KfgXUKnoX0-wGZzDzmGsphnFa8j5lAuhIv5rQ9yGgoReNvAHnvj3UE4IEhOpmANuhSO8LC7ik49X9Fi52PqA8a7H_6FgJqvti1s3-kUaplkoVCwhaOKwB8pbvAWGmP9rKGK5RL9Y66K9zdjGeBWnRoCpwSLPpiLOGG_JTEXTVrc9pn5F8J_fdiajRhGaTQ95FSuBEsDjihYRaPGTmabBBPuTFSZk2-OTrEqhYxrlictE9ZGUuaRVZ20kVDUJvnw8vXk-dfnT1dDqnk)
75-
[diagram source](https://mermaid.live/edit#pako:eNp1UctqwzAQ_JVFpxSSH_ChUOoUeiiEuD5JOajS2hbIktGjJYT8e1dumjotvS2zs_NgT0x5jaxinfUfapAhwWstnHDZ8KfgXUKnoX0-wGZzDzmGsphnFa8j5lAuhIv5rQ9yGgoReNvAHnvj3UE4IEhOpmANuhSO8LC7ik49X9Fi52PqA8a7H_6FgJqvti1s3-kUaplkoVCwhaOKwB8pbvAWGmP9rKGK5RL9Y66K9zdjGeBWnRoCpwSLPpiLOGG_JTEXTVrc9pn5F8J_fdiajRhGaTQ95FSuBEsDjihYRaPGTmabBBPuTFSZk2-OTrEqhYxrlictE9ZGUuaRVZ20kVDUJvnw8vXk-dfnT1dDqnk)
117+
```mermaid
118+
flowchart TD
119+
120+
ui[Frontend UI] --> usr
121+
ui --> cs
122+
ui --> eur
123+
124+
125+
subgraph usr [US Region]
126+
usapi[US Sentry API] --> uspg[(US Postgres)]
127+
usapi --> used[(EU Event Data)]
128+
end
129+
subgraph cs [Control Silo]
130+
capi[Control Silo Sentry API] --> cpg[(Control Postgres)]
131+
end
132+
subgraph eur [EU Region]
133+
euapi[EU Sentry API] --> eupg[(EU Postgres)]
134+
euapi --> eued[(EU Event Data)]
135+
end
136+
```
76137

77138
Each region silo can be scaled independently, and is isolated from other regions. Within each region exists separate, dedicated infrastructure and applications as outlined in the [application overview](/architecture/#high-level-overview).
78139

src/components/docPage/index.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {ReactNode} from 'react';
2+
import Script from 'next/script';
23

34
import {getCurrentGuide, getCurrentPlatform, nodeForPath} from 'sentry-docs/docTree';
45
import {serverContext} from 'sentry-docs/serverContext';
@@ -54,6 +55,9 @@ export function DocPage({
5455

5556
const leafNode = nodeForPath(rootNode, unversionedPath);
5657

58+
// a hack to show syntax highlighting on editors
59+
const javascript = String.raw;
60+
5761
return (
5862
<div className="tw-app">
5963
<Header pathname={pathname} searchPlatforms={searchPlatforms} />
@@ -108,6 +112,34 @@ export function DocPage({
108112
)}
109113
</main>
110114
</section>
115+
{/* can't use useEffect here (server component) */}
116+
<Script
117+
type="module"
118+
id="mermaid-script"
119+
dangerouslySetInnerHTML={{
120+
__html: javascript`
121+
const mermaidBlocks = document.querySelectorAll('.language-mermaid');
122+
if (mermaidBlocks.length >= 0) {
123+
const {default: mermaid} = await import(
124+
'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs'
125+
);
126+
mermaid.initialize({startOnLoad: false});
127+
mermaidBlocks.forEach(block => {
128+
// get rid of code highlighting
129+
const code = block.textContent;
130+
block.innerHTML = code;
131+
// force transparent background
132+
block.style.backgroundColor = 'transparent';
133+
const parentCodeTabs = block.closest('.code-tabs-wrapper')
134+
if(parentCodeTabs) {
135+
parentCodeTabs.innerHTML = block.outerHTML;
136+
}
137+
});
138+
await mermaid.run({nodes: document.querySelectorAll('.language-mermaid')});
139+
}
140+
`,
141+
}}
142+
/>
111143
</div>
112144
);
113145
}

0 commit comments

Comments
 (0)