Skip to content

Commit

Permalink
Merge pull request #29 from x-qdo/feature/otel
Browse files Browse the repository at this point in the history
Feature/otel
  • Loading branch information
astreter committed Feb 11, 2022
2 parents 38adcb3 + d4f4a55 commit 5b2c26c
Show file tree
Hide file tree
Showing 21 changed files with 520 additions and 235 deletions.
10 changes: 10 additions & 0 deletions .helm/templates/deployment-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
role: api
template:
metadata:
annotations:
sidecar.opentelemetry.io/inject: "true"
labels:
{{- include "jiraclick.selectorLabels" . | nindent 8 }}
role: api
Expand All @@ -36,10 +38,18 @@ spec:
{{ include "jiraclick.common_env" . | nindent 12 }}
- name: HTTPHANDLER_PORT
value: "8080"
- name: METRICS_PORT
value: "9090"
envFrom:
- configMapRef:
name: opentelemetry-config
ports:
- name: http-handler
containerPort: 8080
protocol: TCP
- name: http-metrics
containerPort: 9090
protocol: TCP
livenessProbe:
httpGet:
path: /health-check
Expand Down
11 changes: 11 additions & 0 deletions .helm/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
role: worker
template:
metadata:
annotations:
sidecar.opentelemetry.io/inject: "true"
labels:
{{- include "jiraclick.selectorLabels" . | nindent 8 }}
role: worker
Expand All @@ -34,6 +36,15 @@ spec:
- worker
env:
{{ include "jiraclick.common_env" . | nindent 12 }}
- name: METRICS_PORT
value: "9090"
envFrom:
- configMapRef:
name: opentelemetry-config
ports:
- name: http-metrics
containerPort: 9090
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand Down
4 changes: 4 additions & 0 deletions .helm/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ spec:
targetPort: http-handler
protocol: TCP
name: http-handler
- port: 9090
targetPort: http-metrics
protocol: TCP
name: http-metrics
selector:
{{- include "jiraclick.selectorLabels" . | nindent 4 }}
role: api
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.14 AS builder
FROM golang:1.17 AS builder

ARG GOPROXY=direct
ARG GOPROXY=https://proxy.golang.org,direct
ENV GOPROXY ${GOPROXY}

ARG GOPRIVATE
Expand Down
4 changes: 3 additions & 1 deletion cmd/httphandler.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cmd

import (
"github.com/astreter/amqpwrapper"
"github.com/astreter/amqpwrapper/v2"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
"x-qdo/jiraclick/pkg/contract"

"x-qdo/jiraclick/pkg/config"
Expand Down Expand Up @@ -42,6 +43,7 @@ func NewHTTPHandlerCmd(
"message": "ok",
})
})
router.Use(otelgin.Middleware(config.ServiceName))

router.POST("webhooks/clickup", clickUpHandler.TaskEvent)

Expand Down
2 changes: 1 addition & 1 deletion cmd/worker.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"github.com/astreter/amqpwrapper"
"github.com/astreter/amqpwrapper/v2"
"github.com/spf13/cobra"

"x-qdo/jiraclick/pkg/consumer"
Expand Down
21 changes: 17 additions & 4 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package context

import (
"context"
"github.com/astreter/amqpwrapper"
"github.com/astreter/amqpwrapper/v2"
"github.com/x-qdo/otelwrapper"
"sync"
"x-qdo/jiraclick/pkg/contract"

Expand Down Expand Up @@ -41,14 +42,26 @@ func NewContext() (*Context, error) {

ctx.WaitGroup = new(sync.WaitGroup)

amqpProvider, err := amqpwrapper.NewRabbitChannel(ctx.Ctx, ctx.CancelF, ctx.WaitGroup, &amqpwrapper.Config{
URL: cfg.RabbitMQ.URL,
Debug: cfg.Debug,
tp, err := otelwrapper.InitTracerProvider(config.ServiceName, "default")
if err != nil {
return nil, err
}
go otelwrapper.ShutdownWaiting(tp, ctx.Ctx, ctx.WaitGroup)

amqpProvider, err := amqpwrapper.NewRabbitChannel(ctx.Ctx, ctx.WaitGroup, &amqpwrapper.Config{
URL: cfg.RabbitMQ.URL,
Debug: cfg.Debug,
ConfirmSends: true,
})
if err != nil {
panic(err)
}

go func() {
<-amqpProvider.Cancel()
ctx.CancelF()
}()

db, err := provider.NewPostgres(cfg)
if err != nil {
panic(err)
Expand Down
37 changes: 23 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,37 @@ module x-qdo/jiraclick
go 1.16

require (
github.com/andygrunwald/go-jira v1.13.0
github.com/andygrunwald/go-jira v1.14.0
github.com/araddon/dateparse v0.0.0-20201001162425-8aadafed4dc4
github.com/astreter/amqpwrapper v1.2.3
github.com/astreter/amqpwrapper/v2 v2.0.2
github.com/gin-gonic/gin v1.7.7
github.com/go-pg/migrations/v8 v8.0.1 // indirect
github.com/go-pg/pg/v10 v10.7.4
github.com/go-playground/validator/v10 v10.9.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-pg/migrations/v8 v8.1.0
github.com/go-pg/pg/extra/pgotel/v10 v10.10.6
github.com/go-pg/pg/v10 v10.10.6
github.com/go-playground/validator/v10 v10.10.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/pkg/errors v0.8.1
github.com/rabbitmq/amqp091-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/rabbitmq/amqp091-go v1.3.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.4.0
github.com/trivago/tgo v1.0.1
github.com/trivago/tgo v1.0.7
github.com/ugorji/go v1.2.6 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/x-qdo/otelwrapper v1.0.1
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.28.0
go.opentelemetry.io/otel v1.3.0
go.opentelemetry.io/otel/trace v1.3.0
go.opentelemetry.io/proto/otlp v0.12.0 // indirect
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
google.golang.org/genproto v0.0.0-20220204002441-d6cc3cc0770e // indirect
google.golang.org/grpc v1.44.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

0 comments on commit 5b2c26c

Please sign in to comment.