在亚马逊上运行 X-Ray 守护程序 EC2 - AWS X-Ray

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

在亚马逊上运行 X-Ray 守护程序 EC2

注意

End-of-support 注意 — 2027 年 2 月 25 日, AWS X-Ray 将停止对 AWS X-Ray SDKs 和守护程序的支持。2027 年 2 月 25 日之后,您将不再收到更新或发布。有关支持时间表的更多信息,请参阅X-Ray SDK 和守护程序终止支持时间表。我们建议迁移到 OpenTelemetry。有关迁移到的更多信息 OpenTelemetry,请参阅从 X-Ray 仪器迁移到 OpenTelemetry 仪器

您可以在亚马逊 EC2的以下操作系统上运行 X-Ray 守护程序:

  • Amazon Linux

  • Ubuntu

  • Windows Server(2012 R2 及更高版本)

使用实例配置文件授予进程守护程序权限以上传跟踪数据到 X-Ray。有关更多信息,请参阅 授予进程守护程序向 X-Ray 发送数据的权限

使用用户数据脚本在启动实例时自动运行进程守护程序。

例 用户数据脚本 - Linux
#!/bin/bash curl https://s3.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-3.x.rpm -o /home/ec2-user/xray.rpm yum install -y /home/ec2-user/xray.rpm
例 用户数据脚本 - Windows Server
<powershell> if ( Get-Service "AWSXRayDaemon" -ErrorAction SilentlyContinue ) { sc.exe stop AWSXRayDaemon sc.exe delete AWSXRayDaemon } $targetLocation = "C:\Program Files\Amazon\XRay" if ((Test-Path $targetLocation) -eq 0) { mkdir $targetLocation } $zipFileName = "aws-xray-daemon-windows-service-3.x.zip" $zipPath = "$targetLocation\$zipFileName" $destPath = "$targetLocation\aws-xray-daemon" if ((Test-Path $destPath) -eq 1) { Remove-Item -Recurse -Force $destPath } $daemonPath = "$destPath\xray.exe" $daemonLogPath = "$targetLocation\xray-daemon.log" $url = "https://s3.dualstack.us-west-2.amazonaws.com/aws-xray-assets.us-west-2/xray-daemon/aws-xray-daemon-windows-service-3.x.zip" Invoke-WebRequest -Uri $url -OutFile $zipPath Add-Type -Assembly "System.IO.Compression.Filesystem" [io.compression.zipfile]::ExtractToDirectory($zipPath, $destPath) New-Service -Name "AWSXRayDaemon" -StartupType Automatic -BinaryPathName "`"$daemonPath`" -f `"$daemonLogPath`"" sc.exe start AWSXRayDaemon </powershell>