-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tag 2021.01.05 add tail based sample to current otel guides. committe…
…r:陈晨。 add tail based sample and update read me file contents.
- Loading branch information
Showing
13 changed files
with
269 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### Open-Telemetry Config 目录 | ||
|
||
> Open-Telemetry Config 目录仅仅是个人的一些配置参考。 | ||
##### 列表 | ||
|
||
- otel-col-config.yaml: Otel-Collector-Dev 内部的配置相关,仅供参考。 | ||
|
||
- otel-col-contrib-config.yaml: Otel-Collector-Contrib-Dev 内部的配置相关,仅供参考。 | ||
|
||
- others.properties: 个人用的其他配置,仅供参考。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
extensions: | ||
health_check: | ||
pprof: | ||
endpoint: 0.0.0.0:1777 | ||
zpages: | ||
endpoint: 0.0.0.0:55679 | ||
|
||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
|
||
|
||
|
||
processors: | ||
batch: | ||
send_batch_size: 10000 | ||
send_batch_max_size: 10240 | ||
timeout: 5s | ||
|
||
tail_sampling: | ||
decision_wait: 50s | ||
num_traces: 200 | ||
expected_new_traces_per_sec: 10 | ||
policies: | ||
[ | ||
{ | ||
name: test-policy-1, | ||
type: numeric_attribute, ## 因为 min_value, max_value是闭区间。[201, 999] | ||
numeric_attribute: {key: http.status_code, min_value: 201, max_value: 999} | ||
} | ||
] | ||
|
||
exporters: | ||
logging: | ||
logLevel: DEBUG | ||
sampling_initial: 5 | ||
sampling_thereafter: 200 | ||
jaeger: | ||
endpoint: 192.168.2.6:14250 | ||
insecure: true | ||
prometheusremotewrite: | ||
endpoint: "http://192.168.2.6:9998" | ||
namespace: "otel-collector-metrics-space" | ||
insecure: true | ||
|
||
service: | ||
|
||
pipelines: | ||
|
||
traces: | ||
receivers: [otlp] | ||
processors: [tail_sampling] | ||
exporters: [logging, jaeger] | ||
|
||
metrics: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [logging, prometheusremotewrite] | ||
|
||
extensions: [health_check, pprof, zpages] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,58 @@ | ||
docker 命令:仅供参考。 | ||
## docker 命令:仅供参考。 只是很不喜欢官方docker compose 的端口映射。 | ||
|
||
jaeger: | ||
##jaeger: | ||
## 中文文档有个端口忘记开启,切记切记。 | ||
|
||
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 -p 14250:14250 jaegertracing/all-in-one:1.16 | ||
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 -p 14250:14250 \ | ||
jaegertracing/all-in-one:1.16 | ||
|
||
|
||
prometheus: | ||
##prometheus: | ||
|
||
docker search prometheus | ||
|
||
docker pull prom/prometheus | ||
|
||
docker run --name prometheus -d -p 9999:9090 quay.io/prometheus/prometheus | ||
docker run --name prometheus -d -p 9999:9090 \ | ||
quay.io/prometheus/prometheus | ||
|
||
docker cp prometheus.yml 204ff9046a33:/etc/prometheus/prometheus.yml | ||
|
||
prometheus gateway: | ||
## prometheus gateway: | ||
|
||
docker pull prom/pushgateway | ||
|
||
docker run -d --name=pg -p 9091:9091 prom/pushgateway | ||
|
||
|
||
grafana: | ||
## grafana: | ||
|
||
docker pull grafana/grafana | ||
|
||
docker run -d -p 3000:3000 --name=grafana grafana/grafana | ||
|
||
|
||
otel-docker: | ||
## otel-docker: | ||
|
||
hub.docker search otel ---> docker pull 。 | ||
|
||
docker run -d -p 1777:1777 -p 4317:4317 -p 8888:8888 -p 13133:13133 -p 55678:55678 -p 55679:55679 -p 55680:55680 -p 55681:55681 --name otelcol-dev otel/opentelemetry-collector-dev | ||
docker run -d -p 1777:1777 -p 4317:4317 \ | ||
-p 8888:8888 -p 13133:13133 -p 55678:55678 \ | ||
-p 55679:55679 -p 55680:55680 -p 55681:55681 \ | ||
--name otelcol-dev otel/opentelemetry-collector-dev | ||
|
||
docker cp config.yaml 85dee316e533:/etc/otel/config.yaml | ||
|
||
|
||
## otel-col-contrib to docker. | ||
docker run -p 1777:1777 -p 4317:4317 \ | ||
-p 8888:8888 -p 13133:13133 \ | ||
-p 55679:55679 -p 55680:55680 \ | ||
-p 55681:55681 \ | ||
-v /c/Users/chenc/dockerOtelTest/config.yaml:/etc/otel/config.yaml \ | ||
--name otelcol-contrib-dev otel/opentelemetry-collector-contrib-dev | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### Open-Telemetry-Simple-TailBased 案例工程 | ||
|
||
> Open-Telemetry-Simple-TailBased 实际测试了 Otel-Col 对 Trace Data 的采样规则。 | ||
##### 测试模块快速开始 | ||
|
||
1. 确保[Guides 案例工程下的步骤](../README.md)执行完毕。 | ||
|
||
2. 启动此模块[otel-simple-tailbase](https://github.com/chenmudu/open-telemetry-java-guides/tree/master/otel-simple-tailbase/src/main/java/org/chenmudu/otel/tailbase)TailBasedRunMain. | ||
|
||
3. 访问http://localhost:10009/tailbased。 | ||
|
||
4. Copy Console 中的 TraceId访问 http://localhost:16686/ 即可观测结果。 | ||
|
||
##### 注意 | ||
|
||
1. 当你使用想观测 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>open-telemetry-java-guides</artifactId> | ||
<groupId>org.chenmudu.otel</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>otel-simple-tailbase</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-extension-annotations</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
30 changes: 30 additions & 0 deletions
30
otel-simple-tailbase/src/main/java/org/chenmudu/otel/tailbase/TailBasedRunMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* MIT License | ||
* <p> | ||
* Copyright (c) 2020 chenmudu (陈晨) | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
package org.chenmudu.otel.tailbase; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* | ||
* @author [email protected] 2021/1/5 00:15 | ||
*/ | ||
@SpringBootApplication | ||
public class TailBasedRunMain { | ||
public static void main(String[] args) { | ||
SpringApplication.run(TailBasedRunMain.class, args); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...lbase/src/main/java/org/chenmudu/otel/tailbase/controller/OtelTestTailBaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* MIT License | ||
* <p> | ||
* Copyright (c) 2020 chenmudu (陈晨) | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
package org.chenmudu.otel.tailbase.controller; | ||
|
||
import io.opentelemetry.extension.annotations.WithSpan; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* | ||
* @author [email protected] 2021/1/5 00:16 | ||
*/ | ||
@Slf4j | ||
@RestController | ||
public class OtelTestTailBaseController { | ||
|
||
private volatile Integer counter = 0; | ||
|
||
@GetMapping("/tailbased") | ||
public String tailbased() { | ||
log.info("OtelTestTailBaseController hello started!"); | ||
this.calledHi(); | ||
return "OtelTestTailBaseController hello !"; | ||
} | ||
|
||
@WithSpan(value = "testCalledHi") | ||
private String calledHi() { | ||
log.info("OtelTestTailBaseController calledHi started!"); | ||
// 当你配置了tail_base采样规则时即可生效。 | ||
if(counter++ % 2 == 1) { | ||
int i = 1 /0 ; | ||
} | ||
return "calledHi"; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
otel-simple-tailbase/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
server.port=10009 | ||
|
||
spring.application.name=otel-simple-tail-based |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<configuration> | ||
<jmxConfigurator/> | ||
<property name="charset" value="UTF-8" /> | ||
<property name="pattern" | ||
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-5level] - [%X{traceId},%X{spanId}]- %logger{30}.%method:%line %msg%n" /> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>${pattern}</pattern> | ||
</encoder> | ||
</appender> | ||
<root level="INFO"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters