generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 237
Add health check extension for liveness & readiness probes #1779
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
Merged
HussainRaza28
merged 11 commits into
feature-health-observability-addon-update
from
health_check_extension
Aug 6, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
36c8164
Add health check extension for liveness & readiness probes
HussainRaza28 0b89b7b
Add health check extension for liveness & readiness probes
HussainRaza28 a2b3b46
Add health check extension for liveness & readiness probes
HussainRaza28 f418b61
add health_check changes on tocwconfig_test.go
HussainRaza28 0f82478
remove .yaml file changes
HussainRaza28 ee4eb0c
Reorganize healthcheck extension into proper folder structure
HussainRaza28 2411e2c
Reorganize healthcheck extension into proper folder structure
HussainRaza28 ab2ffec
Fix the correct import path for healthcheck translator
HussainRaza28 77a9c61
Add healthcheck extension for kubernetes environments
HussainRaza28 805faf8
Kubernetes fix for test file
HussainRaza28 f4d3972
Update health check extension approach in tests
HussainRaza28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
translator/translate/otel/extension/healthcheck/translator.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package healthcheck | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/confmap" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common" | ||
) | ||
|
||
type healthCheckTranslator struct { | ||
name string | ||
} | ||
|
||
var _ common.Translator[component.Config, component.ID] = (*healthCheckTranslator)(nil) | ||
|
||
func NewHealthCheckTranslator() common.Translator[component.Config, component.ID] { | ||
return &healthCheckTranslator{name: "health_check"} | ||
} | ||
|
||
func (t *healthCheckTranslator) ID() component.ID { | ||
return component.NewIDWithName(component.MustNewType("health_check"), t.name) | ||
} | ||
|
||
func (t *healthCheckTranslator) Translate(_ *confmap.Conf) (component.Config, error) { | ||
cfg := &struct { | ||
Endpoint string `mapstructure:"endpoint"` | ||
Path string `mapstructure:"path"` | ||
}{ | ||
Endpoint: "0.0.0.0:13133", | ||
Path: "/", | ||
} | ||
|
||
return cfg, nil | ||
} |
29 changes: 29 additions & 0 deletions
29
translator/translate/otel/extension/healthcheck/translator_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package healthcheck | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.opentelemetry.io/collector/confmap" | ||
) | ||
|
||
func TestHealthCheckTranslator(t *testing.T) { | ||
translator := NewHealthCheckTranslator() | ||
assert.Equal(t, "health_check", translator.ID().Type().String()) | ||
|
||
conf := confmap.New() | ||
cfg, err := translator.Translate(conf) | ||
assert.NoError(t, err) | ||
|
||
// Assert the config has the expected fields | ||
healthCheckCfg, ok := cfg.(*struct { | ||
Endpoint string `mapstructure:"endpoint"` | ||
Path string `mapstructure:"path"` | ||
}) | ||
assert.True(t, ok) | ||
assert.Equal(t, "0.0.0.0:13133", healthCheckCfg.Endpoint) | ||
assert.Equal(t, "/", healthCheckCfg.Path) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would add
pipelines.Translators.Extensions.Set(healthcheckextension.NewHealthCheckTranslator())
under here since we only need the healthcheck extension for Kubernetes environments, not just when the agent is in a container.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.
That makes sense. I moved it under the Kubernetes mode check since we only need the health check extension for Kubernetes environments.