|
5 | 5 | # variable. Without it Compose renders a blank image name or a blank kernel |
6 | 6 | # version and only warns, and the operator meets either a confusing "neither |
7 | 7 | # an image nor a build context" error or a fetch-artifacts failure after the |
8 | | -# host has already been mutated. The eight knobs that are genuinely optional and |
9 | | -# are absent from .env (TEAM_API_KEY, ADMIN_TOKEN, SANDBOX_ACCESS_TOKEN_HASH_SEED |
10 | | -# and E2B_DASHBOARD_HOST only as commented lines) keep the ${VAR:-...} form: HUGEPAGES, NBDS_MAX, PF_MIN_FREE_GIB, |
11 | | -# FORCE_REBUILD and E2B_DASHBOARD_HOST carry a working default, while |
| 8 | +# host has already been mutated. The nine knobs that are genuinely optional and |
| 9 | +# are absent from .env (TEAM_API_KEY, ADMIN_TOKEN, SANDBOX_ACCESS_TOKEN_HASH_SEED, |
| 10 | +# E2B_DASHBOARD_HOST and E2B_OTEL_COLLECTOR_GRPC_ENDPOINT only as commented |
| 11 | +# lines) keep the ${VAR:-...} form: HUGEPAGES, NBDS_MAX, PF_MIN_FREE_GIB, |
| 12 | +# FORCE_REBUILD, E2B_DASHBOARD_HOST and E2B_OTEL_COLLECTOR_GRPC_ENDPOINT carry a |
| 13 | +# working default (the last an empty one, which exports no telemetry), while |
12 | 14 | # TEAM_API_KEY, ADMIN_TOKEN and SANDBOX_ACCESS_TOKEN_HASH_SEED carry none — the |
13 | 15 | # stack generates all three per install (seed for the key, api-secrets for the |
14 | 16 | # api's two), and a value set in .env or the shell overrides the generated one. |
@@ -102,6 +104,30 @@ services: |
102 | 104 | timeout: 2s |
103 | 105 | retries: 12 |
104 | 106 |
|
| 107 | + # The built-in OpenTelemetry collector, run only with the otel profile: |
| 108 | + # COMPOSE_PROFILES=otel in .env, which Compose reads itself. It receives |
| 109 | + # OTLP/gRPC on 127.0.0.1:4317, the address to give |
| 110 | + # E2B_OTEL_COLLECTOR_GRPC_ENDPOINT, and writes the e2b.* metrics into |
| 111 | + # ClickHouse (config/otel/otel-collector.yaml says what it keeps). The image |
| 112 | + # has no shell, so there is no healthcheck; `curl -s 127.0.0.1:13133` on the |
| 113 | + # host is the check. No service depends on it, `ready` included. |
| 114 | + otel-collector: |
| 115 | + image: otel/opentelemetry-collector-contrib:0.146.0 |
| 116 | + profiles: [otel] |
| 117 | + restart: unless-stopped |
| 118 | + network_mode: host |
| 119 | + depends_on: |
| 120 | + clickhouse-migrator: |
| 121 | + condition: service_completed_successfully |
| 122 | + environment: |
| 123 | + # sha256 of config/otel/otel-collector.yaml, same purpose as |
| 124 | + # VECTOR_CONFIG_SHA256 on the vector service. |
| 125 | + OTEL_CONFIG_SHA256: 96621f22e4e8ab2b420a6bc659c0b47239535f90627951aba449a309f614ce5f |
| 126 | + command: ["--config=/etc/otelcol-contrib/config.yaml"] |
| 127 | + configs: |
| 128 | + - source: otel-collector-config |
| 129 | + target: /etc/otelcol-contrib/config.yaml |
| 130 | + |
105 | 131 | db-migrator: |
106 | 132 | image: ${E2B_DB_MIGRATOR_IMAGE:?fetch the .env that ships beside compose.yaml (README, Install)} |
107 | 133 | restart: "no" |
@@ -240,6 +266,10 @@ services: |
240 | 266 | REDIS_URL: 127.0.0.1:6379 |
241 | 267 | CLICKHOUSE_CONNECTION_STRING: clickhouse://clickhouse:clickhouse@127.0.0.1:9000/default |
242 | 268 | LOGS_COLLECTOR_ADDRESS: http://127.0.0.1:30006 |
| 269 | + # Where this service and api, client-proxy and dashboard-api export their |
| 270 | + # metrics, traces and logs over OTLP/gRPC. Empty unless .env sets |
| 271 | + # E2B_OTEL_COLLECTOR_GRPC_ENDPOINT, and empty exports nothing. |
| 272 | + OTEL_COLLECTOR_GRPC_ENDPOINT: ${E2B_OTEL_COLLECTOR_GRPC_ENDPOINT:-} |
243 | 273 | TEMPLATE_STORAGE_URL: file:///var/lib/e2b/storage/templates |
244 | 274 | BUILD_CACHE_STORAGE_URL: file:///var/lib/e2b/storage/build-cache |
245 | 275 | ARTIFACTS_REGISTRY_PROVIDER: Local |
@@ -304,6 +334,7 @@ services: |
304 | 334 | # LOKI_URL, and tests/pins.bats refuses that pin. |
305 | 335 | LOGS_READ_CONFIG: "true" |
306 | 336 | LOGS_COLLECTOR_ADDRESS: http://127.0.0.1:30006 |
| 337 | + OTEL_COLLECTOR_GRPC_ENDPOINT: ${E2B_OTEL_COLLECTOR_GRPC_ENDPOINT:-} |
307 | 338 | API_INTERNAL_GRPC_PORT: "5009" |
308 | 339 | API_EDGE_GRPC_PORT: "5109" |
309 | 340 | PPROF_PORT: "6060" |
@@ -388,6 +419,7 @@ services: |
388 | 419 | POSTGRES_CONNECTION_STRING: postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable |
389 | 420 | REDIS_URL: 127.0.0.1:6379 |
390 | 421 | CLICKHOUSE_CONNECTION_STRING: clickhouse://clickhouse:clickhouse@127.0.0.1:9000/default |
| 422 | + OTEL_COLLECTOR_GRPC_ENDPOINT: ${E2B_OTEL_COLLECTOR_GRPC_ENDPOINT:-} |
391 | 423 | AUTH_PROVIDER_CONFIG: '{"jwt":[]}' |
392 | 424 | volumes: |
393 | 425 | - seed-state:/run/e2b:ro |
@@ -472,6 +504,7 @@ services: |
472 | 504 | API_INTERNAL_GRPC_ADDRESS: 127.0.0.1:5009 |
473 | 505 | PROXY_PORT: "3002" |
474 | 506 | HEALTH_PORT: "3003" |
| 507 | + OTEL_COLLECTOR_GRPC_ENDPOINT: ${E2B_OTEL_COLLECTOR_GRPC_ENDPOINT:-} |
475 | 508 | depends_on: |
476 | 509 | api: |
477 | 510 | condition: service_healthy |
@@ -853,3 +886,93 @@ configs: |
853 | 886 | skip_unknown_fields = false |
854 | 887 | compression = "gzip" |
855 | 888 | batch.timeout_secs = 1 |
| 889 | + otel-collector-config: |
| 890 | + content: | |
| 891 | + # The built-in OpenTelemetry collector. The services export to it once their |
| 892 | + # collector endpoint is 127.0.0.1:4317. It keeps the e2b.* metrics and writes |
| 893 | + # them into the stack's own ClickHouse, into the metrics_gauge and metrics_sum |
| 894 | + # tables the clickhouse-migrator creates; the api's metrics endpoints read |
| 895 | + # what those two feed. Traces, logs and the other metrics are dropped; the |
| 896 | + # commented otlp/upstream exporter below forwards traces and logs instead. |
| 897 | + # Every listener binds loopback: the collector shares the machine's network |
| 898 | + # with the services, and nothing off the machine has a reason to reach it. |
| 899 | + receivers: |
| 900 | + otlp: |
| 901 | + protocols: |
| 902 | + grpc: |
| 903 | + endpoint: 127.0.0.1:4317 |
| 904 | + max_recv_msg_size_mib: 100 |
| 905 | +
|
| 906 | + processors: |
| 907 | + # Batches traces and logs on their way to nop, or to otlp/upstream once |
| 908 | + # that forwards them. |
| 909 | + batch: |
| 910 | + timeout: 5s |
| 911 | +
|
| 912 | + batch/clickhouse: |
| 913 | + timeout: 5s |
| 914 | + send_batch_size: 50000 |
| 915 | +
|
| 916 | + filter/external_metrics: |
| 917 | + metrics: |
| 918 | + include: |
| 919 | + match_type: regexp |
| 920 | + metric_names: |
| 921 | + - "e2b.*" |
| 922 | +
|
| 923 | + extensions: |
| 924 | + # `curl -s 127.0.0.1:13133` on the machine answers while the collector runs. |
| 925 | + # The image has no shell, so there is nothing to check from inside it. |
| 926 | + health_check: |
| 927 | + endpoint: 127.0.0.1:13133 |
| 928 | +
|
| 929 | + exporters: |
| 930 | + clickhouse: |
| 931 | + endpoint: tcp://127.0.0.1:9000 |
| 932 | + database: default |
| 933 | + username: clickhouse |
| 934 | + password: clickhouse |
| 935 | + async_insert: true |
| 936 | + create_schema: false |
| 937 | + metrics_tables: |
| 938 | + gauge: |
| 939 | + name: metrics_gauge |
| 940 | + sum: |
| 941 | + name: metrics_sum |
| 942 | +
|
| 943 | + # Accepts traces and logs and discards them. Without a pipeline for them the |
| 944 | + # receiver would answer Unimplemented, and every service would log each |
| 945 | + # batch it refused. |
| 946 | + nop: |
| 947 | +
|
| 948 | + # To forward traces and logs to a collector of your own, uncomment this |
| 949 | + # exporter, put that collector's OTLP/gRPC address in its endpoint, and |
| 950 | + # name it in place of nop in the traces and logs pipelines at the end. |
| 951 | + # otlp/upstream: |
| 952 | + # endpoint: collector.example.com:4317 |
| 953 | + # tls: |
| 954 | + # insecure: true |
| 955 | +
|
| 956 | + service: |
| 957 | + telemetry: |
| 958 | + logs: |
| 959 | + level: warn |
| 960 | + # No internal metrics: by default the collector serves its own on |
| 961 | + # 127.0.0.1:8888, one more listener on the machine, and refuses to start |
| 962 | + # when something else holds that port. |
| 963 | + metrics: |
| 964 | + level: none |
| 965 | + extensions: [health_check] |
| 966 | + pipelines: |
| 967 | + metrics/external: |
| 968 | + receivers: [otlp] |
| 969 | + processors: [filter/external_metrics, batch/clickhouse] |
| 970 | + exporters: [clickhouse] |
| 971 | + traces: |
| 972 | + receivers: [otlp] |
| 973 | + processors: [batch] |
| 974 | + exporters: [nop] |
| 975 | + logs: |
| 976 | + receivers: [otlp] |
| 977 | + processors: [batch] |
| 978 | + exporters: [nop] |
0 commit comments