Skip to content

Commit

Permalink
chore: make OTEL endpoint configurable in generator dockerfile (#1075)
Browse files Browse the repository at this point in the history
* chore: make OTEL endpoint configurable in generator dockerfile

* chore: upgrade otel and go to 1.34.0 and 1.24
  • Loading branch information
shantanualsi authored Feb 14, 2025
1 parent b76afa6 commit 5c7df3b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 65 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ jobs:
context: ./generator/
image_name: 'fake-log-generator'
environment: 'prod'
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64
build-args: |
OTLP_ENDPOINT=http://localhost:3100/otlp
14 changes: 11 additions & 3 deletions generator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM otel/opentelemetry-collector-contrib:latest AS collector

# Final stage
FROM golang:1.22
FROM golang:1.24

# Copy the collector binary from the collector stage
COPY --from=collector /otelcol-contrib /otelcol-contrib
Expand All @@ -19,11 +19,16 @@ RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -o /generator

# Copy the OTEL collector config
COPY otel-config.yaml /etc/otel/config.yaml
COPY otel-config.yaml /etc/otel/config.template.yaml

# Create a startup script
COPY <<EOF /start.sh
#!/bin/sh
# Set default OTLP endpoint if not provided
OTLP_ENDPOINT=\${OTLP_ENDPOINT:-http://host.docker.internal:3100/otlp}

# Replace environment variables in the config template
envsubst < /etc/otel/config.template.yaml > /etc/otel/config.yaml

# Start the OTEL collector in the background
/otelcol-contrib --config /etc/otel/config.yaml &

Expand All @@ -34,6 +39,9 @@ sleep 2
/generator \$@
EOF

# Install envsubst utility
RUN apt-get update && apt-get install -y gettext-base && rm -rf /var/lib/apt/lists/*

RUN chmod +x /start.sh

ENTRYPOINT ["/start.sh"]
41 changes: 20 additions & 21 deletions generator/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/grafana/explore-logs/generator

go 1.22

toolchain go1.22.0
go 1.24.0

require (
github.com/brianvoe/gofakeit v3.18.0+incompatible
Expand All @@ -11,13 +9,13 @@ require (
github.com/grafana/loki/pkg/push v0.0.0-20240912152814-63e84b476a9a
github.com/prometheus/common v0.34.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/contrib/bridges/otelslog v0.7.0
go.opentelemetry.io/otel v1.32.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0
go.opentelemetry.io/otel/sdk v1.32.0
go.opentelemetry.io/otel/sdk/log v0.8.0
google.golang.org/grpc v1.67.1
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/contrib/bridges/otelslog v0.9.0
go.opentelemetry.io/otel v1.34.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.10.0
go.opentelemetry.io/otel/sdk v1.34.0
go.opentelemetry.io/otel/sdk/log v0.10.0
google.golang.org/grpc v1.69.4
)

require (
Expand All @@ -32,11 +30,11 @@ require (
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/regexp v0.0.0-20220304095617-2e8d9baf4ac2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
Expand All @@ -50,19 +48,20 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/prometheus v0.35.0 // indirect
go.opentelemetry.io/otel/log v0.8.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/log v0.10.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
google.golang.org/protobuf v1.36.3 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 5c7df3b

Please sign in to comment.