-
Notifications
You must be signed in to change notification settings - Fork 376
[Resources.Aws] Get ECS container ID on Windows #4028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,6 +108,16 @@ internal void ExtractMetadataV4ResourceAttributes(AWSSemanticConventions.Attribu | |
| using var containerResponse = JsonDocument.Parse(metadataV4ContainerResponse); | ||
| using var taskResponse = JsonDocument.Parse(metadataV4TaskResponse); | ||
|
|
||
| // On Linux the container ID is obtained from a file which does not exist on Windows. | ||
| // The ECS Metadata V4 container endpoint always carries the same ID in the "DockerId" field. | ||
| // See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v4-response.html. | ||
| if (OperatingSystem.IsWindows() && | ||
| containerResponse.RootElement.TryGetProperty("DockerId", out var dockerIdElement) && | ||
| dockerIdElement.GetString() is string { Length: > 0 } dockerId) | ||
| { | ||
| resourceAttributes.AddAttributeContainerId(dockerId); | ||
| } | ||
|
Comment on lines
+111
to
+119
|
||
|
|
||
| if (!containerResponse.RootElement.TryGetProperty("ContainerARN", out var containerArnElement) | ||
| || containerArnElement.GetString() is not string containerArn) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was intentionally conservative here to not change the existing behaviour for Linux.