Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ♻️ some enhancement in the tracing and monitoring using opentelemetry #103

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://containers.dev/guide/dockerfile#dockerfile
# https://github.com/devcontainers/templates/tree/main/src/go
# https://github.com/devcontainers/images/tree/main/src/go

FROM mcr.microsoft.com/devcontainers/go:latest

# Add additional commands
30 changes: 0 additions & 30 deletions .devcontainer/Dockerfile-dev

This file was deleted.

211 changes: 112 additions & 99 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,108 +1,121 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
// https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/setting-up-your-dotnet-project-for-codespaces
// https://github.com/microsoft/vscode-remote-try-dotnet
// https://dev.to/this-is-learning/set-up-github-codespaces-for-a-net-8-application-5999
// https://audacioustux.notion.site/Getting-Started-with-Devcontainer-c727dbf9d56f4d6b9b0ef87b3111693f
{
"name": "store-microservices",
"build": {
"dockerfile": "./Dockerfile-dev",
"args": {
"VARIANT": "ubuntu-22.04"
}
"name": "Go Food Delivery Microservices",
// use existing dev container templates. More info: https://containers.dev/guide/dockerfile, https://containers.dev/templates
//"image": "mcr.microsoft.com/devcontainers/dotnet:1-7.0",
// use a Dockerfile file. More info: https://containers.dev/guide/dockerfile#dockerfile
// "build": {
// // Path is relative to the devcontainer.json file.
// "dockerfile": "Dockerfile"
// },
// using a Dockerfile with Docker Compose, https://containers.dev/guide/dockerfile#docker-compose-image
"dockerComposeFile": "docker-compose.yaml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
// https://github.com/devcontainers/features/tree/main/src/go
"ghcr.io/devcontainers/features/go:1": {
"version": "1.21"
},
// https://github.com/devcontainers/features/tree/main/src/github-cli
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "2"
},
"runArgs": [
"-u",
"vscode",
"-v",
"-v",
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"go.gopath": "/go",
// https://github.com/golang/tools/blob/master/gopls/doc/vscode.md#vscode
"go.useLanguageServer": true,
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
// Optional: Disable snippets, as they conflict with completion ranking.
"editor.snippetSuggestions": "none"
},
"[go.mod]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"[sql]": {
"editor.formatOnSave": true
},
// There are handly utility scripts within /scripts that we invoke via go run.
// These scripts (and its dependencies) should never be consumed by the actual server directly
// Thus they are flagged to require the "scripts" build.sh tag.
// We only inform gopls and the vscode go compiler here, that it has to set this build.sh tag if it sees such a file.
"go.buildTags": "scripts,migrate",
// https://github.com/devcontainers/features/tree/main/src/powershell
"ghcr.io/devcontainers/features/powershell:1": {
"version": "latest"
},
// https://github.com/devcontainers/features/tree/main/src/node
"ghcr.io/devcontainers/features/node:1": {},
// // https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube
// "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
// // https://github.com/devcontainers/features/tree/main/src/terraform
// "ghcr.io/devcontainers/features/terraform:1": {},
// https://github.com/devcontainers/features/tree/main/src/docker-in-docker
// https://devopscube.com/run-docker-in-docker/
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/git:1": {},
// https://github.com/devcontainers/features/tree/main/src/common-utils
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": true
}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {
"git.autofetch": true,
"files.autoSave": "onFocusChange",
"editor.formatOnSave": true,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"explorer.autoReveal": true,
"resmon.show.cpufreq": false,
"dotnet.server.startTimeout": 60000,
"omnisharp.projectLoadTimeout": 60,
"workbench.colorTheme": "Visual Studio Light",
"workbench.iconTheme": "material-icon-theme",
"editor.minimap.enabled": false,
"editor.fontFamily": "'MesloLGM Nerd Font', 'Droid Sans Mono', 'monospace', 'Droid Sans Fallback', 'Consolas'",
"editor.fontSize": 14,
"explorer.confirmDelete": false,
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.defaultProfile.linux": "zsh",
"powershell.cwd": "~",
"terminal.external.windowsExec": "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\pwsh.exe",
"gopls": {
// Add parameter placeholders when completing a function.
"usePlaceholders": true,
// If true, enable additional analyses with staticcheck.
// Warning: This will significantly increase memory usage.
// DISABLED, done via
"staticcheck": false
"ui.semanticTokens": true
},
"gopls.env": {
"GOFLAGS": "-tags=scripts,migrate"
},
// https://code.visualstudio.com/docs/languages/go#_intellisense
"go.autocompleteUnimportedPackages": true,
// https://github.com/golangci/golangci-lint#editor-integration
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--fast",
"--timeout",
"5m"
],
// disable test caching, race and show coverage (in sync with makefile)
"go.testFlags": [
"-cover",
"-race",
"-count=1",
"-v"
],
"go.coverMode": "atomic", // atomic is required when utilizing -race
"go.delveConfig": {
"dlvLoadConfig": {
// increase max length of strings displayed in debugger
"maxStringLen": 2048
},
"apiVersion": 2
}
},
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"golang.go",
// optional:
"ms-azuretools.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"go.lintFlags": ["--fast"],
"go.lintOnSave": "package",
"go.testFlags": ["-failfast", "-v"],
"go.toolsManagement.autoUpdate": true,
"go.useLanguageServer": true,
"go.formatTool": "gofumpt"
},
"extensions": [
"golang.Go",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker",
"ms-dotnettools.csdevkit",
"mutantdino.resourcemonitor",
"humao.rest-client",
"42crunch.vscode-openapi",
"heaths.vscode-guid",
"bungcip.better-toml",
"eamodio.gitlens",
"casualjim.gotemplate",
"davidanson.vscode-markdownlint",
"cweijan.vscode-mysql-client2",
"bierner.markdown-mermaid"
],
"postCreateCommand": "go version",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.21"
},
"ghcr.io/devcontainers/features/docker-from-docker:1": {
"version": "latest"
}
"dzhavat.bracket-pair-toggler",
"ms-azuretools.vscode-docker",
"vivaxy.vscode-conventional-commits",
"emmanuelbeziat.vscode-great-icons",
"ms-vscode.vs-keybindings",
"GitHub.vscode-github-actions",
"PKief.material-icon-theme",
"EditorConfig.EditorConfig",
"DavidAnson.vscode-markdownlint"
]
}
},
"hostRequirements": {
"cpus": 2,
"memory": "8gb",
"storage": "32gb"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],
// "portsAttributes": {
// "5001": {
// "protocol": "https"
// }
// }
// https://containers.dev/implementors/json_reference/#lifecycle-scripts
"updateContentCommand": "chmod +x .devcontainer/scripts/update.sh",
"postCreateCommand": "chmod +x .devcontainer/scripts/post-create.sh"
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
26 changes: 26 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# https://containers.dev/guide/dockerfile#docker-compose-image
# https://containers.dev/guide/dockerfile#docker-compose-dockerfile
services:
devcontainer:
build:
context: .
volumes:
- ../..:/workspaces:rw,cached
init: true
command: sleep infinity

