Class InstrumentationProps
(experimental) Interface for instrumentation properties.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.ApplicationSignals.Alpha
Assembly: Amazon.CDK.AWS.ApplicationSignals.Alpha.dll
Syntax (csharp)
public class InstrumentationProps : IInstrumentationProps
Syntax (vb)
Public Class InstrumentationProps Implements IInstrumentationProps
Remarks
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;
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 });
// Define Task Definition for CloudWatch agent (Daemon)
var cwAgentTaskDefinition = new Ec2TaskDefinition(this, "CloudWatchAgentTaskDefinition", new Ec2TaskDefinitionProps {
NetworkMode = NetworkMode.HOST
});
new CloudWatchAgentIntegration(this, "CloudWatchAgentIntegration", new CloudWatchAgentIntegrationProps {
TaskDefinition = cwAgentTaskDefinition,
ContainerName = "ecs-cwagent",
EnableLogging = false,
Cpu = 128,
MemoryLimitMiB = 64,
PortMappings = new [] { new PortMapping {
ContainerPort = 4316,
HostPort = 4316
}, new PortMapping {
ContainerPort = 2000,
HostPort = 2000
} }
});
// Create the CloudWatch Agent daemon service
// Create the CloudWatch Agent daemon service
new Ec2Service(this, "CloudWatchAgentDaemon", new Ec2ServiceProps {
Cluster = cluster,
TaskDefinition = cwAgentTaskDefinition,
Daemon = true
});
// Define Task Definition for user application
var sampleAppTaskDefinition = new Ec2TaskDefinition(this, "SampleAppTaskDefinition", new Ec2TaskDefinitionProps {
NetworkMode = NetworkMode.HOST
});
sampleAppTaskDefinition.AddContainer("app", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("test/sample-app"),
Cpu = 0,
MemoryLimitMiB = 512
});
// No CloudWatch Agent side car is needed as application container communicates to CloudWatch Agent daemon through host network
// No CloudWatch Agent side car is needed as application container communicates to CloudWatch Agent daemon through host network
new ApplicationSignalsIntegration(this, "ApplicationSignalsIntegration", new ApplicationSignalsIntegrationProps {
TaskDefinition = sampleAppTaskDefinition,
Instrumentation = new InstrumentationProps {
SdkVersion = PythonInstrumentationVersion.V0_8_0
},
ServiceName = "sample-app"
});
new Ec2Service(this, "MySampleApp", new Ec2ServiceProps {
Cluster = cluster,
TaskDefinition = sampleAppTaskDefinition,
DesiredCount = 1
});
}
}
Synopsis
Constructors
InstrumentationProps() | (experimental) Interface for instrumentation properties. |
Properties
RuntimePlatform | (experimental) The runtime platform of the instrumentation. |
SdkVersion | (experimental) The version of the instrumentation. |
Constructors
InstrumentationProps()
(experimental) Interface for instrumentation properties.
public InstrumentationProps()
Remarks
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;
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 });
// Define Task Definition for CloudWatch agent (Daemon)
var cwAgentTaskDefinition = new Ec2TaskDefinition(this, "CloudWatchAgentTaskDefinition", new Ec2TaskDefinitionProps {
NetworkMode = NetworkMode.HOST
});
new CloudWatchAgentIntegration(this, "CloudWatchAgentIntegration", new CloudWatchAgentIntegrationProps {
TaskDefinition = cwAgentTaskDefinition,
ContainerName = "ecs-cwagent",
EnableLogging = false,
Cpu = 128,
MemoryLimitMiB = 64,
PortMappings = new [] { new PortMapping {
ContainerPort = 4316,
HostPort = 4316
}, new PortMapping {
ContainerPort = 2000,
HostPort = 2000
} }
});
// Create the CloudWatch Agent daemon service
// Create the CloudWatch Agent daemon service
new Ec2Service(this, "CloudWatchAgentDaemon", new Ec2ServiceProps {
Cluster = cluster,
TaskDefinition = cwAgentTaskDefinition,
Daemon = true
});
// Define Task Definition for user application
var sampleAppTaskDefinition = new Ec2TaskDefinition(this, "SampleAppTaskDefinition", new Ec2TaskDefinitionProps {
NetworkMode = NetworkMode.HOST
});
sampleAppTaskDefinition.AddContainer("app", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("test/sample-app"),
Cpu = 0,
MemoryLimitMiB = 512
});
// No CloudWatch Agent side car is needed as application container communicates to CloudWatch Agent daemon through host network
// No CloudWatch Agent side car is needed as application container communicates to CloudWatch Agent daemon through host network
new ApplicationSignalsIntegration(this, "ApplicationSignalsIntegration", new ApplicationSignalsIntegrationProps {
TaskDefinition = sampleAppTaskDefinition,
Instrumentation = new InstrumentationProps {
SdkVersion = PythonInstrumentationVersion.V0_8_0
},
ServiceName = "sample-app"
});
new Ec2Service(this, "MySampleApp", new Ec2ServiceProps {
Cluster = cluster,
TaskDefinition = sampleAppTaskDefinition,
DesiredCount = 1
});
}
}
Properties
RuntimePlatform
(experimental) The runtime platform of the instrumentation.
public IRuntimePlatform? RuntimePlatform { get; set; }
Property Value
Remarks
Default: - the runtime platform specified through the input TaskDefinition.
Stability: Experimental
SdkVersion
(experimental) The version of the instrumentation.
public InstrumentationVersion SdkVersion { get; set; }
Property Value
Remarks
Stability: Experimental