Skip to content

Commit

Permalink
feat: add base project
Browse files Browse the repository at this point in the history
  • Loading branch information
cksidharthan committed Jun 22, 2023
1 parent 918b2e9 commit b737cc7
Show file tree
Hide file tree
Showing 635 changed files with 281,140 additions and 1 deletion.
96 changes: 96 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
ignored-numbers:
- '0'
- '1'
- '2'
- '3'
ignored-functions:
- strings.SplitN
govet:
check-shadowing: true
enable:
- fieldalignment
lll:
line-length: 200
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

linters:
disable-all: true
enable:
- bodyclose
- dogsled
- lll
- dupl
- errcheck
- exportloopref
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- noctx
- nolintlint
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
- wsl
- gocognit
- godot
- goheader
- gomodguard
- gci
- nestif
- prealloc
- gochecknoinits
- goconst
- gocritic

run:
tests: false
concurrency: 5
skip-dirs-use-default: true
2 changes: 2 additions & 0 deletions .hadolint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## This file is used by the Hadolint linter to ignore certain rules. This will contain a list of rules to be ignored.
ignored:
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/active-tab-highlighter.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/go-jaeger.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# go-jaeger
# go-tracer
Tracing library for Go applications using OpenTracing. This library hooks into the logrus library.

## Usage
Please see the [examples](https://github.com/cksidharthan/go-jaeger/blob/main/example/example.go) directory for usage examples.

## Running the example
1. Run the Jaeger all-in-one docker image
```bash
task run-jaeger
```
2. Run the example
```bash
task run-example
```
3. Open the Jaeger UI
```bash
task open-jaeger-ui
```

# Screenshots
After running the example, you can see the traces in the Jaeger UI as shown below.
![Screenshot](./assets/jaeger-ui-example.png)


# Contributing
Please feel free to raise issues and submit PRs.
74 changes: 74 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: 3


tasks:
dev-setup:
desc: "Setup development environment"
cmds:
- go install golang.org/x/tools/cmd/goimports@latest
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
- go install github.com/nikolaydubina/go-cover-treemap@latest

deps:
desc: "Dependencies Check"
cmds:
- go mod download
- go mod tidy
- go mod verify
- go mod vendor

fmt:
desc: "Format Check"
cmds:
- goimports -w -e $(find . -type f -name '*.go' -not -path "*/vendor/*")

lint:
desc: "Lint Check"
cmds:
- golangci-lint run --fix
- go vet ./...

test:
desc: "Running unit Tests"
cmds:
- go test -coverprofile cover.out ./pkg/...
- go tool cover -html=cover.out -o cover.html
- go-cover-treemap -coverprofile cover.out > assets/cover-treemap.svg

run-jaeger:
desc: "Run Jaeger"
cmds:
- docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p 5775:5775/udp -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 14268:14268 -p 9411:9411 jaegertracing/all-in-one:latest

stop-jaeger:
desc: "Stop Jaeger"
cmds:
- docker stop jaeger

run-example:
desc: "Run example"
cmds:
- go run example/main.go

open-jaeger-ui:
desc: "Open Jaeger UI"
cmds:
- open http://localhost:16686

dc-up:
desc: "Start docker-compose"
cmds:
- docker-compose up -d -f deploy/docker-compose/docker-compose.yml

dc-down:
desc: "Stop docker-compose"
cmds:
- docker-compose down -f deploy/docker-compose/docker-compose.yml

pr-check:
desc: "Run all checks"
cmds:
- task: deps
- task: fmt
- task: lint
- task: test
47 changes: 47 additions & 0 deletions assets/cover-treemap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/jaeger-ui-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions deploy/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
jaeger:
image: jaegertracing/all-in-one:1.44.0
container_name: jaeger
networks:
- dev-network
ports:
- "6831:6831/udp"
- "6832:6832/udp"
- "5775:5775/udp"
- "5778:5778"
- "16686:16686"
- "14268:14268"
- "9411:9411"
environment:
- COLLECTOR_OTLP_ENABLED=true
- LOG_LEVEL=debug
- COLLECTOR_ZIPKIN_HTTP_PORT=9411

networks:
dev-network:
driver: bridge
5 changes: 5 additions & 0 deletions deploy/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM docker.io/jaegertracing/all-in-one:1.44.0

RUN addgroup -S jaegergroup && adduser -S jaeger -G jaegergroup

USER jaeger
Loading

0 comments on commit b737cc7

Please sign in to comment.