Skip to content

Commit

Permalink
Merge branch 'nginx:main' into AddADMResourceNameDims
Browse files Browse the repository at this point in the history
  • Loading branch information
p-borole authored Aug 15, 2023
2 parents 3461ca5 + a13f6ca commit 68ecd7a
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 36 deletions.
2 changes: 2 additions & 0 deletions hugo/config/_default/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ refLinksErrorLevel = "ERROR"
enableRobotsTXT = "true"
#canonifyURLs = true
pluralizeListTitles = false
pygmentsCodeFences = true
pygmentsUseClasses = true

[caches]
[caches.modules]
Expand Down
2 changes: 1 addition & 1 deletion hugo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nginx/agent/hugo

go 1.18

require github.com/nginxinc/nginx-hugo-theme v0.34.0 // indirect
require github.com/nginxinc/nginx-hugo-theme v0.35.0 // indirect
2 changes: 2 additions & 0 deletions hugo/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ github.com/nginxinc/nginx-hugo-theme v0.34.0-alpha h1:8tKWnkhxP5Nk0V64v8rE9T3cru
github.com/nginxinc/nginx-hugo-theme v0.34.0-alpha/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
github.com/nginxinc/nginx-hugo-theme v0.34.0 h1:G7LPVq7w1ls6IS4+OkTwjhFb67rLCzPdfZvW1/sn2Cw=
github.com/nginxinc/nginx-hugo-theme v0.34.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
github.com/nginxinc/nginx-hugo-theme v0.35.0 h1:7XB2GMy6qeJgKEJy9wOS3SYKYpfvLW3/H+UHRPLM4FU=
github.com/nginxinc/nginx-hugo-theme v0.35.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
10 changes: 0 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package main

