我正在为研究 OpenTelemetry 编写简单的项目。
我想使用 otel 来配置许多出口商。
谁能建议我如何配置代理和收集器?我尝试了 github 示例,但无法正常工作。
我的码头工人撰写:
otel-collector:
container_name: otel-collector
image: otel/opentelemetry-collector
volumes:
- ./../config/otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "1888:1888" # pprof extension
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
- "13133:13133" # health_check extension
- "4317" # OTLP gRPC receiver
- "55670:55679" # zpages extension
depends_on:
- zipkin
otel-agent:
container_name: otel-agent
image: otel/opentelemetry-collector
command: ["--config=/etc/otel-agent-config.yaml", "${OTELCOL_ARGS}"]
volumes:
- ./../config/otel-agent-config.yaml:/etc/otel-agent-config.yaml
ports:
- "8887:8888" # Prometheus metrics exposed by the agent
- "14250" # Jaeger grpc receiver
- "14268" # Jaeger http thrift receiver
- "55678" # OpenCensus receiver
- "4317" # OTLP gRPC receiver
- "9411" # Zipkin receiver
- "1777:1777" # pprof extension
- "55679:55679" # zpages extension
- "13133" # health_check
depends_on:
- otel-collector
我的代理配置:
我想从 .net 应用程序接收数据并将其重定向到 otel-collector。
receivers:
otlp:
protocols:
grpc:
http:
zipkin:
exporters:
otlp:
endpoint: otel-collector:4317
insecure: true
logging:
loglevel: debug
processors:
batch:
extensions:
health_check:
pprof:
endpoint: 0.0.0.0:1777
zpages:
endpoint: 0.0.0.0:55679
service:
extensions: [health_check, pprof, zpages]
pipelines:
traces:
receivers: [otlp, zipkin]
processors: [batch]
exporters: [otlp, logging]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlp, logging]
我的收集器配置:
我想从代理接收数据并重定向到导出器:zipkin、newrelic、logger。
receivers:
otlp:
protocols:
grpc:
http:
exporters:
logging:
loglevel: debug
zipkin:
endpoint: "http://zipkin:9411/api/v2/spans"
format: proto
newrelic:
apikey: NRAK-abc
timeout: 30s
traces:
host_override: trace-api.eu.newrelic.com
timeout: 20s
metrics:
host_override: metric-api.eu.newrelic.com
logs:
host_override: log-api.eu.newrelic.com
processors:
batch:
extensions:
health_check:
pprof:
endpoint: :1888
zpages:
endpoint: :55679
service:
extensions: [pprof, zpages, health_check]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging, zipkin, newrelic]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [logging, zipkin, newrelic]
我的 dotnet 应用程序启动:
services.AddOpenTelemetryTracing((builder) => builder
.AddSource("Sample")
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("SampleApi").AddTelemetrySdk())
.AddAspNetCoreInstrumentation(options =>
{
options.Filter = (req) => !req.Request.Path.ToUriComponent().Contains("swagger", StringComparison.OrdinalIgnoreCase);
})
.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Endpoint = new Uri("http://otel-collector:4317");
})