3.6. 扩展
扩展为 Collector 添加功能。例如,身份验证可以自动添加到接收器和导出器中。
目前,红帽构建的 OpenTelemetry 提供了以下正式发行(GA)和技术预览扩展:
3.6.1. BearerTokenAuth Extension
BearerTokenAuth Extension 是基于 HTTP 和 gRPC 协议的接收器和导出器的验证器。您可以使用 OpenTelemetry Collector 自定义资源为接收器和 exporter 端的 BearerTokenAuth Extension 配置客户端身份验证和服务器身份验证。此扩展支持 trace、metrics 和 logs。
OpenTelemetry Collector 自定义资源,为 BearerTokenAuth Extension 配置了客户端和服务器身份验证
# ... config: extensions: bearertokenauth: scheme: "Bearer" 1 token: "<token>" 2 filename: "<token_file>" 3 receivers: otlp: protocols: http: auth: authenticator: bearertokenauth 4 exporters: otlp: auth: authenticator: bearertokenauth 5 service: extensions: [bearertokenauth] pipelines: traces: receivers: [otlp] exporters: [otlp] # ...
3.6.2. OAuth2Client Extension
OAuth2Client Extension 是导出器的验证器,它基于 HTTP 和 gRPC 协议。OAuth2Client Extension 的客户端身份验证在 OpenTelemetry Collector 自定义资源中的单独部分中配置。此扩展支持 trace、metrics 和 logs。
OAuth2Client 扩展只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
OpenTelemetry Collector 自定义资源,为 OAuth2Client Extension 配置了客户端身份验证
# ... config: extensions: oauth2client: client_id: <client_id> 1 client_secret: <client_secret> 2 endpoint_params: 3 audience: <audience> token_url: https://example.com/oauth2/default/v1/token 4 scopes: ["api.metrics"] 5 # tls settings for the token client tls: 6 insecure: true 7 ca_file: /var/lib/mycert.pem 8 cert_file: <cert_file> 9 key_file: <key_file> 10 timeout: 2s 11 receivers: otlp: protocols: http: {} exporters: otlp: auth: authenticator: oauth2client 12 service: extensions: [oauth2client] pipelines: traces: receivers: [otlp] exporters: [otlp] # ...
- 1
- 客户端标识符,由身份提供程序提供。
- 2
- 用于向身份提供程序验证客户端的机密密钥。
- 3
- 其他元数据,采用键值对格式,在身份验证过程中传输。例如,
audience
指定访问令牌的预期受众,指示令牌的接收者。 - 4
- OAuth2 令牌端点的 URL,Collector 请求访问令牌。
- 5
- 范围定义客户端请求的特定权限或访问级别。
- 6
- 令牌客户端的传输层安全性 (TLS) 设置,用于在请求令牌时建立安全连接。
- 7
- 当设置为
true
时,将 Collector 配置为使用不安全或非验证的 TLS 连接来调用配置的令牌端点。 - 8
- 用于在 TLS 握手过程中验证服务器证书的证书颁发机构 (CA) 文件的路径。
- 9
- 如果需要,客户端必须用来向 OAuth2 服务器验证自己的客户端证书文件的路径。
- 10
- 身份验证所需的客户端私钥文件的路径。
- 11
- 为令牌客户端的请求设置超时。
- 12
- 您可以将验证器配置分配给 OTLP 导出器。
3.6.3. File Storage Extension
File Storage Extension 支持 trace、metrics 和 logs。此扩展可保留本地文件系统的状态。此扩展会保留基于 HTTP 和 gRPC 协议的 OpenTelemetry 协议 (OTLP) 导出器的发送队列。此扩展需要对目录的读和写访问权限。此扩展可以使用默认目录,但默认目录必须已存在。
File Storage Extension 只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
OpenTelemetry Collector 自定义资源带有配置的文件存储扩展,它会保留 OTLP 发送队列
# ... config: extensions: file_storage/all_settings: directory: /var/lib/otelcol/mydir 1 timeout: 1s 2 compaction: on_start: true 3 directory: /tmp/ 4 max_transaction_size: 65_536 5 fsync: false 6 exporters: otlp: sending_queue: storage: file_storage/all_settings 7 service: extensions: [file_storage/all_settings] 8 pipelines: traces: receivers: [otlp] exporters: [otlp] # ...
3.6.4. OIDC Auth Extension
OIDC Auth Extension 使用 OpenID Connect (OIDC) 协议向接收器验证传入的请求。它针对签发者验证授权标头中的 ID 令牌,并更新传入请求的身份验证上下文。
OIDC Auth Extension 只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
OpenTelemetry Collector 自定义资源带有配置的 OIDC Auth Extension
# ... config: extensions: oidc: attribute: authorization 1 issuer_url: https://example.com/auth/realms/opentelemetry 2 issuer_ca_path: /var/run/tls/issuer.pem 3 audience: otel-collector 4 username_claim: email 5 receivers: otlp: protocols: grpc: auth: authenticator: oidc exporters: debug: {} service: extensions: [oidc] pipelines: traces: receivers: [otlp] exporters: [debug] # ...
3.6.5. Jaeger Remote Sampling Extension
Jaeger Remote Sampling Extension 在 Jaeger 的远程抽样 API 后启用服务抽样策略。您可以配置此扩展,将请求代理到后备远程抽样服务器,如 Jaeger 收集器关闭管道或从本地文件系统到静态 JSON 文件。
Jaeger Remote Sampling Extension 只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
OpenTelemetry Collector 自定义资源带有配置的 Jaeger Remote Sampling Extension
# ... config: extensions: jaegerremotesampling: source: reload_interval: 30s 1 remote: endpoint: jaeger-collector:14250 2 file: /etc/otelcol/sampling_strategies.json 3 receivers: otlp: protocols: http: {} exporters: debug: {} service: extensions: [jaegerremotesampling] pipelines: traces: receivers: [otlp] exporters: [debug] # ...
Jaeger Remote Sampling 策略文件示例
{ "service_strategies": [ { "service": "foo", "type": "probabilistic", "param": 0.8, "operation_strategies": [ { "operation": "op1", "type": "probabilistic", "param": 0.2 }, { "operation": "op2", "type": "probabilistic", "param": 0.4 } ] }, { "service": "bar", "type": "ratelimiting", "param": 5 } ], "default_strategy": { "type": "probabilistic", "param": 0.5, "operation_strategies": [ { "operation": "/health", "type": "probabilistic", "param": 0.0 }, { "operation": "/metrics", "type": "probabilistic", "param": 0.0 } ] } }
3.6.6. Performance Profiler Extension
Performance Profiler Extension 启用 Go net/http/pprof
端点。开发人员使用此扩展来收集性能配置集并调查服务的问题。
Performance Profiler 扩展只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
OpenTelemetry Collector 自定义资源带有配置的 Performance Profiler Extension
# ... config: extensions: pprof: endpoint: localhost:1777 1 block_profile_fraction: 0 2 mutex_profile_fraction: 0 3 save_to_file: test.pprof 4 receivers: otlp: protocols: http: {} exporters: debug: {} service: extensions: [pprof] pipelines: traces: receivers: [otlp] exporters: [debug] # ...
3.6.7. Health Check Extension
Health Check Extension 提供了一个 HTTP URL,用于检查 OpenTelemetry Collector 的状态。您可以将此扩展用作 OpenShift 上的存活度和就绪度探测。
健康检查扩展只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
OpenTelemetry Collector 自定义资源带有配置的 Health Check Extension
# ... config: extensions: health_check: endpoint: "0.0.0.0:13133" 1 tls: 2 ca_file: "/path/to/ca.crt" cert_file: "/path/to/cert.crt" key_file: "/path/to/key.key" path: "/health/status" 3 check_collector_pipeline: 4 enabled: true 5 interval: "5m" 6 exporter_failure_threshold: 5 7 receivers: otlp: protocols: http: {} exporters: debug: {} service: extensions: [health_check] pipelines: traces: receivers: [otlp] exporters: [debug] # ...
3.6.8. zPages Extension
zPages 扩展提供了一个 HTTP 端点,提供实时数据来实时调试检测组件。您可以使用此扩展进行进程诊断,并深入了解 trace 和 metrics,而无需依赖外部的后端。使用这个扩展,您可以通过观察提供的端点上的诊断信息来监控和排除 OpenTelemetry Collector 和相关组件的行为。
zPages 扩展只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
OpenTelemetry Collector 自定义资源带有配置的 zPages Extension
# ...
config:
extensions:
zpages:
endpoint: "localhost:55679" 1
receivers:
otlp:
protocols:
http: {}
exporters:
debug: {}
service:
extensions: [zpages]
pipelines:
traces:
receivers: [otlp]
exporters: [debug]
# ...
- 1
- 指定提供 zPages 扩展的 HTTP 端点。默认值为
localhost:55679
。
访问 HTTP 端点需要端口转发,因为红帽构建的 OpenTelemetry Operator 不会公开此路由。
您可以通过运行以下 oc
命令启用端口转发:
$ oc port-forward pod/$(oc get pod -l app.kubernetes.io/name=instance-collector -o=jsonpath='{.items[0].metadata.name}') 55679
Collector 为诊断提供以下 zPages:
- ServiceZ
-
显示 Collector 服务和到以下 zPages 的链接的概述:PipelineZ、ExtensionZ 和 FeatureZ。本页还显示有关构建版本和运行时的信息。此页面的 URL 示例是
http://localhost:55679/debug/servicez
。 - PipelineZ
-
显示有关 Collector 中活跃管道的详细信息。此页面显示管道类型,无论数据是否被修改,以及每个管道的相关接收器、处理器和导出器。此页面的 URL 示例是
http://localhost:55679/debug/pipelinez
。 - ExtensionZ
-
显示 Collector 中当前活跃的扩展。此页面的 URL 示例是
http://localhost:55679/debug/extensionz
。 - FeatureZ
-
显示 Collector 中启用的功能门及其状态和描述。此页面的 URL 示例是
http://localhost:55679/debug/featurez
。 - TraceZ
-
显示延迟,按 span 分类。可用时间范围包括 0 µs, 10 µs, 100 µs, 1 ms, 10 ms, 100 ms, 1 s, 10 s, 1 m.此页面还允许快速检查错误示例。此页面的 URL 示例是
http://localhost:55679/debug/tracez
。
3.6.9. 其他资源
- OpenTelemetry 协议(OTLP) (OpenTelemetry 文档)