迁移至红帽构建的 OpenTelemetry


Red Hat build of OpenTelemetry 3.8

从 Jaeger 转换到 OpenTelemetry 以进行分布式追踪

Red Hat OpenShift Documentation Team

摘要

本文档论述了如何从 Red Hat build of Jaeger 迁移到红帽构建的 OpenTelemetry。了解两种迁移方法:将 Jaeger Agent sidecar 替换为 OpenTelemetry Collector sidecar,并在不使用独立 Collector 部署的情况下迁移不使用 sidecar。包括配置 Jaeger 接收器以保持协议兼容性、设置服务帐户和 RBAC 权限、启用 sidecar 注入和更新应用程序追踪端点的步骤,以便将 trace 导出为 TempoStack。

第 1 章 迁移

警告

弃用的 Red Hat OpenShift distributed tracing 平台(Jaeger) 3.5 是红帽支持的 Red Hat OpenShift distributed tracing 平台(Jaeger)的最后一个发行版本。

所有对已弃用 Red Hat OpenShift distributed tracing 平台(Jaeger) 3.5 的支持和维护在 2025 年 11 月 3 日终止。

如果您仍然使用 Red Hat OpenShift distributed tracing 平台(Jaeger),您必须迁移到红帽构建的 OpenTelemetry Operator 和 Tempo Operator 用于分布式追踪集合和存储。如需更多信息,请参阅 Red Hat build of OpenTelemetry 文档中的 "Migrating",请参阅 Red Hat build of OpenTelemetry 文档中的"安装",以及 Red Hat OpenShift distributed tracing 平台(Tempo)文档中的"安装"。

如需更多信息,请参阅 OpenShift 中的红帽知识库解决方案 Jaeger Deprecation 和 Removal

如果您已将 Red Hat OpenShift distributed tracing 平台(Jaeger)用于应用程序,您可以迁移到 OpenTelemetry 的红帽构建,它基于 OpenTelemetry 开源项目。

Red Hat build of OpenTelemetry 提供了一组 API、库、代理和工具,以便在分布式系统中促进可观察性。Red Hat build of OpenTelemetry 中的 OpenTelemetry Collector 可以影响 Jaeger 协议,因此您不需要在应用程序中更改 SDK。

从分布式追踪平台 (Jaeger) 迁移到红帽构建的 OpenTelemetry 需要配置 OpenTelemetry Collector 和应用程序来无缝报告 trace。您可以迁移 sidecar 和 sidecar 部署。

1.1. 使用 sidecar 迁移

Red Hat build of OpenTelemetry Operator 支持 sidecar 注入部署工作负载,以便您可以从分布式追踪平台(Jaeger) sidecar 迁移到红帽构建的 OpenTelemetry sidecar。

先决条件

  • 在集群中使用 Red Hat OpenShift distributed tracing Platform (Jaeger)。
  • 已安装红帽构建的 OpenTelemetry。

流程

  1. 将 OpenTelemetry Collector 配置为 sidecar。

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: <otel-collector-namespace>
    spec:
      mode: sidecar
      config:
        receivers:
          jaeger:
            protocols:
              grpc: {}
              thrift_binary: {}
              thrift_compact: {}
              thrift_http: {}
        processors:
          batch: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 50
            spike_limit_percentage: 30
          resourcedetection:
            detectors: [openshift]
            timeout: 2s
        exporters:
          otlp:
            endpoint: "tempo-<example>-gateway:8090" 
    1
    
            tls:
              insecure: true
        service:
          pipelines:
            traces:
              receivers: [jaeger]
              processors: [memory_limiter, resourcedetection, batch]
              exporters: [otlp]
    Copy to Clipboard Toggle word wrap
    1
    此端点指向使用 Tempo Operator 部署的 <example> TempoStack 实例的网关。
  2. 创建用于运行应用程序的服务帐户。

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: otel-collector-sidecar
    Copy to Clipboard Toggle word wrap
  3. 为某些处理器所需的权限创建集群角色。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: otel-collector-sidecar
    rules:
      
    1
    
    - apiGroups: ["config.openshift.io"]
      resources: ["infrastructures", "infrastructures/status"]
      verbs: ["get", "watch", "list"]
    Copy to Clipboard Toggle word wrap
    1
    resourcedetectionprocessor 需要基础架构和基础架构/状态的权限。
  4. 创建 ClusterRoleBinding 来为服务帐户设置权限。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: otel-collector-sidecar
    subjects:
    - kind: ServiceAccount
      name: otel-collector-deployment
      namespace: otel-collector-example
    roleRef:
      kind: ClusterRole
      name: otel-collector
      apiGroup: rbac.authorization.k8s.io
    Copy to Clipboard Toggle word wrap
  5. 将 OpenTelemetry Collector 部署为 sidecar。
  6. 通过从 Deployment 对象中删除 "sidecar.jaegertracing.io/inject": "true" 注解,从应用程序中删除注入的 Jaeger Agent。
  7. 通过将 sidecar.opentelemetry.io/inject: "true" 注解添加到 Deployment 对象的 .spec.template.metadata.annotations 字段来启用 OpenTelemetry sidecar 自动注入。
  8. 使用为应用程序部署创建的服务帐户,以允许处理器获取正确的信息并将其添加到您的追踪中。

