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

Logproto: Extract push.proto from logproto package to the separate module #8259

Merged
merged 3 commits into from
Jan 26, 2023

Conversation

mar4uk
Copy link
Contributor

@mar4uk mar4uk commented Jan 24, 2023

What this PR does / why we need it:
This PR is aimed to extract push proto to a separate module. It will allow using push proto in other repositories without bringing the whole Loki as a dependency.

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@mar4uk mar4uk changed the title Logproto: Extract push.proto from logproto.proto Logproto: Extract push.proto from logproto package to the separate module Jan 24, 2023
@mar4uk mar4uk force-pushed the extract-push-proto-from-logproto branch 11 times, most recently from 29c50af to f0a28f9 Compare January 25, 2023 15:54
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@mar4uk mar4uk force-pushed the extract-push-proto-from-logproto branch from f0a28f9 to 6c41f23 Compare January 25, 2023 17:00
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@mar4uk mar4uk force-pushed the extract-push-proto-from-logproto branch from 6c41f23 to efafb94 Compare January 25, 2023 17:15
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@mar4uk mar4uk marked this pull request as ready for review January 25, 2023 20:56
@mar4uk mar4uk requested a review from a team as a code owner January 25, 2023 20:56
Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

I like this PR, but I think we'll have to address the proto package name changing and breaking method compatibility. See #6852 for another example of this in the past.

Hopefully we can have separate golang pkgs (the new push pkg and the pre-existing logproto) both register the same grpc package namespace (logproto). If that doesn't work, we could look at code-generating a compatible grpc package from the same definition subset.


func (c *pusherClient) Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*PushResponse, error) {
out := new(PushResponse)
err := c.cc.Invoke(ctx, "/push.Pusher/Push", in, out, opts...)
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 worried this may be a breaking change since the path is used in the method name here.

@@ -0,0 +1,40 @@
syntax = "proto3";

package push;
Copy link
Member

Choose a reason for hiding this comment

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

To address breaking concerns, I wonder if we can name this with the same package as before: package logproto;

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 seems working! renamed package from push to logproto

@mar4uk mar4uk force-pushed the extract-push-proto-from-logproto branch from efafb94 to b012f96 Compare January 26, 2023 16:13
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@mar4uk mar4uk requested a review from owen-d January 26, 2023 16:27
Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

Nice work. LGTM!

@owen-d owen-d merged commit 4cd1246 into grafana:main Jan 26, 2023
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@mar4uk mar4uk mentioned this pull request Jan 27, 2023
5 tasks
salvacorts added a commit that referenced this pull request Jul 17, 2023
**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?
grafanabot pushed a commit that referenced this pull request Jul 17, 2023
**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)
vlad-diachenko pushed a commit that referenced this pull request Jul 17, 2023
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?

Co-authored-by: Salva Corts <salva.corts@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants