Skip to content

Commit

Permalink
fix(otel): ensuring service will start
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Oct 8, 2024
1 parent e3b7d37 commit e5e07e3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion infrastructure/otel-collector/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const config = {
env_code: isDev ? 'dev' : 'prod',
},
healthCheck: {
command: ['CMD-SHELL', 'curl -f http://localhost/status || exit 1'],
command: ['CMD-SHELL', 'curl -f http://localhost:3000/status || exit 1'],
interval: 15,
retries: 3,
timeout: 5,
Expand Down
4 changes: 1 addition & 3 deletions infrastructure/otel-collector/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ class OTELCollector extends TerraformStack {
containerConfigs: [
{
healthCheck: config.healthCheck,
name: 'otel-collector',
containerImage: 'pocket/opentelemetry-collector-contrib',
name: 'app',
essential: true,
portMappings: [{ containerPort: 3000, hostPort: 3000 }],
logMultilinePattern: '^\\S.+',
Expand All @@ -109,7 +108,6 @@ class OTELCollector extends TerraformStack {
valueFrom: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/GCP_SA_TRACES:::`,
},
],
repositoryCredentialsParam: `arn:aws:secretsmanager:${region.name}:${caller.accountId}:secret:Shared/DockerHub`,
},
],
codeDeploy: {
Expand Down
5 changes: 1 addition & 4 deletions servers/otel-collector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# Use an alpine image as our base image, this allows us to define our own entry point script and have access to sh or bash, which the otel image does not have
FROM alpine:3
RUN apk add nginx curl

# Copy the otelcol-contrib binary from the official image
COPY --from=otel/opentelemetry-collector-contrib:0.111.0 /otelcol-contrib /otelcol-contrib

COPY otel-collector-config.yaml /etc/otelcol-contrib/config.yaml


RUN apk add nginx curl
COPY httpd.conf /etc/nginx/http.d/default.conf

COPY entrypoint.sh /entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion servers/otel-collector/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -e
echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /etc/otelcol-contrib/key.json
nginx
nginx &
exec "$@"
3 changes: 2 additions & 1 deletion servers/otel-collector/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ server {

# Everything is a 200
location /status {
proxy_pass http://localhost:13133;
default_type application/json;
return 200 '{"status": "ok"}';
}

location / {
Expand Down
48 changes: 30 additions & 18 deletions servers/otel-collector/otel-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ receivers:
# grpc:
# endpoint: "0.0.0.0:4317" # gRPC port for receiving traces, metrics, and logs over gRPC
http:
endpoint: "localhost:4318" # http port for receiving traces, metrics, and logs over http

extensions:
health_check:
endpoint: localhost:13133


endpoint: '0.0.0.0:4318' # http port for receiving traces, metrics, and logs over http

exporters:
googlecloud:
Expand All @@ -23,19 +17,19 @@ exporters:
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 30
limit_percentage: 70
spike_limit_percentage: 10
batch:
# batch metrics before sending to reduce API usage
send_batch_max_size: 10100
send_batch_size: 10000
timeout: 5s
resourcedetection/ecs:
detectors: [env, ecs]
timeout: 2s
# Ensures that anything coming from the ECS detector in code will not override any existing attributes.
# Otherwise, note, that the ECS detector will be that of where the collector is running, not the service.
override: false
detectors: [env, ecs]
timeout: 2s
# Ensures that anything coming from the ECS detector in code will not override any existing attributes.
# Otherwise, note, that the ECS detector will be that of where the collector is running, not the service.
override: false
resource/cleanup_for_google:
attributes:
- key: service.namespace
Expand All @@ -61,13 +55,31 @@ service:
pipelines:
traces:
receivers: [otlp]
processors: [resourcedetection/ecs, resource/cleanup_for_google, memory_limiter, batch]
exporters: [debug]
processors:
[
resourcedetection/ecs,
resource/cleanup_for_google,
memory_limiter,
batch,
]
exporters: [googlecloud]
metrics:
receivers: [otlp]
processors: [resourcedetection/ecs, resource/cleanup_for_google, memory_limiter, batch]
processors:
[
resourcedetection/ecs,
resource/cleanup_for_google,
memory_limiter,
batch,
]
exporters: [googlecloud]
logs:
receivers: [otlp]
processors: [resourcedetection/ecs, resource/cleanup_for_google, memory_limiter, batch]
exporters: [debug]
processors:
[
resourcedetection/ecs,
resource/cleanup_for_google,
memory_limiter,
batch,
]
exporters: [googlecloud]

0 comments on commit e5e07e3

Please sign in to comment.