1.2. 在没有 sidecar 的情况下迁移

您可以从分布式追踪平台(Jaeger)迁移到没有 sidecar 部署的红帽构建的 OpenTelemetry。

先决条件

  • 在集群中使用 Red Hat OpenShift distributed tracing Platform (Jaeger)。
  • 已安装红帽构建的 OpenTelemetry。

流程

  1. 配置 OpenTelemetry Collector 部署。
  2. 创建部署 OpenTelemetry Collector 的项目。

    apiVersion: project.openshift.io/v1
    kind: Project
    metadata:
      name: observability
    Copy to Clipboard Toggle word wrap
  3. 创建用于运行 OpenTelemetry Collector 实例的服务帐户。

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: otel-collector-deployment
      namespace: observability
    Copy to Clipboard Toggle word wrap
  4. 创建集群角色,以设置处理器所需的权限。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: otel-collector
    rules:
      
    1
    
      
    2
    
    - apiGroups: ["", "config.openshift.io"]
      resources: ["pods", "namespaces", "infrastructures", "infrastructures/status"]
      verbs: ["get", "watch", "list"]
    Copy to Clipboard Toggle word wrap
    1
    k8sattributesprocessor 需要 podsnamespaces 资源的权限。
    2
    resourcedetectionprocessor 需要 infrastructuresinfrastructures/status 的权限。
  5. 创建 ClusterRoleBinding 来为服务帐户设置权限。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: otel-collector
    subjects:
    - kind: ServiceAccount
      name: otel-collector-deployment
      namespace: observability
    roleRef:
      kind: ClusterRole
      name: otel-collector
      apiGroup: rbac.authorization.k8s.io
    Copy to Clipboard Toggle word wrap
  6. 创建 OpenTelemetry Collector 实例。

    注意

    此收集器会将 trace 导出至 TempoStack 实例。您必须使用 Red Hat Tempo Operator 创建 TempoStack 实例,并放在正确的端点中。

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: observability
    spec:
      mode: deployment
      serviceAccount: otel-collector-deployment
      config:
        receivers:
          jaeger:
            protocols:
              grpc: {}
              thrift_binary: {}
              thrift_compact: {}
              thrift_http: {}
        processors:
          batch: {}
          k8sattributes: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 50
            spike_limit_percentage: 30
          resourcedetection:
            detectors: [openshift]
        exporters:
          otlp:
            endpoint: "tempo-example-gateway:8090"
            tls:
              insecure: true
        service:
          pipelines:
            traces:
              receivers: [jaeger]
              processors: [memory_limiter, k8sattributes, resourcedetection, batch]
              exporters: [otlp]
    Copy to Clipboard Toggle word wrap
  7. 将追踪端点指向 OpenTelemetry Operator。
  8. 如果您要将 trace 直接从应用程序导出到 Jaeger,请将 API 端点从 Jaeger 端点改为 OpenTelemetry Collector 端点。

    使用带有 Golang 的 jaegerexporter 导出 trace 的示例

    exp, err := jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint(url))) 
    1
    Copy to Clipboard Toggle word wrap

    1
    URL 指向 OpenTelemetry Collector API 端点。

法律通告

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部