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

[k159] Remove Prometheus dependency for push pkg #9956

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

grafanabot
Copy link
Collaborator

Backport 15af77b from #9937


What this PR does / why we need it:

In #9694, we modified the push pkg to import Prometheus as a dependency to use the labels.Labels type for the entries' non-indexed labels.

Having Prometheus as a dependency is problematic since any project importing the push pkg will need to import Prometheus as a result. In fact, this is one of the reasons why the push pkg was extracted from Loki in the first place (#8259).

This PR removes the dependency of Prometheus from the push pkg by copying some bits of the implementation for Prometheus' labels.Labels. We copy:

  • The Labels struct definition
  • The JSON Marshaling and Unmarshaling methods for the labels. We need this so labels are encoded as maps instead of an array of objects.

Notes for reviewers:

  • To implement the JSON Marshaling and Unmarshaling methods the push pkg now depends on golang.org/x/exp. I think it should be fine for projects importing the push pkg to also depend on golang.org/x/exp, right?

**What this PR does / why we need it**:

In #9694, we modified the `push` pkg
to import Prometheus as a dependency to use the `labels.Labels` type for
the entries' non-indexed labels.

Having Prometheus as a dependency is problematic since any project
importing the `push` pkg will need to import Prometheus as a result. In
fact, this is one of the reasons why the `push` pkg was extracted from
Loki in the first place (#8259).

This PR removes the dependency of Prometheus from the `push` pkg by
copying some bits of the implementation for Prometheus' `labels.Labels`.
We copy:
- The Labels struct definition
- The JSON Marshaling and Unmarshaling methods for the labels. We need
this so labels are encoded as maps instead of an array of objects.

---

**Notes for reviewers:**

- To implement the JSON Marshaling and Unmarshaling methods the `push`
pkg now depends on `golang.org/x/exp`. I think it should be fine for
projects importing the `push` pkg to also depend on `golang.org/x/exp`,
right?

(cherry picked from commit 15af77b)
@grafanabot grafanabot requested a review from a team as a code owner July 17, 2023 08:41
@grafanabot grafanabot added backport size/M type/bug Somehing is not working as expected labels Jul 17, 2023
Copy link
Contributor

@vlad-diachenko vlad-diachenko left a comment

Choose a reason for hiding this comment

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

lgtm

@vlad-diachenko vlad-diachenko merged commit 49b2b73 into k159 Jul 17, 2023
@vlad-diachenko vlad-diachenko deleted the backport-9937-to-k159 branch July 17, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport size/M type/bug Somehing is not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants