From 2401ea4b6bf69af19e49308a005b8234a614d6f5 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 8 Nov 2023 15:56:07 -0600 Subject: [PATCH] add Dockerfile and initial build config --- .github/CODEOWNERS | 1 + .github/workflows/ci.yml | 31 +++++++++++++++++++++++ Dockerfile | 6 +++++ Makefile | 17 +++++++++++++ README.md | 9 ++----- otel-config.yaml | 54 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 otel-config.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..0c4dfdd --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @Dwolla/platform \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..71ccd61 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Build + +on: + pull_request: + push: + branches: ['**'] + tags: [v*] + +jobs: + build: + strategy: + matrix: + otel_tag: + - v0.35.0 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build and Push Docker Image + uses: Dwolla/jenkins-agents-workflow/.github/actions/build@main + with: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + BASE_TAG: ${{ matrix.OTEL_TAG }} + TAG_NAME: OTEL_TAG + IMAGE_NAME: dwolla/otel-collector + build-complete: + needs: build + runs-on: ubuntu-latest + steps: + - run: echo "The build completed successfully" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ca369ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +ARG OTEL_TAG +FROM amazon/aws-otel-collector:${OTEL_TAG} +LABEL maintainer="Dwolla Dev " +LABEL org.label-schema.vcs-url="https://github.com/Dwolla/dwolla-adot-collector" + +COPY otel-config.yaml /etc/otel-config.yaml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3d61d77 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +OTEL_TAG := $(OTEL_TAG) +JOB := core-${OTEL_TAG} +CLEAN_JOB := clean-${OTEL_TAG} + +all: ${JOB} +clean: ${CLEAN_JOB} +.PHONY: all clean ${JOB} ${CLEAN_JOB} + +${JOB}: core-%: Dockerfile + docker buildx build \ + --platform linux/arm64,linux/amd64 \ + --build-arg OTEL_TAG=$* \ + --tag dwolla/otel-collector:$*-SNAPSHOT \ + . + +${CLEAN_JOB}: clean-%: + docker image rm --force dwolla/otel-collector:$*-SNAPSHOT diff --git a/README.md b/README.md index 118844b..aae0a29 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,10 @@ Docker image that adds Dwolla's configuration to the AWS distribution of OpenTel ## Local Development -With [yq](https://kislyuk.github.io/yq/) installed, to build this image locally run the following command: +With [jq](https://jqlang.github.io/jq/manual/) installed, to build this image locally run the following command: ```bash make \ - TAG=$(curl --silent https://raw.githubusercontent.com/Dwolla/jenkins-agents-workflow/main/.github/workflows/build-docker-image.yml | \ - yq .on.workflow_call.inputs.NVM_TAG.default) \ + OTEL_TAG=$(curl --silent https://api.github.com/repos/aws-observability/aws-otel-collector/releases/latest | jq .name) \ all ``` - -Alternatively, without [yq](https://kislyuk.github.io/yq/) installed, refer to the NVM_TAG default values defined in [jenkins-agents-workflow](https://github.com/Dwolla/jenkins-agents-workflow/blob/main/.github/workflows/build-docker-image.yml) and run the following command: - -`make NVM_TAG= all` diff --git a/otel-config.yaml b/otel-config.yaml new file mode 100644 index 0000000..ade3e34 --- /dev/null +++ b/otel-config.yaml @@ -0,0 +1,54 @@ +extensions: + health_check: + +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:55681 + zipkin: + +processors: + memory_limiter: + limit_mib: 100 + check_interval: 5s + batch/traces: + timeout: 10s + send_batch_size: 50 + attributes: + actions: + - key: deployment.environment + value: ${env:DWOLLA_ENV} + action: insert + - key: peer.service + action: extract + pattern: ^consul!(?P.*)$ # AFAICT using "peer.service" would be an illegal capture group name + - key: peer.service + action: update + from_attribute: peerservice + - key: peerservice + action: delete + +exporters: + awsxray: + indexed_attributes: + - otel.resource.service.name + - deployment.environment + +service: + pipelines: + traces: + receivers: + - otlp + - zipkin + processors: + - memory_limiter + - batch/traces + - attributes + exporters: + - awsxray + + extensions: + - health_check