# services:
# devcontainer:
# image: mcr.microsoft.com/devcontainers/dotnet:3.1.0
# volumes:
# - ../..:/workspaces:cached
# network_mode: service:db
# command: sleep infinity

# db:
# image: postgres:latest
# restart: unless-stopped
# environment:
# POSTGRES_PASSWORD: postgres
# POSTGRES_USER: postgres
# POSTGRES_DB: postgres
10 changes: 10 additions & 0 deletions .devcontainer/scripts/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -eax

# Run the setup-fonts.sh script
echo "Installing Nerd Fonts..."
./setup-fonts.sh

echo "Installing tools for Go development..."
./../../scripts/install-tools.sh
24 changes: 24 additions & 0 deletions .devcontainer/scripts/setup-fonts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Download MesloLGM Nerd Font
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/Meslo.zip -O MesloLGM.zip

# Extract the font files
unzip MesloLGM.zip -d MesloLGM

# Create the fonts directory if it doesn't exist
mkdir -p ~/.local/share/fonts

# Move the font files to the fonts directory
mv MesloLGM/*.ttf ~/.local/share/fonts/

# Update the font cache
fc-cache -fv

# Clean up
rm -rf MesloLGM.zip MesloLGM

# Verify installation
fc-list | grep "MesloLGM"

echo "Font setup completed."
3 changes: 3 additions & 0 deletions .devcontainer/scripts/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

set -eax
4 changes: 2 additions & 2 deletions .github/workflows/first-interaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "Welcome to go-ecommerce-microservices. Thank you ${{ github.event.pull_request.user.login }} for reporting your first issue. Please check out our [contributor guide](https://github.com/mehdihadeli/go-ecommerce-microservices/blob/main/CONTRIBUTION.md)."
pr-message: "Thank you ${{ github.event.pull_request.user.login }} for your first pull request to go-ecommerce-microservices repository. Please check out our [contributors guide](https://github.com/mehdihadeli/go-ecommerce-microservices/blob/main/CONTRIBUTION.md)."
issue-message: "Welcome to go-food-delivery-microservices. Thank you ${{ github.event.pull_request.user.login }} for reporting your first issue. Please check out our [contributor guide](https://github.com/mehdihadeli/go-food-delivery-microservices/blob/main/CONTRIBUTION.md)."
pr-message: "Thank you ${{ github.event.pull_request.user.login }} for your first pull request to go-food-delivery-microservices repository. Please check out our [contributors guide](https://github.com/mehdihadeli/go-food-delivery-microservices/blob/main/CONTRIBUTION.md)."
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

.cycle/

.env
43 changes: 34 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
{
"gopls": {
"git.autofetch": true,
"files.autoSave": "onFocusChange",
"editor.formatOnSave": true,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"explorer.autoReveal": true,
"resmon.show.cpufreq": false,
"dotnet.server.startTimeout": 60000,
"omnisharp.projectLoadTimeout": 60,
"gopls": {
"ui.semanticTokens": true
},
"go.lintTool":"golangci-lint",
"go.lintFlags": ["--fast"],
"go.lintOnSave": "package",
"go.testFlags": ["-failfast","-v"],
"go.toolsManagement.autoUpdate": true,
"go.useLanguageServer": true
}
},
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],
"go.lintOnSave": "package",
"go.testFlags": ["-failfast", "-v"],
"go.toolsManagement.autoUpdate": true,
"go.useLanguageServer": true,
"go.formatTool": "gofumpt",
"workbench.colorTheme": "Visual Studio Light",
"workbench.iconTheme": "material-icon-theme",
"editor.minimap.enabled": false,
"terminal.integrated.fontFamily": "MesloLGM Nerd Font",
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.defaultProfile.linux": "zsh",
"powershell.cwd": "~",
"terminal.external.windowsExec": "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\pwsh.exe",
"explorer.confirmDelete": false,
"remote.autoForwardPortsSource": "hybrid",
"go.inlayHints.assignVariableTypes": true,
"go.inlayHints.compositeLiteralFields": true,
"go.inlayHints.compositeLiteralTypes": true,
"go.inlayHints.constantValues": true,
"go.inlayHints.functionTypeParameters": true,
"go.inlayHints.rangeVariableTypes": true
}
Loading
Loading