Skip to content
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

Implement AppSignals on EKS and native EC2 #929

Merged
merged 46 commits into from
Nov 2, 2023
Merged

Conversation

lisguo
Copy link
Contributor

@lisguo lisguo commented Oct 25, 2023

Description of the issue

This is the implementation for app signals within the cloudwatch agent. Includes config translation of opentelemetry components to enable collection of Latency, Error, and Fault metrics (through emf) and traces.

Description of changes

  • New awsappsignals processor
  • Translation of app_signals under logs.metrics_collected and traces.traces_collected
  • Creates otel pipeline with the otlp receiver -> resourcedetection, awsappsignals processor -> emfexporter / xrayexporter

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Created a dev build and tested on EKS and EC2.

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

JayPolanco and others added 30 commits September 28, 2023 16:56
Co-authored-by: Lisa Guo <[email protected]>
Co-authored-by: Ping Xiang <[email protected]>
Co-authored-by: nanzhenAWS <[email protected]>
Co-authored-by: Lisa Guo <[email protected]>
Co-authored-by: Lisa Guo <[email protected]>
Co-authored-by: Harry <[email protected]>
Co-authored-by: Hyunsoo Kim <[email protected]>
@lisguo lisguo requested a review from a team as a code owner October 25, 2023 21:31
mxiamxia
mxiamxia previously approved these changes Oct 25, 2023
Copy link
Contributor

@mxiamxia mxiamxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@codecov-commenter
Copy link

codecov-commenter commented Oct 26, 2023

Codecov Report

Attention: 42 lines in your changes are missing coverage. Please review.

Comparison is base (96d4763) 57.58% compared to head (9c0de4c) 62.40%.
Report is 444 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #929      +/-   ##
==========================================
+ Coverage   57.58%   62.40%   +4.81%     
==========================================
  Files         370      357      -13     
  Lines       17548    18278     +730     
==========================================
+ Hits        10105    11406    +1301     
+ Misses       6848     6296     -552     
+ Partials      595      576      -19     
Files Coverage Δ
cfg/commonconfig/commonconfig.go 8.00% <ø> (ø)
...md/amazon-cloudwatch-agent-config-wizard/wizard.go 59.55% <ø> (-8.51%) ⬇️
...amazon-cloudwatch-agent/amazon-cloudwatch-agent.go 2.64% <ø> (ø)
...oudwatch-agent/register_event_logger_notwindows.go 0.00% <ø> (ø)
...-cloudwatch-agent/register_event_logger_windows.go 0.00% <ø> (ø)
cmd/config-translator/translator.go 0.00% <ø> (ø)
cmd/xray-migration/commands_unix.go 42.50% <ø> (ø)
cmd/xray-migration/commands_windows.go 42.50% <ø> (ø)
cmd/xray-migration/xray-migration.go 30.28% <ø> (ø)
handlers/agentinfo/info.go 83.00% <ø> (ø)
... and 13 more

... and 235 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lisguo lisguo requested a review from jefchien October 27, 2023 14:03
go.mod Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/README.md Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/README.md Outdated Show resolved Hide resolved
}

func (cfg *Config) Validate() error {
// TODO: validate those mandatory fields (if exist) in the config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still a TODO?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we try to compile the globs here so we don't wait until runtime to panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it's still a todo. @thpierce, will this be added later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have any mandatory fields. So this TODO can be removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation doesn't only check if any mandatory field is missing, it's also about whether the values customer set there are legal/valid. Is there any validation we want to put for the later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like mentioned above, could we validate the globs so if they're invalid they are discovered at translation time?

plugins/processors/awsappsignals/factory.go Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/internal/resolver/eks.go Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/internal/resolver/eks.go Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/processor.go Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/processor.go Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/processor.go Outdated Show resolved Hide resolved
plugins/processors/awsappsignals/processor.go Outdated Show resolved Hide resolved
Comment on lines +118 to +123
// Attributes are provided for each log and trace, but not at the metric level
// Need to process attributes for every data point within a metric.
func (ap *awsappsignalsprocessor) processMetricAttributes(ctx context.Context, m pmetric.Metric, resourceAttribes pcommon.Map) {

// This is a lot of repeated code, but since there is no single parent superclass
// between metric data types, we can't use polymorphism.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a single parent superclass, but you can still reduce the repeated code.

The functions within each RemoveIf are exactly the same. The metricsMutators for loop is exactly the same for each too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They look the same, but they don't. The datapoints are of different types.

Copy link
Contributor

@jefchien jefchien Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use interfaces/generics to get them to behave the same.

type DataPoints[T HasAttributes] interface {
    At(i int) T
    Len() int
}

type HasAttributes interface {
    Attributes() pcommon.Map
}

func getAttributes[T HasAttributes](dps DataPoints[T]) []pcommon.Map {
    var attributes []pcommon.Map
    for i := 0; i < dps.Len(); i++ {
       attributes = append(attributes, dps.At(i).Attributes())
    }
    return attributes
}

func Test(m pmetric.Metric) {
   switch m.Type() {
      case pmetric.MetricTypeGauge:
           getAttributes[pmetric.NumberDataPoint](m.Gauge().DataPoints())
   }
}

plugins/processors/awsappsignals/processor.go Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move plugins/processors/awsappsignals to processor/awsappsignals. plugins is a legacy directory for telegraf. Going forward, all new components should be top level like receiver/adapter and extension/agenthealth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I put this in plugins since I saw the other processors in there. If we do this then we should add the /processor directory to be unit tested

"app_signals": {
"type": "object",
"properties": {},
"additionalProperties": true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If this should always be empty, then consider setting additionalProperties to false, so the schema validation will fail. This way there's less confusion about the configuration.

@@ -4,6 +4,7 @@
package awsxray

import (
_ "embed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused.

@lisguo lisguo merged commit 38a4016 into aws:main Nov 2, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.