Enhance observability and error handling in NATS integration. Introduce comprehensive OpenTelemetry support with environment-based sampling and semantic attributes for tracing and metrics. Implement an advisory dead-letter queue (DLQ) handler for managing message delivery failures. Update NATS consumer to utilize structured logging and improve error handling strategies. Refactor configuration files for OpenTelemetry collector in both development and production environments, ensuring robust telemetry integration. Enhance documentation to reflect new features and best practices for observability.

This commit is contained in:
windyboy
2025-11-18 11:47:35 +08:00
parent 5d05237283
commit 7f44b5389d
31 changed files with 2546 additions and 476 deletions
+39
View File
@@ -3,27 +3,66 @@ receivers:
protocols:
http:
endpoint: 0.0.0.0:4318
max_request_body_size: 20971520 # 20MB
max_concurrent_streams: 16
grpc:
endpoint: 0.0.0.0:4317
max_recv_msg_size: 4194304 # 4MB
max_concurrent_streams: 16
processors:
batch:
send_batch_size: 1024
timeout: 1s
send_batch_max_size: 2048
resource:
attributes:
- key: service.instance.id
value: "${POD_NAME}"
action: upsert
- key: k8s.pod.name
value: "${POD_NAME}"
action: upsert
- key: k8s.namespace.name
value: "${NAMESPACE}"
action: upsert
exporters:
logging:
loglevel: info
sampling_initial: 10
sampling_thereafter: 100
otlphttp/jaeger:
endpoint: http://jaeger:4318
tls:
insecure: true
sending_queue:
queue_size: 10000
retry_on_failure:
enabled: true
initial_interval: 5s
max_interval: 30s
max_elapsed_time: 300s
prometheus:
endpoint: "0.0.0.0:8889"
const_labels:
source: "otel-collector"
sending_queue:
queue_size: 10000
retry_on_failure:
enabled: true
service:
pipelines:
traces:
receivers: [otlp]
processors: [resource, batch]
exporters: [logging, otlphttp/jaeger]
metrics:
receivers: [otlp]
processors: [resource, batch]
exporters: [logging, prometheus]