erea

Jaeger (Distributed Tracing System) 본문

devops/msa

Jaeger (Distributed Tracing System)

erea 2019. 2. 24. 15:03

Overview

jaeger란? Uber Technologies에서 만든 분산형 추적시스템 오픈소스로서 마이크로 서비스 기반 분산 시스템 모니터링을 할수가 있다.

현재는 CNCF(Cloud Native Computing Foundation)의 프로젝트이다.

- 분산형 추적시스템에 대표적인 오픈소스로는 zipkin, jagger, appdash 가 대표적이다.

- 분산 컨텍스트 전파

- 분산 트랜잭션 모니터링

- 근본 원인 분석

- 서비스 의존성 분석

- 성능 / 대기 시간 최적화



Installation

client

application.yml

1
2
compile group: 'io.opentracing.contrib', name:'opentracing-spring-web-autoconfigure', version: '0.0.4'
compile group: 'com.uber.jaeger', name: 'jaeger-core', version: '0.27.0

---

jaegerConfig.java
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import com.uber.jaeger.Configuration;
 
import com.uber.jaeger.samplers.ProbabilisticSampler;
 
import org.springframework.beans.factory.annotation.Value;
 
import org.springframework.boot.web.client.RestTemplateBuilder;
 
import org.springframework.context.annotation.Bean;
 
import org.springframework.web.client.RestTemplate;
 
@org.springframework.context.annotation.Configuration
 
public class JaegerConfig {
 
    @Value("trace.url")
 
    String JaggerUrl;
 
    @Bean
 
    public io.opentracing.Tracer jaggerTracer() {
 
        return new Configuration("ios", new
        Configuration.SamplerConfiguration(ProbabilisticSampler.TYPE, 1,
        JaggerUrl),
        new Configuration.ReporterConfiguration()).getTracer();
    }
}
--

Server

Helm chart

value.yaml
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# Default values for jaeger.
# Default values for jaeger.
# This is a YAML-formatted file.
# Jaeger values are grouped by component. Cassandra values override subchart values
  
provisionDataStore:
  cassandra: false
  elasticsearch: true
  
tag: 1.9.0
  
storage:
  # allowed values (cassandra, elasticsearch)
  type: elasticsearch
  cassandra:
    host: cassandra
    port: 9042
    user: user
    password: password
  elasticsearch:
    scheme: http
    host: elasticsearch
    port: 9200
    user: elastic
    password: changeme
    nodesWanOnly: false
  
# Begin: Override values on the Cassandra subchart to customize for Jaeger
cassandra:
  image:
    tag: 3.11.3
  persistence:
    # To enable persistence, please see the documentation for the Cassandra chart
    enabled: false
  config:
    cluster_name: jaeger
    seed_size: 1
    dc_name: dc1
    rack_name: rack1
    endpoint_snitch: GossipingPropertyFileSnitch
# End: Override values on the Cassandra subchart to customize for Jaeger
  
# Begin: Default values for the various components of Jaeger
# This chart has been based on the Kubernetes integration found in the following repo:
# https://github.com/jaegertracing/jaeger-kubernetes/blob/master/production/jaeger-production-template.yml
#
# This is the jaeger-cassandra-schema Job which sets up the Cassandra schema for
# use by Jaeger
schema:
  annotations: {}
  image: jaegertracing/jaeger-cassandra-schema
  pullPolicy: IfNotPresent
  # Acceptable values are test and prod. Default is for production use.
  mode: prod
  resources: {}
    # limits:
    #   cpu: 500m
    #   memory: 512Mi
    # requests:
    #   cpu: 256m
    #   memory: 128Mi
  ## Additional pod labels
  ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  podLabels: {}
  
# Begin: Override values on the Elasticsearch subchart to customize for Jaeger
elasticsearch:
  image:
    tag: "5.4"
  cluster:
    name: "tracing"
  data:
    persistence:
      enabled: false
  rbac:
    create: false
  
