Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(dev): Limit local otel-collector perf impact (#68414)

Michael Matlokab3116ea13ab1
diff --git a/docker-compose.base.yml b/docker-compose.base.yml
index 5bbd6cf6a7d3..9d9425781acd 100644
--- a/docker-compose.base.yml
+++ b/docker-compose.base.yml
@@ -792,6 +792,18 @@ services:
- jaeger
networks:
- otel_network
+ # Cap the footprint: the collector parses every container's logs, so one
+ # log-flooding container could otherwise peg many cores and balloon RAM.
+ cpus: 2
+ mem_limit: 2g
+ environment:
+ # Keep Go's GC under mem_limit so pressure triggers collection, not an OOM kill.
+ GOMEMLIMIT: 1750MiB
+ logging:
+ driver: json-file
+ options:
+ max-size: '50m'
+ max-file: '3'
jaeger:
image: jaegertracing/all-in-one:1.76.0
diff --git a/otel-collector-config.dev.yaml b/otel-collector-config.dev.yaml
index 3e8758474ce1..60839f3c0459 100644
--- a/otel-collector-config.dev.yaml
+++ b/otel-collector-config.dev.yaml
@@ -97,6 +97,9 @@ exporters:
headers:
# special "local" token is automatically mapped to team_id 1 in dev environments
authorization: Bearer phc_local
+ # Give up in 30s (vs the 5 min default) when capture-logs is down.
+ retry_on_failure:
+ max_elapsed_time: 30s
otlphttp/logs:
endpoint: 'http://host.docker.internal:4320'
compression: none
@@ -105,6 +108,8 @@ exporters:
headers:
# special "local" token is automatically mapped to team_id 1 in dev environments
authorization: Bearer phc_local
+ retry_on_failure:
+ max_elapsed_time: 30s
otlphttp/metrics:
endpoint: 'http://host.docker.internal:4320'
compression: none
@@ -112,26 +117,35 @@ exporters:
insecure: true
headers:
authorization: Bearer phc_local
+ retry_on_failure:
+ max_elapsed_time: 30s
processors:
+ # Shed load instead of buffering to multiple GB of RAM when a downstream
+ # (e.g. capture-logs) is unreachable.
+ memory_limiter:
+ check_interval: 1s
+ limit_mib: 512
+ spike_limit_mib: 128
batch:
service:
pipelines:
traces:
receivers: [otlp]
- processors: [batch]
+ processors: [memory_limiter, batch]
exporters: [otlp, otlphttp]
logs:
exporters:
- otlphttp/logs
processors:
+ - memory_limiter
- batch
receivers:
- otlp
- receiver_creator
metrics:
receivers: [otlp, prometheus]
- processors: [batch]
+ processors: [memory_limiter, batch]
exporters: [otlphttp/metrics]
extensions: [docker_observer, health_check, zpages] # Enabling the declared extensions