Skip to content

Commit

Permalink
Reorganize projects to use build info in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
gagbo committed Apr 25, 2023
1 parent aced1d6 commit 2670345
Show file tree
Hide file tree
Showing 30 changed files with 182 additions and 3,277 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "autometrics-shared"]
path = configs/shared
url = https://github.com/autometrics-dev/autometrics-shared.git
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ trigger alerts directly from production usage:
![a Slack bot is posting an alert directly in the channel](./assets/slack-alert-example.png)

A fully working use-case and example of library usage is available in the
[examples/web](./examples/web) subdirectory
[examples/web](./examples/web) subdirectory. You can build and run load on the
example server using:

```console
git submodule update --init
docker compose -f docker-compose.prometheus-example.yaml up
```

And then explore the generated links by opening the [main
file](./examples/web/cmd/main.go).

## How to use

Expand Down
File renamed without changes.
1,594 changes: 0 additions & 1,594 deletions configs/autometrics.rules.yml

This file was deleted.

1 change: 1 addition & 0 deletions configs/shared
Submodule shared added at fd4aa1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ services:
container_name: alertmanager
restart: unless-stopped
volumes:
- ./alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./slack_url.txt:/etc/alertmanager/slack_url
- ./examples/otel/configs/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./examples/otel/configs/slack_url.txt:/etc/alertmanager/slack_url
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
expose:
Expand All @@ -34,8 +34,8 @@ services:
container_name: prometheus
restart: unless-stopped
volumes:
- ./prometheus.yaml:/etc/prometheus/prometheus.yaml
- ./autometrics.rules.yml:/etc/prometheus/autometrics.rules.yml
- ./examples/otel/configs/prometheus.yaml:/etc/prometheus/prometheus.yaml
- ./examples/otel/configs/autometrics.rules.yml:/etc/prometheus/autometrics.rules.yml
command:
- '--config.file=/etc/prometheus/prometheus.yaml'
expose:
Expand All @@ -48,7 +48,9 @@ services:
- web-server

web-server:
build: .
build:
context: .
dockerfile: examples/otel/Dockerfile
container_name: web-server
restart: unless-stopped
expose:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ services:
container_name: alertmanager
restart: unless-stopped
volumes:
- ./alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./slack_url.txt:/etc/alertmanager/slack_url
- ./examples/web/configs/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./examples/web/configs/slack_url.txt:/etc/alertmanager/slack_url
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
expose:
Expand All @@ -34,8 +34,8 @@ services:
container_name: prometheus
restart: unless-stopped
volumes:
- ./prometheus.yaml:/etc/prometheus/prometheus.yaml
- ./autometrics.rules.yml:/etc/prometheus/autometrics.rules.yml
- ./examples/web/configs/prometheus.yaml:/etc/prometheus/prometheus.yaml
- ./examples/web/configs/autometrics.rules.yml:/etc/prometheus/autometrics.rules.yml
command:
- '--config.file=/etc/prometheus/prometheus.yaml'
expose:
Expand All @@ -48,10 +48,23 @@ services:
- web-server

web-server:
build: .
build:
context: .
dockerfile: examples/web/Dockerfile
container_name: web-server
restart: unless-stopped
expose:
- 62086
ports:
- "62086:62086"

load-server:
build:
context: .
dockerfile: examples/web/load.Dockerfile
environment:
TARGET_HOST: web-server
container_name: load-server
restart: unless-stopped
depends_on:
- web-server
26 changes: 17 additions & 9 deletions examples/otel/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
FROM golang:1.20-alpine
MAINTAINER Fiberplane <[email protected]>
ARG version=development

# Cannot really build the demo image from
# the examples subfolder because of
# relative imports shenanigans that go out of build context (i.e. upwards)
#
# Use
# GOOS=linux GOARCH=amd64 go build -o web-server ./cmd/main.go
#
# To build the web-server app
RUN apk update && apk add git

COPY web-server /
WORKDIR /app

COPY . ./

RUN go mod download

WORKDIR /app/examples/web

RUN go generate cmd/main.go

ENV VERSION="$version"

RUN scripts/build_server

RUN cp web-server /

EXPOSE 62086

Expand Down
5 changes: 5 additions & 0 deletions examples/otel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ You can notice the 3 differences that are mentionned in the top-level README:
- The autometrics call in the Go generator has the `-otel` flag
- The `amImpl.Init` call uses a different first argument, with the name of the
OpenTelemetry scope to use

## Quickstart

You can build and run the example by using the
`docker-compose.open-telemetry-example.yaml` file at the root of the repo.
Loading

0 comments on commit 2670345

Please sign in to comment.