Files
zeekay 10e6fec4c0 debrand: the brand token is INSIGHTS_, and a wrong one stops the container
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO
split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live
pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the
container entrypoint, so the misspelling does not degrade a feature -- it runs
migrate --check against a database whose history this tree does not share and
the container never starts.

Both replacements are measured against the shipped tree rather than chosen:
every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL ->
INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12
determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_
tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of
the bad rule and cannot collide with an upstream name.

The rule is fixed for the next convergence, and the tree it already produced is
repaired in the same commit -- the codemod is idempotent against its own output,
so it cannot undo this itself.
2026-08-01 17:42:28 -07:00

120 lines
5.5 KiB
TypeScript

import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/shared/OnboardingDocsContentWrapper'
import { StepDefinition } from '../steps'
export const getOpenTelemetrySteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {
const { CodeBlock, Markdown, dedent } = ctx
return [
{
title: 'Scrape a Prometheus endpoint',
badge: 'recommended',
content: (
<>
<Markdown>
{dedent`
If your services already expose a Prometheus \`/metrics\` endpoint, run the Insights
metrics agent. It scrapes those endpoints and forwards them to Insights, so your
application code does not change.
`}
</Markdown>
<CodeBlock
blocks={[
{
language: 'bash',
file: 'Docker',
code: dedent`
docker run -d --name insights-metrics-agent \\
-e INSIGHTS_API_KEY=<ph_project_token> \\
-e INSIGHTS_HOST=<ph_client_api_host> \\
-e SCRAPE_TARGETS=your-app:9090,your-worker:9091 \\
insights/metrics-agent:latest
`,
},
]}
/>
<Markdown>
{dedent`
\`SCRAPE_TARGETS\` is a comma-separated list of \`host:port\` targets to scrape.
On Kubernetes, the Helm chart in \`products/metrics/agent/chart\` runs the same image.
Set \`shards\` to spread targets across a fleet, and \`persistence.enabled=true\` to keep
the export queue across restarts.
Counters and histograms scraped with OpenMetrics exemplars become clickable trace
links. Your Prometheus client has to attach the exemplars, the agent only preserves them.
`}
</Markdown>
</>
),
},
{
title: 'Send metrics over OTLP',
badge: 'optional',
content: (
<>
<Markdown>
{dedent`
If you instrument your application directly, Insights accepts metrics from any
OpenTelemetry client over OTLP HTTP. There is no Insights-specific package to install,
use the standard OpenTelemetry libraries for your language.
`}
</Markdown>
<CodeBlock
blocks={[
{
language: 'bash',
file: 'Environment variables',
code: dedent`
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT="<ph_client_api_host>/i/v1/metrics"
OTEL_EXPORTER_OTLP_METRICS_HEADERS="Authorization=Bearer <ph_project_token>"
OTEL_SERVICE_NAME="my-app"
`,
},
{
language: 'yaml',
file: 'OTel Collector',
code: dedent`
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
processors:
batch:
exporters:
otlphttp/insights:
metrics_endpoint: "<ph_client_api_host>/i/v1/metrics"
headers:
Authorization: "Bearer <ph_project_token>"
service:
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp/insights]
`,
},
]}
/>
<Markdown>
{dedent`
The endpoint accepts OTLP over HTTP as \`application/x-protobuf\` or
\`application/json\`. gRPC is not supported, use the HTTP transport instead.
Gauges, sums, histograms, exponential histograms, and summaries are all accepted.
Keep label cardinality low: values like user IDs or request IDs create a new series
each time and get rate limited.
`}
</Markdown>
</>
),
},
]
}
export const OpenTelemetryInstallation = createInstallation(getOpenTelemetrySteps)