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

[chore] move dockerstats receiver's objects to package internal/docker/receiver #33038

Conversation

aboguszewski-sumo
Copy link
Member

Description: Functions and structs that could be reused have been moved to a separate package in order to be able to deprecate this receiver.
For reasons and arguments to do so, please see #32023 (comment)
Does it need a changelog entry? IMO not, it's not a change in the collector's config/api.
cc @andrzej-stencel

Link to tracking Issue: #31597

Testing: old tests, moved

Documentation: old documentation, moved or regenerated

@aboguszewski-sumo aboguszewski-sumo requested review from a team and fatsheep9146 May 14, 2024 11:58
@aboguszewski-sumo aboguszewski-sumo force-pushed the docker-stats-move-to-internal branch from 5989d24 to 332b579 Compare May 14, 2024 13:12
@github-actions github-actions bot added the cmd/otelcontribcol otelcontribcol command label May 14, 2024
@andrzej-stencel andrzej-stencel added the Skip Changelog PRs that do not require a CHANGELOG.md entry label May 15, 2024
@andrzej-stencel andrzej-stencel changed the title chore: move dockerstats receiver's objects to package internal/docker/receiver [chore] move dockerstats receiver's objects to package internal/docker/receiver May 15, 2024
@aboguszewski-sumo
Copy link
Member Author

bump @andrzej-stencel

@aboguszewski-sumo aboguszewski-sumo force-pushed the docker-stats-move-to-internal branch from 53c647e to 95e6c9a Compare May 21, 2024 07:50
@aboguszewski-sumo
Copy link
Member Author

I tried to investigate the failing checks, same thing happens here: https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/9086234384/job/24971438739?pr=33059

@aboguszewski-sumo aboguszewski-sumo force-pushed the docker-stats-move-to-internal branch from 95e6c9a to 17eb6a0 Compare May 22, 2024 13:02
Copy link
Contributor

@MovieStoreGuy MovieStoreGuy left a comment

Choose a reason for hiding this comment

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

The scope of changes is far too high to be done within one PR.

I would suggest split the PR into at least two:

  • Updated internal package with shared functionality
  • Removing duplicated functionality

@aboguszewski-sumo
Copy link
Member Author

While I partially agree, I'd like to make it clear whether this is the way it should be done, as purely transform dockerstats receiver into docker receiver is already taking a lot of time and there are some more changes I'd like to add.
WDYT @andrzej-stencel?

@andrzej-stencel
Copy link
Member

I'm not sure if I understand correctly what @MovieStoreGuy is proposing. Is it to first duplicate the code from Docker Stats receiver into a common package (that would not be used anywhere?) and then separately remove the duplicated code from Docker Stats receiver, starting to use the common package?

If my understanding is correct, I'm not sure if this would make review easier for me. But if that would make reviewing easier for @MovieStoreGuy then it's probably the way to go.

@aboguszewski-sumo
Copy link
Member Author

pinging @MovieStoreGuy, could you clarify here?

Copy link
Contributor

@jamesmoessis jamesmoessis left a comment

Choose a reason for hiding this comment

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

Looks OK, it definitely is a big change and is breaking so it's not super ideal, though I'm happy to move it along in the interest of getting things done

I also don't think you can be marking things like this as [chore] since it has actual code changes and even user facing changes to the output of the metrics.

