-
Notifications
You must be signed in to change notification settings - Fork 38
opentelemetry-operations-collector repo rewrite #246
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
Conversation
cd1bfd6 to
c3753a0
Compare
|
Interesting, do we need to make relevant kokoro config changes to make it work with this change? |
|
I think we should just get rid of that Kokoro setup, it is utterly unnecessary and has been for years. |
|
Looks solid, nice! |
LujieDuan
left a comment
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.
Nice work! Couple of small suggestions:
ridwanmsharif
left a comment
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.
note: I only reviewed distrogen. Most of my comments are noits and not blocking. Once responded to or addressed, I'll do another quick pass but things look pretty good now
| "github.com/google/go-cmp/cmp" | ||
| ) | ||
|
|
||
| var ErrNoDiff = errors.New("no differences found with previous generation") |
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.
Does this have to be exported?
|
|
||
| RUN_DISTROGEN=go run ./cmd/distrogen | ||
|
|
||
| GEN_GOOGLE_OTEL=$(RUN_DISTROGEN) -registry ./registries/operations-collector-registry.yaml -spec ./specs/google-otel.yaml -custom_templates ./templates/google-otel |
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.
These are really cool make targets. Could you add a README.md in the distrogen tool with some instructions on what we expect each of these yaml files to contain?
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.
Will do, but need a bit more time to write something nice.
cmd/distrogen/yaml.go
Outdated
| var result T | ||
| err = yaml.Unmarshal(content, &result) | ||
| if err != nil { | ||
| return nil, wrapYamlErr(err, path) |
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.
| return nil, wrapYamlErr(err, path) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to unmarshal file %s something: %w", path, originalErr) | |
| } | |
| return &result, nil |
Why not just this? I don't see wrapYamlErr used anywhere else.
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.
brain must have been turned off when I wrote this cause yeah idk why I did that. Fixed in 79e8314
| return generateDistribution() | ||
| } | ||
|
|
||
| func generateSpec() error { |
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.
Neat idea. We don't have to recommend or document this option yet but I'm not sure if this is how I want to recommend folks build their GBOT spec. I imagine folks want a collector for a bunch of different configs/use cases and we don't want folks to build a different spec for each one. It is certainly a useful tool to find a minimal spec but this could confuse some people too.
Also, it doesn't do enough right? If my config uses an invalid receiver, or uses a forked component, I still would need to provide a registry.yaml file for it?
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.
This feature is definitely half-baked. I forgot it was even here in the primary branch. I did it as a mockup for someone at KubeCon. I am okay with straight up removing the feature for now cause it's half-baked.
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.
Yeah might be simpler to just remove for now
| if !ok { | ||
| return nil, fmt.Errorf("reading section %s: invalid section data", sectionName) | ||
| } | ||
| return mapKeys(section), nil |
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.
This is not entirely right is it? You can have receivers with the name prometheus/self-metrics and prometheus/app both referring to the same underlying receiver but the receiver is just prometheus.
cmd/distrogen/registry.go
Outdated
|
|
||
| // LoadAll will take a list of component names and load them | ||
| // from the registry, attaching the appropriate version tag. | ||
| func (rl RegistryList) LoadAll(names []string, version string, stableVersion string, contribVersion string) (RegistryComponents, RegistryLoadError) { |
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.
[nit] Load here is used in a different context than how its used when we called LoadRegistry. Lets fix one of the naming to something else
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.
Load is such an equally good word for both things that I struggled to come up with something. Proposed something in 7442ce8
|
|
||
| // RegistryComponents is a map of registry component names to component | ||
| // details. | ||
| type RegistryComponents map[string]*RegistryComponent |
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.
type RegistryList map[string]*RegistryComponent
Isn't this component effectively the same from one in line 70?
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.
Yeah you're right, I didn't notice these types converge when I refactored a bunch of registry stuff. Removed and consolidated the methods in 79e8314
cmd/distrogen/distribution.go
Outdated
|
|
||
| errs := make(RegistryLoadError) | ||
| var err RegistryLoadError | ||
| context.Receivers, err = registry.Receivers.LoadAll(spec.Components.Receivers, spec.OpenTelemetryVersion, spec.OpenTelemetryStableVersion, spec.OpenTelemetryContribVersion) |
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.
This translation from the RegistryList to RegistryComponents is confusing. They are the same no?
Seems like all this is doing is some cleanup of the gomod entry
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.
In registry, the full list of all components exists. The context will only contain the actual configured components from the spec. Now that the type names are the same this is more confusing, not sure if this can either be done differently or if I should just add a comment clarifying.
| return generateDistribution() | ||
| } | ||
|
|
||
| func generateSpec() error { |
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.
Yeah might be simpler to just remove for now
cmd/distrogen/registry.go
Outdated
| errs := make(RegistryLoadError) | ||
|
|
||
| for _, name := range names { | ||
| entry, err := rl.LoadComponent(name) |
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.
[nit] This is just a map lookup now, we can inline this when its called and get rid of this method.
| entry, err := rl.LoadComponent(name) | |
| entry, ok := rl[name] | |
| if !ok { | |
| errs[name] = ErrComponentNotFound | |
| continue | |
| } |
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 ended up refactoring this slightly in 055331f
The method is still there but it does things in a different order that makes more sense
cmd/distrogen/registry.go
Outdated
| } | ||
|
|
||
| // LoadComponent will load a component from the registry. | ||
| func (rl RegistryComponents) LoadComponent(name string) (*RegistryComponent, error) { |
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.
We don't need this I don't think, see other comment
ridwanmsharif
left a comment
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.
my comments don't block a merge fwiw. Feel free to resolve and address the rest
all distrogen changes LGTM. Lets get this in 🚀🚀🚀
LujieDuan
left a comment
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.
Reviewed other changes and LGTM! 🚀
This PR is a rewrite of the opentelemetry-operations-collector repo to the new version from the `google-otel-poc` branch. The new version has: * A tool called `distrogen` for generations and managing collector distributions * The original otelopscol binary buildable with ocb * The new Google-Built OpenTelemetry Collector * All the same original components as the original repo, modularized for use with OCB * An in-depth Makefile and developer tooling to make updating OTel versions for components as seamless as possible
59043c8 to
65c09be
Compare
|
FYI: I updated the branch protection rules on this repo so the Kokoro presubmits are non-blocking for merge to master. |
This PR is a rewrite of the opentelemetry-operations-collector repo to the new version from the
google-otel-pocbranch. The new version has:distrogenfor generation and management of collector distributions