otel
installation
doc https://opentelemetry.io/docs/collector/installation/
1 | ❯ helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts |
1 | ❯ helm template my-release ./opentelemetry-collector/ --values ./opentelemetry-collector/value.yaml |
mode**=**<daemonset**|**deployment**|**statefulset>
1 | exporters: |
1 | <a href="/tool/apm/exporter/#xx-exporter" target="_blank">exporter.yaml</a> |
service
nginx
source https://github.com/nginxinc/nginx-otel
deb https://nginx.org/packages/debian/pool/nginx/n/
仓库版本nginx-module-otel_1.26.x+0.1.0-x ,openrestry 1.25.x (截止2024.9.8 )
nginx: [emerg] module “/opt/proxy/openresty/nginx/modules/ngx_otel_module.so” version 1026000 instead of 1025003 in /opt/proxy/openresty/nginx/conf/nginx.conf:18
单独编译
1 | ❯ git clone --depth 1 https://github.com/nginxinc/nginx-otel.git |
跟openresty一起编译
1 | src=/home/cs/data/modules/nginx/src && \ |
nginx.conf
nginx.conf demo
load_module modules/ngx_otel_module.so;
http {
#####################################################
#https://nginx.org/en/docs/ngx_otel_module.html
otel_exporter {
endpoint localhost:4317;
interval 5s;
batch_size 512;
batch_count 4;
}
otel_service_name "openresty-1.25.3";
# otel_trace on; #http处全局开启
# trace 10% of requests
split_clients $otel_trace_id $ratio_sampler {
90% on;
* off;
}
# or we can trace 10% of user sessions
split_clients $cookie_sessionid $session_sampler {
90% on;
* off;
}
#####################################################
log_format local '$remote_addr - $upstream_addr - [$time_local] $status "$request $http_referer" $upstream_bytes_sent $http_host';
server {
listen 443 ssl;
server_name local.org ~^([\w-]+)\.local\.org$;
ssl_certificate conf.d/ssl/local.org/local.org.server.crt;
ssl_certificate_key conf.d/ssl/local.org/local.org.server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
access_log logs/local.log local;
location / {
#####################################################
otel_trace $ratio_sampler;
otel_trace_context propagate;
#####################################################
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxxxx;
}
}
}
以上编译nginx-otel操作会自动安装依赖,需要翻
❯ tree ./ -L 2
.
├── _deps
│ ├── grpc-build
│ ├── grpc-src
│ ├── grpc-subbuild
│ ├── otelcpp-build ## https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md
│ ├── otelcpp-src
│ └── otelcpp-subbuild
├── cmake_install.cmake
├── CMakeCache.txt
├── CMakeFiles
│ ├── 3.25.1
│ ├── cmake.check_cache
│ ├── CMakeDirectoryInformation.cmake
│ ├── CMakeOutput.log
│ ├── CMakeRuleHashes.txt
│ ├── CMakeScratch
│ ├── Makefile.cmake
│ ├── Makefile2
│ ├── ngx_otel_module.dir
│ ├── pkgRedirects
│ ├── progress.marks
│ └── TargetDirectories.txt
├── gens
├── http_archives
│ └── opencensus-proto-0.3.0
├── Makefile
├── ngx_otel_module.so
├── opentelemetry
│ └── proto
└── protos
├── src
└── test