Skip to content

Docker Stats Receiver #495

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
merged 12 commits into from
Sep 3, 2020
Merged

Docker Stats Receiver #495

merged 12 commits into from
Sep 3, 2020

Conversation

rmfitzpatrick
Copy link
Contributor

Description: Adds a new docker_stats receiver that fetches container stats on a configured interval. Functionality is largely ported from the SignalFx Smart Agent docker container stats monitor: https://github.com/signalfx/signalfx-agent/blob/master/docs/monitors/docker-container-stats.md

Testing: Provides unit and integration tests.

Documentation: Readme section added.

@rmfitzpatrick rmfitzpatrick requested a review from a team July 23, 2020 17:31
@codecov
Copy link

codecov bot commented Jul 23, 2020

Codecov Report

Merging #495 into master will increase coverage by 0.30%.
The diff coverage is 96.34%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #495      +/-   ##
==========================================
+ Coverage   88.14%   88.45%   +0.30%     
==========================================
  Files         236      242       +6     
  Lines       12575    13040     +465     
==========================================
+ Hits        11084    11534     +450     
- Misses       1137     1147      +10     
- Partials      354      359       +5     
Flag Coverage Δ
#integration 74.88% <79.56%> (+3.59%) ⬆️
#unit 87.65% <78.92%> (-0.31%) ⬇️

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

Impacted Files Coverage Δ
receiver/dockerstatsreceiver/docker.go 90.97% <90.97%> (ø)
receiver/dockerstatsreceiver/receiver.go 97.01% <97.01%> (ø)
receiver/dockerstatsreceiver/metrics.go 98.39% <98.39%> (ø)
receiver/dockerstatsreceiver/config.go 100.00% <100.00%> (ø)
receiver/dockerstatsreceiver/factory.go 100.00% <100.00%> (ø)
receiver/dockerstatsreceiver/matcher.go 100.00% <100.00%> (ø)
... and 3 more

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 da67628...171ac79. Read the comment docs.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

It will be almost impossible for one of the maintainer to review 5000+ lines. Consider to split this PR into more readable PRs, as a rule of thumb 500 lines is considered a large PR

While in development consider to not add it to the components.go in the service.

@rmfitzpatrick
Copy link
Contributor Author

@bogdandrutu not to split hairs, but after removing an undesired metadata file and taking go.mod/sum out of the picture it's a more manageable ~3k lines, a lot of which is test data. Still a large PR, but it's a fairly major feature addition. Will break up into more reasonable commits for each component to help determine if separate PRs are necessary.

Common metric creation utils and validation helpers would dramatically cut back on the scope of additions as well. I plan on adding these in a future effort, unrelated to this feature.

@pmcollins
Copy link
Member

Ryan, in the interest of breaking this PR into smaller chunks, I'm wondering if there's a seam that we could find on which to split these changes. Like, if I understand correctly, this receiver has one part (A) that reads the current containers and listens for changes, and another part (B) that fetches container stats and converts them to metrics on a schedule. Is this an accurate assessment?

Would it be helpful to create a PR that just does A for now? And in support of that effort, would it be easier to handle the distinct functions (A and B) in separate classes?

@rmfitzpatrick
Copy link
Contributor Author

A) listens for container events from the docker daemon and maintains an internal store for containers that should be queried for stats. B) iterates over the internal store on an interval, fetches stats and converts them to metrics.

I think the simplest functional PR would consist of B, and a subsequent one would introduce the event handling. However, it's not clear to me that sacrificing the initial dynamic functionality would be worth the feature penalty.

Happy to break apart if it would make others' efforts easier overall though.

@pmcollins
Copy link
Member

Sounds good to me. Not sure how functional it has to be while in development though, at least not until the receiver is registered in components.go, but if it is functional, then I suppose that's more Agile. :-)

@rmfitzpatrick
Copy link
Contributor Author

@pmcollins I've taken out the dynamic container updates, but left some of the scaffolding it will use in the interest of not spending too much effort on things that will immediately be undone.

@pmcollins
Copy link
Member

Can you rebase?

@rmfitzpatrick
Copy link
Contributor Author

@pmcollins sorry, not sure why my changes didn't land earlier. (actually) Added the lock for container removal and adopted the new factory helpers.


// Queries inspect api and returns *ContainerJSON and true when container should be queried for stats,
// nil and false otherwise.
func (dc *DockerClient) inspectedContainerIsOfInterest(ctx context.Context, cid string) (*dtypes.ContainerJSON, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if inspectedContainerIsOfInterest, shouldBeExcluded and excludedImageMatcher should all go into a separate filter type/class.

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'm not sure I follow or agree atm. inspectedContainerIsOfInterest provides a critical docker client containerInspect call, which belongs in the core type imo. excludedImageMatcher is a StringMatcher, an already separate type, and the associated shouldBeExcluded provide a nil check only applicable to dockerClient.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, that makes sense. Is shouldBeExcluded needed though -- it looks like excludedImageMatcher can't be nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a pointer to a StringMatcher so it can be right, but isn't in practice thus far? I'm not sure of what is idiomatic but this seems like a straightforward nil check.

Copy link
Member

@pmcollins pmcollins left a comment

Choose a reason for hiding this comment

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

LGTM

@rmfitzpatrick
Copy link
Contributor Author

@jrcamp, @keitwb, @asuresh4, @bogdandrutu any chance you can take (another) look?

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

@rmfitzpatrick can you please add this to changelog.md?

@tigrannajaryan tigrannajaryan merged commit 34027d2 into open-telemetry:master Sep 3, 2020
@rmfitzpatrick
Copy link
Contributor Author

@rmfitzpatrick can you please add this to changelog.md?

Thanks, @tigrannajaryan, added in #917

dyladan referenced this pull request in dynatrace-oss-contrib/opentelemetry-collector-contrib Jan 29, 2021
The dependency was referring to non-existing version. This was
building fine in this repo because the dependency is replaced
but was causing problem in other repos which consume the testbed.
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
* Add zipkin exporter

The zipkin exporter implements the SpanBatcher interface. It follows
the current-at-the-time-of-writing document about conversion from
OpenTelemetry span data to Zipkin spans. Which means that endpoint
information is not yet filled.

* Fix typo in docs

* Add a zipkin example

This sends span information to a locally running zipkin collector.
Currently I have a problem getting the collector to show me the spans
after accepting them with HTTP 202. Not sure if this is because of
missing endpoint information.

* Make gitignore consistent

The fixed paths should be prefixed with a slash. The "relative" paths
mean that git will ignore all the files that end with the path.

* Add tests for zipkin exporter
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.

6 participants