agent:
  enabled: true
  annotations: {}
  image: jaegertracing/jaeger-agent
  pullPolicy: IfNotPresent
  collector:
    host: null
    port: null
  cmdlineParams: {}
  daemonset:
    useHostPort: false
  service:
    annotations: {}
    # List of IP ranges that are allowed to access the load balancer (if supported)
    loadBalancerSourceRanges: []
    type: LoadBalancer
    # zipkinThriftPort :accept zipkin.thrift over compact thrift protocol
    zipkinThriftPort: 5775
    # compactPort: accept jaeger.thrift over compact thrift protocol
    compactPort: 6831
    # binaryPort: accept jaeger.thrift over binary thrift protocol
    binaryPort: 6832
    # samplingPort: (HTTP) serve configs, sampling strategies
    samplingPort: 5778
  resources: {}
    # limits:
    #   cpu: 500m
    #   memory: 512Mi
    # requests:
    #   cpu: 256m
    #   memory: 128Mi
  nodeSelector: {}
  podAnnotations: {}
  ## Additional pod labels
  ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  podLabels: {}
  ## Allow the scheduling on tainted nodes (requires Kubernetes >= 1.6)
  ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
  tolerations: []
  useHostNetwork: false
  dnsPolicy: ClusterFirst
  
collector:
  enabled: true
  annotations: {}
  image: jaegertracing/jaeger-collector
  pullPolicy: IfNotPresent
  dnsPolicy: ClusterFirst
  cmdlineParams: {}
  replicaCount: 1
  service:
    annotations: {}
    # List of IP ranges that are allowed to access the load balancer (if supported)
    loadBalancerSourceRanges: []
    type: ClusterIP
    # tchannelPort: used by jaeger-agent to send spans in jaeger.thrift format
    tchannelPort: 14267
    # httpPort: can accept spans directly from clients in jaeger.thrift format
    httpPort: 14268
    # can accept Zipkin spans in JSON or Thrift
    zipkinPort: 9411
    healthCheckPort: 14269
  resources: {}
    # limits:
    #   cpu: 1
    #   memory: 1Gi
    # requests:
    #   cpu: 500m
    #   memory: 512Mi
  nodeSelector: {}
  podAnnotations: {}
  ## Additional pod labels
  ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  podLabels: {}
  ## Allow the scheduling on tainted nodes (requires Kubernetes >= 1.6)
  ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
  tolerations: []
  
query:
  enabled: true
  annotations: {}
  image: jaegertracing/jaeger-query
  pullPolicy: IfNotPresent
  dnsPolicy: ClusterFirst
  cmdlineParams: {}
  healthCheckPort: 16687
  basePath: /
  replicaCount: 1
  service:
    annotations: {}
    type: ClusterIP
    # List of IP ranges that are allowed to access the load balancer (if supported)
    loadBalancerSourceRanges: []
    # queryPort: externally accessible port for UI and API
    queryPort: 80
    # targetPort: the internal port the UI and API are exposed on
    targetPort: 16686
  ingress:
    enabled: false
    annotations: {}
    # Used to create an Ingress record.
    # hosts:
    #   - chart-example.local
    # annotations:
      # kubernetes.io/ingress.class: nginx
      # kubernetes.io/tls-acme: "true"
    # tls:
      # Secrets must be manually created in the namespace.
      # - secretName: chart-example-tls
      #   hosts:
      #     - chart-example.local
  resources: {}
    # limits:
    #   cpu: 500m
    #   memory: 512Mi
    # requests:
    #    cpu: 256m
    #    memory: 128Mi
  nodeSelector: {}
  podAnnotations: {}
  ## Additional pod labels
  ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  podLabels: {}
  ## Allow the scheduling on tainted nodes (requires Kubernetes >= 1.6)
  ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
  tolerations: []
  
spark:
  enabled: false
  annotations: {}
  image: jaegertracing/spark-dependencies
  tag: latest
  pullPolicy: Always
  schedule: "49 23 * * *"
  successfulJobsHistoryLimit: 5
  failedJobsHistoryLimit: 5
  resources: {}
    # limits:
    #   cpu: 500m
    #   memory: 512Mi
    # requests:
    #   cpu: 256m
    #   memory: 128Mi
  nodeSelector: {}
  ## Additional pod labels
  ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  podLabels: {}
  ## Allow the scheduling on tainted nodes (requires Kubernetes >= 1.6)
  ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
  tolerations: []
# End: Default values for the various components of Jaeger
  
hotrod:
  enabled: false
  replicaCount: 1
  image:
    repository: jaegertracing/example-hotrod
    tag: latest
    pullPolicy: Always
  service:
    annotations: {}
    name: hotrod
    type: ClusterIP
    # List of IP ranges that are allowed to access the load balancer (if supported)
    loadBalancerSourceRanges: []
    externalPort: 80
    internalPort: 8080
  ingress:
    enabled: false
    # Used to create Ingress record (should be used with service.type: ClusterIP).
    hosts:
      - chart-example.local
    annotations: {}
      # kubernetes.io/ingress.class: nginx
      # kubernetes.io/tls-acme: "true"
    tls:
      # Secrets must be manually created in the namespace.
      # - secretName: chart-example-tls
      #   hosts:
      #     - chart-example.local
  resources: {}
    # We usually recommend not to specify default resources and to leave this as a conscious
    # choice for the user. This also increases chances charts run on environments with little
    # resources, such as Minikube. If you do want to specify resources, uncomment the following
    # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
    # limits:
    #   cpu: 100m
    #   memory: 128Mi
    # requests:
    #   cpu: 100m
    #   memory: 128Mi
  tracing:
    host: null
    port: 6831

local docker

1
docker run --rm -it --network=host jaegertracing/all-in-one


Zipikin vs Jaeger

Launguage

 

 Zipkin

 Jaeger

 C++

 Unofficial

 Official

 C#

 Official

 Official

 Go

 Official

 Official

 Java

Official

 Official

 Python

 Unofficial

 Official

 Ruby

 Official

 Unofficial

 Scala

 Official

 Unofficial(or use the Java library)

 Node.js

 Official

 Official

 PHP

 Unofficial

 Unofficial


Framework & Library

zipkin의 경우 인기있는 프레임워크를 지원하고 데이터베이스 드라이버와 같은 라이브러리를 지원한다.

jagger의 경우 Open Tracinginstrumentation libraries 를 활용한 다양한 라이브러리로 구현이 가능하다

jager는 또 gRPC, Thrift 및 AWS SDK 도구가 포함되어있다.

둘다 백엔드는 카산드라와 엘라스틱서치를 지원한다.





Jaeger는 CNCF의 일부로 당연히 kubernetes환경에 적합하게 설계되어있다.

helm 차트 템플릿 과 Envoy 또는 Isito 와 같은 서비스 프록시를 Jaeger Suppoter와 함께 사용하면 컨테이너에서 호출을 추적하는 것이

용이하다.

즉 k8s 통합환경에서 분산 추적에 맞게 설계되어있다.

Zipkin은 Docker 이미지와 Java 라이브러리를 제공Jaeger와 달리 Zipkin은 수집기, 저장소, API 및 UI가 포함 된 단일 프레임워크이다.

Conclusion

production환경이 kubernetes면 무조건 jaeger를 단일 환경 및 모놀리틱 시스템에는 zipkin을 고려해볼만 하다

즉 컨테이너 환경에는 jaeger로 가야되는게 맞는거 같다.

또한 jaeger안에는 expoter로 zipkin도 있기때문에 zipkin도 통합할수 있다.

즉 jaeger를 써보고 맞지않는다면 zipkin을 고려해보면 좋겠다.




'devops > msa' 카테고리의 다른 글

Microservice 4.0 (Istio Service Mesh and Serverless)  (0) 2018.10.11
istio  (0) 2018.10.11
Comments