import (
"context"
"net/http"
"os"
"os/signal"
"runtime"
Expand All @@ -27,8 +26,6 @@ import (
"github.com/nginx/agent/v2/src/extensions"
"github.com/nginx/agent/v2/src/plugins"

_ "net/http/pprof"

"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -58,13 +55,6 @@ func init() {
}

func main() {
address, debug := os.LookupEnv("PROFILE_ADDRESS")
if debug {
go func() {
log.Println(http.ListenAndServe(address, nil))
}()
}

config.RegisterRunner(func(cmd *cobra.Command, _ []string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
7 changes: 6 additions & 1 deletion sdk/client/commander.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,12 @@ func (c *commander) handleGrpcError(messagePrefix string, err error) error {
if st, ok := status.FromError(err); ok {
log.Errorf("%s: error communicating with %s, code=%s, message=%v", messagePrefix, c.grpc.Target(), st.Code().String(), st.Message())
} else if err == io.EOF {
log.Errorf("%s: server %s is not processing requests, code=%s, message=%v", messagePrefix, c.grpc.Target(), st.Code().String(), st.Message())
_, err = c.channel.Recv()
if st, ok = status.FromError(err); ok {
log.Errorf("%s: server %s is not processing requests, code=%s, message=%v", messagePrefix, c.grpc.Target(), st.Code().String(), st.Message())
} else {
log.Errorf("%s: unable to receive error message for EOF from %s, %v", messagePrefix, c.grpc.Target(), err)
}
} else {
log.Errorf("%s: unknown grpc error while communicating with %s, %v", messagePrefix, c.grpc.Target(), err)
}
Expand Down
7 changes: 6 additions & 1 deletion sdk/client/metric_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ func (r *metricReporter) handleGrpcError(messagePrefix string, err error) error
if st, ok := status.FromError(err); ok {
log.Errorf("%s: error communicating with %s, code=%s, message=%v", messagePrefix, r.grpc.Target(), st.Code().String(), st.Message())
} else if err == io.EOF {
log.Errorf("%s: server %s is not processing requests, code=%s, message=%v", messagePrefix, r.grpc.Target(), st.Code().String(), st.Message())
_, err = r.channel.CloseAndRecv()
if st, ok = status.FromError(err); ok {
log.Errorf("%s: server %s is not processing requests, code=%s, message=%v", messagePrefix, r.grpc.Target(), st.Code().String(), st.Message())
} else {
log.Errorf("%s: unable to receive error message for EOF from %s, %v", messagePrefix, r.grpc.Target(), err)
}
} else {
log.Errorf("%s: unknown grpc error while communicating with %s, %v", messagePrefix, r.grpc.Target(), err)
}
Expand Down
9 changes: 6 additions & 3 deletions src/core/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func (env *EnvironmentType) NewHostInfoWithContext(ctx context.Context, agentVer
return &proto.HostInfo{}
}

if tags == nil {
tags = &[]string{}
}

hostInfoFacacde := &proto.HostInfo{
Agent: agentVersion,
Boot: hostInformation.BootTime,
Expand Down Expand Up @@ -175,8 +179,7 @@ func getUnixName() string {
release := toStr(utsname.Release[:])
version := toStr(utsname.Version[:])
machine := toStr(utsname.Machine[:])

return strings.Join([]string{sysName, nodeName, release, version, machine}, " ")
return fmt.Sprintf("%s %s %s %s %s", sysName, nodeName, release, version, machine)
}

func (env *EnvironmentType) GetHostname() string {
Expand Down Expand Up @@ -795,7 +798,7 @@ func releaseInfo(osReleaseFile string) (release *proto.ReleaseInfo) {
hostReleaseInfo := getHostReleaseInfo()
osRelease, err := getOsRelease(osReleaseFile)
if err != nil {
log.Warnf("Could not read from %s file: %v", osReleaseFile, err)
log.Warnf("Could not read from osRelease file: %v", err)
return hostReleaseInfo
}
return mergeHostAndOsReleaseInfo(hostReleaseInfo, osRelease)
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/dataplane_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func (dps *DataPlaneStatus) healthGoRoutine(pipeline core.MessagePipeInterface)

func (dps *DataPlaneStatus) dataplaneStatus(forceDetails bool) *proto.DataplaneStatus {
processes := dps.env.Processes()
log.Tracef("dataplaneStatus: processes %v", processes)
forceDetails = forceDetails || time.Now().UTC().Add(-dps.reportInterval).After(dps.lastSendDetails)

agentActivityStatuses := []*proto.AgentActivityStatus{}
Expand All @@ -209,7 +208,6 @@ func (dps *DataPlaneStatus) dataplaneStatus(forceDetails bool) *proto.DataplaneS
DataplaneSoftwareDetails: dataplaneSoftwareDetails,
AgentActivityStatus: agentActivityStatuses,
}

return dataplaneStatus
}

Expand All @@ -223,7 +221,7 @@ func (dps *DataPlaneStatus) hostInfo(send bool) (info *proto.HostInfo) {
dps.envHostInfo = hostInfo
log.Tracef("hostInfo: %v", hostInfo)

return dps.envHostInfo
return hostInfo
}

func (dps *DataPlaneStatus) detailsForProcess(processes []*core.Process, send bool) (details []*proto.NginxDetails) {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ func createCollectorConfigsMap(config *config.Config, env core.Environment, bina
ClientVersion: config.Nginx.NginxClientVersion,
}
}

return collectorConfigsMap
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/performance/advanced-metrics/metric_gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func (g *Generator) Generate(ctx context.Context, output chan *Message) error {
for {
select {
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
}
return
case <-timer.C:
g.regenerateCache()
Expand Down
23 changes: 23 additions & 0 deletions test/performance/environment_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package performance

import (
"testing"

"github.com/nginx/agent/v2/src/core"
)

func BenchmarkNewHostInfo(b *testing.B) {
b.ResetTimer()
env := &core.EnvironmentType{}
for i := 0; i < b.N; i++ {
env.NewHostInfo("", nil, "", false)
}
}

func BenchmarkProceses(b *testing.B) {
b.ResetTimer()
env := &core.EnvironmentType{}
for i := 0; i < b.N; i++ {
env.Processes()
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 68ecd7a

Please sign in to comment.