Skip to content

Commit 111d2f8

Browse files
authored
Added Agent version to userAgent (#1019)
1 parent 55b81f4 commit 111d2f8

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ APK_PACKAGE := ./build/$(PACKAGE_NAME).apk
6060
DEB_PACKAGE := ./build/$(PACKAGE_NAME).deb
6161
RPM_PACKAGE := ./build/$(PACKAGE_NAME).rpm
6262

63-
MOCK_MANAGEMENT_PLANE_CONFIG_DIRECTORY ?=
63+
MOCK_MANAGEMENT_PLANE_CONFIG_DIRECTORY ?=
6464
MOCK_MANAGEMENT_PLANE_LOG_LEVEL ?= INFO
6565
MOCK_MANAGEMENT_PLANE_GRPC_ADDRESS ?= 127.0.0.1:0
6666
MOCK_MANAGEMENT_PLANE_API_ADDRESS ?= 127.0.0.1:0
@@ -180,7 +180,7 @@ run: build ## Run code
180180

181181
dev: ## Run agent executable
182182
@echo "🚀 Running App"
183-
$(GORUN) $(PROJECT_DIR)/$(PROJECT_FILE)
183+
$(GORUN) -ldflags=$(LDFLAGS) $(PROJECT_DIR)/$(PROJECT_FILE)
184184

185185
race-condition-dev: ## Run agent executable with race condition detection
186186
@echo "🏎️ Running app with race condition detection enabled"

Diff for: internal/grpc/grpc.go

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"log/slog"
1515
"net"
1616
"os"
17+
"strings"
1718
"sync"
1819

1920
"github.com/cenkalti/backoff/v4"
@@ -204,6 +205,7 @@ func GetDialOptions(agentConfig *config.Config, resourceID string) []grpc.DialOp
204205
opts := []grpc.DialOption{
205206
grpc.WithChainStreamInterceptor(streamClientInterceptors...),
206207
grpc.WithChainUnaryInterceptor(unaryClientInterceptors...),
208+
grpc.WithUserAgent("nginx-agent/" + strings.TrimPrefix(agentConfig.Version, "v")),
207209
grpc.WithDefaultServiceConfig(serviceConfig),
208210
}
209211

Diff for: internal/grpc/grpc_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ func Test_GetDialOptions(t *testing.T) {
9898
},
9999
},
100100
},
101-
expected: 6,
101+
expected: 7,
102102
createCerts: false,
103103
},
104104
{
105105
name: "Test 2: DialOptions mTLS",
106106
agentConfig: types.AgentConfig(),
107-
expected: 6,
107+
expected: 7,
108108
createCerts: true,
109109
},
110110
{
@@ -123,7 +123,7 @@ func Test_GetDialOptions(t *testing.T) {
123123
},
124124
Client: types.AgentConfig().Client,
125125
},
126-
expected: 6,
126+
expected: 7,
127127
createCerts: false,
128128
},
129129
{
@@ -135,7 +135,7 @@ func Test_GetDialOptions(t *testing.T) {
135135
TLS: types.AgentConfig().Command.TLS,
136136
},
137137
},
138-
expected: 4,
138+
expected: 5,
139139
createCerts: false,
140140
},
141141
{
@@ -147,7 +147,7 @@ func Test_GetDialOptions(t *testing.T) {
147147
TLS: types.AgentConfig().Command.TLS,
148148
},
149149
},
150-
expected: 6,
150+
expected: 7,
151151
createCerts: false,
152152
},
153153
{
@@ -159,7 +159,7 @@ func Test_GetDialOptions(t *testing.T) {
159159
Auth: types.AgentConfig().Command.Auth,
160160
},
161161
},
162-
expected: 7,
162+
expected: 8,
163163
createCerts: false,
164164
},
165165
}

0 commit comments

Comments
 (0)