github.com/mier85/go-sensor@v1.30.1-0.20220920111756-9bf41b3bc7e0/acceptor/aws.go (about)

     1  // (c) Copyright IBM Corp. 2021
     2  // (c) Copyright Instana Inc. 2020
     3  
     4  package acceptor
     5  
     6  import "time"
     7  
     8  // AWSContainerLimits is used to send container limits (CPU, memory) to the acceptor plugin
     9  type AWSContainerLimits struct {
    10  	CPU    int `json:"cpu"`
    11  	Memory int `json:"memory"`
    12  }
    13  
    14  // ECSTaskData is a representation of an ECS task for com.instana.plugin.aws.ecs.task plugin
    15  type ECSTaskData struct {
    16  	TaskARN               string                 `json:"taskArn"`
    17  	ClusterARN            string                 `json:"clusterArn"`
    18  	AvailabilityZone      string                 `json:"availabilityZone,omitempty"`
    19  	InstanaZone           string                 `json:"instanaZone,omitempty"`
    20  	TaskDefinition        string                 `json:"taskDefinition"`
    21  	TaskDefinitionVersion string                 `json:"taskDefinitionVersion"`
    22  	DesiredStatus         string                 `json:"desiredStatus"`
    23  	KnownStatus           string                 `json:"knownStatus"`
    24  	Limits                AWSContainerLimits     `json:"limits"`
    25  	PullStartedAt         time.Time              `json:"pullStartedAt"`
    26  	PullStoppedAt         time.Time              `json:"pullStoppedAt"`
    27  	Tags                  map[string]interface{} `json:"tags,omitempty"`
    28  }
    29  
    30  // NewECSTaskPluginPayload returns payload for the ECS task plugin of Instana acceptor
    31  func NewECSTaskPluginPayload(entityID string, data ECSTaskData) PluginPayload {
    32  	const pluginName = "com.instana.plugin.aws.ecs.task"
    33  
    34  	return PluginPayload{
    35  		Name:     pluginName,
    36  		EntityID: entityID,
    37  		Data:     data,
    38  	}
    39  }
    40  
    41  // ECSContainerData is a representation of an ECS container for com.instana.plugin.aws.ecs.container plugin
    42  type ECSContainerData struct {
    43  	Runtime               string             `json:"runtime"`
    44  	Instrumented          bool               `json:"instrumented,omitempty"`
    45  	DockerID              string             `json:"dockerId"`
    46  	DockerName            string             `json:"dockerName"`
    47  	ContainerName         string             `json:"containerName"`
    48  	Image                 string             `json:"image"`
    49  	ImageID               string             `json:"imageId"`
    50  	TaskARN               string             `json:"taskArn"`
    51  	TaskDefinition        string             `json:"taskDefinition"`
    52  	TaskDefinitionVersion string             `json:"taskDefinitionVersion"`
    53  	ClusterARN            string             `json:"clusterArn"`
    54  	DesiredStatus         string             `json:"desiredStatus"`
    55  	KnownStatus           string             `json:"knownStatus"`
    56  	Limits                AWSContainerLimits `json:"limits"`
    57  	CreatedAt             time.Time          `json:"createdAt"`
    58  	StartedAt             time.Time          `json:"startedAt"`
    59  	Type                  string             `json:"type"`
    60  }
    61  
    62  // NewECSContainerPluginPayload returns payload for the ECS container plugin of Instana acceptor
    63  func NewECSContainerPluginPayload(entityID string, data ECSContainerData) PluginPayload {
    64  	const pluginName = "com.instana.plugin.aws.ecs.container"
    65  
    66  	return PluginPayload{
    67  		Name:     pluginName,
    68  		EntityID: entityID,
    69  		Data:     data,
    70  	}
    71  }
    72  
    73  // NewAWSLambdaPluginPayload returns payload for the AWS Lambda plugin of Instana acceptor
    74  func NewAWSLambdaPluginPayload(entityID string) PluginPayload {
    75  	const pluginName = "com.instana.plugin.aws.lambda"
    76  
    77  	return PluginPayload{
    78  		Name:     pluginName,
    79  		EntityID: entityID,
    80  	}
    81  }