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

Support global and per endpoint / backend static attributes in all layers #20

Closed
wants to merge 5 commits into from

Conversation

ssepml
Copy link
Contributor

@ssepml ssepml commented Apr 29, 2024

Description

This PR adds support for:

  • Global static attributes for global and proxy layers
  • Set per endpoint / backend static attributes. These will be merged with the globally provided ones if any

Use Case

The main idea is to provide allow for better grouping when creating dashboards with the metrics.

Approach

Two new fields were added to the global and proxy layers

  • metrics_static_attributes
  • traces_static_attributes

The reason for this option was that the configuration on these two layers was already flat (as opposed to the backend layer which has a metrics and traces section) , hence this keeps the convention already set. Also, changing to something like the backend layer could lead to some breaking changes.

NOTE: I don't have strong opinions on this format and I'm willing to adapt the PR to your preferred way to pass the configuration

Also, configuration provided in an endpoint of backend section will now be parsed to get static labels which will be merged with any other label provided at the top level of the configuration. All other configuration parameters provided will be ignored.

@ssepml ssepml force-pushed the static-labels branch 2 times, most recently from 9116c1f to a7e6a88 Compare April 29, 2024 07:05
Copy link
Contributor

@dhontecillas dhontecillas left a comment

Choose a reason for hiding this comment

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

I took your PR as base and put it into this other branch: #27 .

I would like to make a PR to your branch, so you could review it, and then merge this PR. But since I merged your PR in the main repo (I guess I made a little mess), I don't know how to do it. So, would you mind reviewing that one ?

Luckily it maintains you as an author of the commits (I did not want to take credit for your work, just tried to test it in existing code bases)

Another way would be ... to .. merge that branch into yours ?

Sorry for the mess.

And thank you very much for your contribution.

Comment on lines +14 to +15
EndpointPipeOpts(cfg *luraconfig.EndpointConfig) config.PipeOpts
EndpointBackendOpts(cfg *luraconfig.Backend) config.BackendOpts
Copy link
Contributor

Choose a reason for hiding this comment

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

the change of the signature from *config.PipeOpts to config.PipeOpts is a breaking backwards compat change, and should be avoided.

}

func mergedBackendOpts(s *StateConfig, cfg *luraconfig.Backend) config.BackendOpts {
BackendOpts := *s.cfgData.Layers.Backend
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say variables should not start with a capital character.

return mergedBackendOpts(s, cfg)
}

func mergedBackendOpts(s *StateConfig, cfg *luraconfig.Backend) config.BackendOpts {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say this function could be a "member" of s , and be:
func (s *StateConfig) mergedBackendOpts(cfg *luraconfig.Backend) *config.BackendOpts {


// LuraExtraCfg extracts the extra config field for the namespace if
// provided
func LuraExtraCfg(extraCfg luraconfig.ExtraConfig) (*ConfigData, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this makes the code more readable ! 👍

go build -o srv ./server
.PHONY: build
.PHONY: srv
Copy link
Contributor

Choose a reason for hiding this comment

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

i think, we can remove the .PHONY line if we actually generate a file with the target name.

@ssepml
Copy link
Contributor Author

ssepml commented May 17, 2024

@dhontecillas thanks for the comments. I reviewed the other PR you created, all looks good to me.

Luckily it maintains you as an author of the commits (I did not want to take credit for your work, just tried to test it in existing code bases)

Don't worry about that :), I don't really mind which PR gets merged and given that your PR addresses all the comments already, feel free to continue with that one.

@dhontecillas
Copy link
Contributor

@ssepml then I will merge the other one directly.

Once again, thank you very much for your contribution.

This PR is merged into: #27

@ssepml ssepml deleted the static-labels branch May 27, 2024 06:16
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.

2 participants