@@ -3946,7 +3946,7 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) {
rm := pmetric.NewResourceMetrics()
rm.SetSchemaUrl(conventions.SchemaURL)
ils := rm.ScopeMetrics().AppendEmpty()
ils.Scope().SetName("otelcol/dockerstatsreceiver")
ils.Scope().SetName("otelcol/docker/receiver")
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 technically a breaking change, and should be at least mentioned in the changelog.

@@ -35,24 +37,24 @@ type resultV2 struct {
err error
}

type metricsReceiver struct {
config *Config
type MetricsReceiver struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure how I feel about making all of these types and methods public. Is there an alternative to this?

For example, I can create the OTLP exporter with fairly minimal exposure to the public API.

t, err := otlphttpexporter.NewFactory().CreateTracesExporter(
		ctx,
		exporter.CreateSettings{
			ID:                component.NewID(component.MustNewType("mock_app_otlp_exporter")),
			TelemetrySettings: componenttest.NewNopTelemetrySettings(),
			BuildInfo:         component.NewDefaultBuildInfo(),
		},
		&otlphttpexporter.Config{
			ClientConfig: clientCfg,
			Encoding:     otlphttpexporter.EncodingProto,
		},
	)

Is there a way we could arrange this in a more effective way?

Copy link
Member Author

Choose a reason for hiding this comment

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

I got an impression that this was necessary, but maybe this autoresolved at some point. Nevertheless, the PR is probably going to be split into smaller ones, so I will keep in mind your suggestion.

@MovieStoreGuy
Copy link
Contributor

While I partially agree, I'd like to make it clear whether this is the way it should be done, as purely transform dockerstats receiver into docker receiver is already taking a lot of time and there are some more changes I'd like to add. WDYT @andrzej-stencel?

The process is slow because the amount of change is significantly high. If this was broken up in smaller PRs and incrementally moving packages and functionality then I could get behind it but as it stands this is ~11,000 additions.
It is too easy for something to go amiss or overlooked with this.

Is it to first duplicate the code from Docker Stats receiver into a common package (that would not be used anywhere?) and then separately remove the duplicated code from Docker Stats receiver, starting to use the common package?

It needs to be smaller and not a big bang, I don't mind how it is done but there needs to be more of a plan and reassurance that what is currently given.

My suggestion was to move the required code into a shared package so we can at least reduce the change set and effectively review what is happening, then once that is merged the new package can be adopt and old code and functionality can be removed.

In short, make the PRs smaller and easier to review and I'll be happy to review and approve as appropriate.

@aboguszewski-sumo
Copy link
Member Author

aboguszewski-sumo commented Jun 12, 2024

There aren't many ways to break it into smaller chunks I can think of. One main problem is that there are many functions that use code generated by mdatagen. So, the only reasonable solution I have thought of is the following:

  • edit: Zeroth PR (optional, imo can be merged with first one): prepare empty docker/receiver package
  • First PR: move only internal/metadata package
  • Second PR: move config
  • Third PR: move metrics collecting logic
  • Fourth PR: cleanup

Where maybe (second and third) or (third and fourth) can be merged into one.
cc @andrzej-stencel

@jamesmoessis
Copy link
Contributor

@aboguszewski-sumo I have a question about the overall approach taken with the new docker events/logs gathering.

Why is the focus on moving docker stats receiver before creating the actual events receiver? I would've thought you create the dockerreceiver or dockereventsreceiver and then optionally move the metrics to it later. In my mind the question remains whether the metrics + events/logs need to be in the same component anyway, might it make sense to keep them separate? You might have more success more quickly if you weren't trying to make big changes to existing used components/code.

@aboguszewski-sumo
Copy link
Member Author

@jamesmoessis This was something agreed quite early on: #31597 (comment)
While from time perspective I agree that your suggestion sounds better, initially this seemed like a better idea and I believe that @andrzej-stencel raised this on a SIG meeting.

In my mind the question remains whether the metrics + events/logs need to be in the same component anyway, might it make sense to keep them separate?

I believe this was asked on SIG meeting on March 6th, again Andrzej might elaborate.

From my perspective, it could be a pain to try to merge the receivers later on, as they could already have some differences in code structure. And again, we would be copying a lot of code, so there would be the same problem as in this PR. I already have a PoC of the events receiver so it is only a matter of adapting it to the final receiver that will be used.

@jamesmoessis
Copy link
Contributor

Fair enough, I am just exploring possibilities for making it easier for you to get the new features you want faster.

@aboguszewski-sumo
Copy link
Member Author

I am closing this PR as it's going to be superseded by other ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal/docker receiver/dockerstats Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants