Skip to content

Commit

Permalink
Add support to generate OTEL logs in generate script (#973)
Browse files Browse the repository at this point in the history
* refactor: refactor generator implementation

* chore: modify dockerfile to start otel-collector

* chore: get go otel dependencies

* fixup! chore: modify dockerfile to start otel-collector

* chore: implement otel logging

* chore: fix a few minor bugs

* chore: update spellcheck

* chore: add some more log types

* chore: fix spellcheck

* chore: upgrade loki versions in docker-compose files

* fix: pass arguments to the generator inside dockerfile

* fix: run generate-logs in docker

* chore: change otel-config to use host.docker.internal

Co-authored-by: Sven Grossmann <[email protected]>

---------

Co-authored-by: Galen <[email protected]>
Co-authored-by: Sven Grossmann <[email protected]>
Co-authored-by: Galen Kistler <[email protected]>
  • Loading branch information
4 people authored Jan 7, 2025
1 parent 2f7ad5b commit e07929a
Show file tree
Hide file tree
Showing 15 changed files with 488 additions and 163 deletions.
2 changes: 1 addition & 1 deletion docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
extra_hosts:
- 'host.docker.internal:host-gateway'
loki:
image: grafana/loki:3.2.0
image: grafana/loki:3.3.2
environment:
LOG_CLUSTER_DEPTH: '8'
LOG_SIM_TH: '0.3'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
extra_hosts:
- 'host.docker.internal:host-gateway'
loki:
image: grafana/loki:3.3.0
image: grafana/loki:3.3.2
environment:
LOG_CLUSTER_DEPTH: '8'
LOG_SIM_TH: '0.3'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
extra_hosts:
- 'host.docker.internal:host-gateway'
loki:
image: grafana/loki:3.2.0
image: grafana/loki:3.3.2
environment:
LOG_CLUSTER_DEPTH: '8'
LOG_SIM_TH: '0.3'
Expand Down
29 changes: 27 additions & 2 deletions generator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
# Start with the OTEL collector stage
FROM otel/opentelemetry-collector-contrib:latest AS collector

# Final stage
FROM golang:1.22

# Copy the collector binary from the collector stage
COPY --from=collector /otelcol-contrib /otelcol-contrib

WORKDIR /go/src/app

# Copy and build the log generator
COPY go.mod go.sum ./
COPY *.go ./
COPY flog/ flog/
COPY log/ log/

RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux go build -o /generator

ENTRYPOINT ["/generator"]
# Copy the OTEL collector config
COPY otel-config.yaml /etc/otel/config.yaml

# Create a startup script
COPY <<EOF /start.sh
#!/bin/sh
# Start the OTEL collector in the background
/otelcol-contrib --config /etc/otel/config.yaml &

# Wait a bit for collector to start
sleep 2

# Start the log generator
/generator \$@
EOF

RUN chmod +x /start.sh

ENTRYPOINT ["/start.sh"]
Loading

0 comments on commit e07929a

Please sign in to comment.