Class TraceExporting
(experimental) OpenTelemetry trace exporter and sampling configurations.
Namespace: Amazon.CDK.AWS.ApplicationSignals.Alpha
Assembly: Amazon.CDK.AWS.ApplicationSignals.Alpha.dll
Syntax (csharp)
public class TraceExporting : DeputyBase
Syntax (vb)
Public Class TraceExporting Inherits DeputyBase
Remarks
Contains constants for trace endpoints, sampling strategies, and propagation formats.
Stability: Experimental
ExampleMetadata: infused
Examples
using Constructs;
using Amazon.CDK.AWS.ApplicationSignals.Alpha;
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.ServiceDiscovery;
class MyStack : Stack
{
public MyStack(Construct? scope=null, string? id=null, StackProps props=new StackProps { }) : base(scope, id, props)
{
var vpc = new Vpc(this, "TestVpc", new VpcProps { });
var cluster = new Cluster(this, "TestCluster", new ClusterProps { Vpc = vpc });
var dnsNamespace = new PrivateDnsNamespace(this, "Namespace", new PrivateDnsNamespaceProps {
Vpc = vpc,
Name = "local"
});
var securityGroup = new SecurityGroup(this, "ECSSG", new SecurityGroupProps { Vpc = vpc });
securityGroup.AddIngressRule(securityGroup, Port.TcpRange(0, 65535));
// Define Task Definition for CloudWatch agent (Replica)
var cwAgentTaskDefinition = new FargateTaskDefinition(this, "CloudWatchAgentTaskDefinition", new FargateTaskDefinitionProps { });
new CloudWatchAgentIntegration(this, "CloudWatchAgentIntegration", new CloudWatchAgentIntegrationProps {
TaskDefinition = cwAgentTaskDefinition,
ContainerName = "ecs-cwagent",
EnableLogging = false,
Cpu = 128,
MemoryLimitMiB = 64,
PortMappings = new [] { new PortMapping {
Name = "cwagent-4316",
ContainerPort = 4316,
HostPort = 4316
}, new PortMapping {
Name = "cwagent-2000",
ContainerPort = 2000,
HostPort = 2000
} }
});
// Create the CloudWatch Agent replica service with service connect
// Create the CloudWatch Agent replica service with service connect
new FargateService(this, "CloudWatchAgentService", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = cwAgentTaskDefinition,
SecurityGroups = new [] { securityGroup },
ServiceConnectConfiguration = new ServiceConnectProps {
Namespace = dnsNamespace.NamespaceArn,
Services = new [] { new ServiceConnectService {
PortMappingName = "cwagent-4316",
DnsName = "cwagent-4316-http",
Port = 4316
}, new ServiceConnectService {
PortMappingName = "cwagent-2000",
DnsName = "cwagent-2000-http",
Port = 2000
} }
},
DesiredCount = 1
});
// Define Task Definition for user application
var sampleAppTaskDefinition = new FargateTaskDefinition(this, "SampleAppTaskDefinition", new FargateTaskDefinitionProps { });
sampleAppTaskDefinition.AddContainer("app", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("test/sample-app"),
Cpu = 0,
MemoryLimitMiB = 512
});
// Overwrite environment variables to connect to the CloudWatch Agent service just created
// Overwrite environment variables to connect to the CloudWatch Agent service just created
new ApplicationSignalsIntegration(this, "ApplicationSignalsIntegration", new ApplicationSignalsIntegrationProps {
TaskDefinition = sampleAppTaskDefinition,
Instrumentation = new InstrumentationProps {
SdkVersion = PythonInstrumentationVersion.V0_8_0
},
ServiceName = "sample-app",
OverrideEnvironments = new [] { new EnvironmentExtension {
Name = CommonExporting.OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT,
Value = "http://cwagent-4316-http:4316/v1/metrics"
}, new EnvironmentExtension {
Name = TraceExporting.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
Value = "http://cwagent-4316-http:4316/v1/traces"
}, new EnvironmentExtension {
Name = TraceExporting.OTEL_TRACES_SAMPLER_ARG,
Value = "endpoint=http://cwagent-2000-http:2000"
} }
});
// Create ECS Service with service connect configuration
// Create ECS Service with service connect configuration
new FargateService(this, "MySampleApp", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = sampleAppTaskDefinition,
ServiceConnectConfiguration = new ServiceConnectProps {
Namespace = dnsNamespace.NamespaceArn
},
DesiredCount = 1
});
}
}
Synopsis
Constructors
TraceExporting() | (experimental) OpenTelemetry trace exporter and sampling configurations. |
Properties
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | (experimental) Endpoint configuration for OTLP traces. |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_LOCAL_CWA | (experimental) Local CloudWatch Agent endpoint for traces. |
OTEL_PROPAGATORS | (experimental) Configuration for trace context propagation. |
OTEL_PROPAGATORS_APPLICATION_SIGNALS | (experimental) Supported propagation formats for Application Signals. |
OTEL_TRACES_SAMPLER | (experimental) Sampling configuration for traces. |
OTEL_TRACES_SAMPLER_ALWAYS_OFF | (experimental) Sample no traces. |
OTEL_TRACES_SAMPLER_ALWAYS_ON | (experimental) Sample all traces. |
OTEL_TRACES_SAMPLER_ARG | (experimental) Arguments for trace sampler configuration. |
OTEL_TRACES_SAMPLER_ARG_LOCAL_CWA | (experimental) Local CloudWatch Agent endpoint for sampler. |
OTEL_TRACES_SAMPLER_PARENT_BASED_ALWAYS_OFF | (experimental) Parent-based always off sampling. |
OTEL_TRACES_SAMPLER_PARENT_BASED_ALWAYS_ON | (experimental) Parent-based always on sampling. |
OTEL_TRACES_SAMPLER_PARENT_BASED_TRACEID_RATIO | (experimental) Parent-based trace ID ratio sampling. |
OTEL_TRACES_SAMPLER_TRACEID_RATIO | (experimental) Trace ID ratio based sampling. |
OTEL_TRACES_SAMPLER_XRAY | (experimental) X-Ray sampling strategy. |
Constructors
TraceExporting()
(experimental) OpenTelemetry trace exporter and sampling configurations.
public TraceExporting()
Remarks
Stability: Experimental
Properties
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
(experimental) Endpoint configuration for OTLP traces.
public static string OTEL_EXPORTER_OTLP_TRACES_ENDPOINT { get; }
Property Value
Remarks
Stability: Experimental
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_LOCAL_CWA
(experimental) Local CloudWatch Agent endpoint for traces.
public static string OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_LOCAL_CWA { get; }
Property Value
Remarks
Stability: Experimental
OTEL_PROPAGATORS
(experimental) Configuration for trace context propagation.
public static string OTEL_PROPAGATORS { get; }
Property Value
Remarks
Stability: Experimental
OTEL_PROPAGATORS_APPLICATION_SIGNALS
(experimental) Supported propagation formats for Application Signals.
public static string OTEL_PROPAGATORS_APPLICATION_SIGNALS { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER
(experimental) Sampling configuration for traces.
public static string OTEL_TRACES_SAMPLER { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_ALWAYS_OFF
(experimental) Sample no traces.
public static string OTEL_TRACES_SAMPLER_ALWAYS_OFF { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_ALWAYS_ON
(experimental) Sample all traces.
public static string OTEL_TRACES_SAMPLER_ALWAYS_ON { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_ARG
(experimental) Arguments for trace sampler configuration.
public static string OTEL_TRACES_SAMPLER_ARG { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_ARG_LOCAL_CWA
(experimental) Local CloudWatch Agent endpoint for sampler.
public static string OTEL_TRACES_SAMPLER_ARG_LOCAL_CWA { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_PARENT_BASED_ALWAYS_OFF
(experimental) Parent-based always off sampling.
public static string OTEL_TRACES_SAMPLER_PARENT_BASED_ALWAYS_OFF { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_PARENT_BASED_ALWAYS_ON
(experimental) Parent-based always on sampling.
public static string OTEL_TRACES_SAMPLER_PARENT_BASED_ALWAYS_ON { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_PARENT_BASED_TRACEID_RATIO
(experimental) Parent-based trace ID ratio sampling.
public static string OTEL_TRACES_SAMPLER_PARENT_BASED_TRACEID_RATIO { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_TRACEID_RATIO
(experimental) Trace ID ratio based sampling.
public static string OTEL_TRACES_SAMPLER_TRACEID_RATIO { get; }
Property Value
Remarks
Stability: Experimental
OTEL_TRACES_SAMPLER_XRAY
(experimental) X-Ray sampling strategy.
public static string OTEL_TRACES_SAMPLER_XRAY { get; }
Property Value
Remarks
Stability: Experimental