Skip to content

Commit

Permalink
Addressing the use of "deprecated"
Browse files Browse the repository at this point in the history
https://pkg.go.dev/google.golang.org/grpc#DialContext, for the
recommended function and fix docs for unix and tcp "monitor" behaviour
mvisonneau#952
  • Loading branch information
mdhomer committed Jan 30, 2025
1 parent 088f5f9 commit 53aafac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,15 @@ To use it, you have to start your exporter with the following flag `--internal-m
You can whether use a TCP or UNIX socket eg:

```
~$ gitlab-ci-pipelines-exporter -m 'unix://gcpe-monitor.sock' run
~$ gitlab-ci-pipelines-exporter -m 'unix:///gcpe-monitor.sock' run
~$ gitlab-ci-pipelines-exporter -m 'tcp://127.0.0.1:9000' run
```

To use the monitor CLI, you need to be able to access the monitoring socket and reuse the same flag:
Unix socket address format is denoted here: https://github.com/grpc/grpc/blob/master/doc/naming.md#detailed-design

To use the monitor CLI, you need to be able to access the monitoring socket and reuse the same flag:
```
export GCPE_INTERNAL_MONITORING_LISTENER_ADDRESS='unix://gcpe-monitor.sock'
export GCPE_INTERNAL_MONITORING_LISTENER_ADDRESS='unix:///gcpe-monitor.sock'
~$ gitlab-ci-pipelines-exporter run &
~$ gitlab-ci-pipelines-exporter monitor
```
Expand Down
14 changes: 9 additions & 5 deletions pkg/monitor/client/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package client

import (
"context"
"net/url"

log "github.com/sirupsen/logrus"
Expand All @@ -17,12 +16,17 @@ type Client struct {
}

// NewClient ..
func NewClient(ctx context.Context, endpoint *url.URL) *Client {
func NewClient(endpoint *url.URL) *Client {
log.WithField("endpoint", endpoint.String()).Debug("establishing gRPC connection to the server..")

conn, err := grpc.DialContext(
ctx,
endpoint.String(),
target_address := endpoint.String()
if endpoint.Scheme != "unix" {
// Drop the schema and just use "host:port" if we're dealing with local addresses
target_address = endpoint.Host
}

conn, err := grpc.NewClient(
target_address,
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/monitor/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func newModel(version string, endpoint *url.URL) (m *model) {
vp: viewport.Model{},
telemetryStream: make(chan *pb.Telemetry),
progress: &p,
client: client.NewClient(context.TODO(), endpoint),
client: client.NewClient(endpoint),
}

return
Expand Down

0 comments on commit 53aafac

Please sign in to comment.