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

Added Elastic Beanstalk Resource detector #1585

Merged
merged 4 commits into from
Nov 20, 2020

Conversation

willarmiros
Copy link
Contributor

Description:
Enhancement - adds new resource detector for AWS Elastic Beanstalk environments. It reads a file provided on all EB instances with X-Ray enabled and records the metadata it contains.

Testing:
Tested on live app and added unit tests.

Documentation:
Updated docs to match other resource detectors.

@codecov
Copy link

codecov bot commented Nov 13, 2020

Codecov Report

Merging #1585 (32b53b6) into master (8109852) will decrease coverage by 0.00%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1585      +/-   ##
==========================================
- Coverage   89.24%   89.24%   -0.01%     
==========================================
  Files         354      356       +2     
  Lines       17417    17441      +24     
==========================================
+ Hits        15544    15565      +21     
- Misses       1395     1399       +4     
+ Partials      478      477       -1     
Flag Coverage Δ
integration 71.00% <ø> (ø)
unit 87.88% <93.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...resourcedetectionprocessor/internal/aws/ecs/ecs.go 85.24% <ø> (-0.24%) ⬇️
...sor/internal/aws/elasticbeanstalk/filesystem_eb.go 0.00% <0.00%> (ø)
processor/resourcedetectionprocessor/factory.go 98.68% <100.00%> (+0.01%) ⬆️
.../internal/aws/elasticbeanstalk/elasticbeanstalk.go 100.00% <100.00%> (ø)
receiver/prometheusexecreceiver/receiver.go 85.83% <0.00%> (-2.50%) ⬇️
receiver/k8sclusterreceiver/watcher.go 97.64% <0.00%> (+2.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8109852...32b53b6. Read the comment docs.

## Configuration

```yaml
# a list of resource detectors to run, valid options are: "env", "system", "gce", "ec2", "ecs"
# a list of resource detectors to run, valid options are: "env", "system", "gce", "ec2", "ecs", "elasticBeanstalk"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: for component identifiers (e.g. processor/k8s_tagger) we do underscores instead of camel case so maybe better to do elastic_beanstalk?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will rename


ebmd := &EbMetaData{}
err = json.NewDecoder(conf).Decode(ebmd)
defer conf.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

Would either put the defer right after the err checking or since it looks like you're done reading the file here just conf.Close() with no defer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch don't think a defer is necessary, this was just a bit too mindless of a copy-paste from an online example.

}

if err != nil {
log.Println("Unable to find Elastic Beanstalk config file, skipping resource detection")
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 be using log package but the zap logger passed into the component (looks like ecs is using log too which it shouldn't have). We're not passing log instances into detectors right now so will require some refactoring to add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I noticed there's no Zap object passed in which is why I fell back to log, but in retrospect I probably should have just done nothing. I can remove the logging statements from this PR, and take a look at the refactor to pass in the zap logger in a separate PR.

@willarmiros
Copy link
Contributor Author

@jrcamp sorry for the delay, but I addressed your comments and removed the logging. Also opened #1645 to bring zap into these detector components.

@bogdandrutu bogdandrutu merged commit 51555af into open-telemetry:master Nov 20, 2020
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.

3 participants