기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
관찰성
이 문서는 미리 보기로 출시된 서비스의 사전 릴리스 설명서입니다. 변경될 수 있습니다. |
관측성은 시스템의 현재 상태가 시스템에서 내보내는 데이터에서 추론될 수 있는 정도입니다. 방출되는 데이터는 일반적으로 원격 측정이라고 합니다. AWS 서비스 사용 시 원격 측정에 대한 자세한 내용은 AWS SDK for .NET 개발자 안내서의 관찰 가능성을 참조하세요.
다음 코드는 에서 관찰 가능성을 활성화하는 방법의 예를 보여줍니다 AWS Tools for PowerShell.
<# This is an example of generating telemetry for AWS Tools for PowerShell. Each cmdlet that interacts with an Amazon Web Service creates a trace containing spans for underlying processes and AWS SDK for .NET operations. This example is written using PowerShell 7 and .NET 8. It requires the installation of the .NET CLI tool. Note that implementation varies by the exporter/endpoint, which is not specified in this example. For more information, see https://opentelemetry.io/docs/languages/net/exporters/. #> # Set this value to a common folder path on your computer for local development of code repositories. $devProjectsPath = [System.IO.Path]::Join('C:', 'Dev', 'Repos') # If these values are changed, update the hardcoded method invocation toward the end of this script. # Values must follow constraints for namespaces and classes. $telemetryProjectName = 'ExampleAWSPowerShellTelemetryImplementation' $serviceName = 'ExamplePowerShellService' # This example supposes that the OTLP exporter requires these two properties, # but some exporters require different properties or no properties. $telemetryEndPoint = 'https://example-endpoint-provider.io' $telemetryHeaders = 'x-example-header=abc123' $dllsPath = [System.IO.Path]::Join($devProjectsPath, $telemetryProjectName, 'bin', 'Release', 'net8.0', 'publish') $telemetryProjectPath = [System.IO.Path]::Join($devProjectsPath, $telemetryProjectName) # This script is designed to recreate the example telemetry project each time it's executed. Remove-Item -Path $telemetryProjectPath -Recurse -Force -ErrorAction 'SilentlyContinue' $null = New-Item -Path $devProjectsPath -Name $telemetryProjectName -ItemType 'Directory' <# Create and build a C#-based .NET 8 project that implements OpenTelemetry Instrumentation for the AWS Tools for PowerShell. #> Set-Location -Path $telemetryProjectPath dotnet new classlib # Other exporters are available. # For more information, see https://opentelemetry.io/docs/languages/net/exporters/. dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol dotnet add package OpenTelemetry.Instrumentation.AWS --prerelease $classContent = @" using OpenTelemetry; using OpenTelemetry.Resources; using OpenTelemetry.Trace; namespace Example.Telemetry; public class AWSToolsForPowerShellTelemetry { public static void InitializeAWSInstrumentation() { Sdk.CreateTracerProviderBuilder() .ConfigureResource(e => e.AddService("$ServiceName")) .AddAWSInstrumentation() // Exporters vary so options might need to be changed or omitted. .AddOtlpExporter(options => { options.Endpoint = new Uri("$telemetryEndPoint"); options.Headers = "$telemetryHeaders"; }) .Build(); } } "@ $csFilePath = [System.IO.Path]::Join($telemetryProjectPath, ($serviceName + '.cs')) Set-Content -Path $csFilePath -Value $classContent dotnet build dotnet publish -c Release <# Add additional modules here for any other cmdlets that you require. Beyond this point, additional AWS Tools for PowerShell modules will fail to import due to conflicts with the AWS SDK for .NET assemblies that are added next. #> Import-Module -Name 'AWS.Tools.Common' Import-Module -Name 'AWS.Tools.DynamoDBv2' # Load assemblies for the telemetry project, excluding the AWS SDK for .NET assemblies # that were already loaded by importing AWS Tools for PowerShell modules. $dlls = (Get-ChildItem $dllsPath -Filter *.dll -Recurse ).FullName $AWSSDKAssembliesAlreadyLoaded = [Threading.Thread]::GetDomain().GetAssemblies().Location | Where-Object {$_ -like '*AWSSDK*' } | Split-Path -Leaf $dlls.Where{$AWSSDKAssembliesAlreadyLoaded -notcontains ($_ | Split-Path -Leaf)}.ForEach{Add-Type -Path $_} # Invoke the method defined earlier in this script. [Example.Telemetry.AWSToolsForPowerShellTelemetry]::InitializeAWSInstrumentation() <# Now telemetry will be exported for AWS Tools for PowerShell cmdlets that are invoked directly or indirectly. Execute this cmdlet or execute your own PowerShell script. #> Get-DDBTable -TableName 'DotNetTests-HashTable' -Region 'us-east-1'