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

Refactor of system/memory metricset #26334

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a8003d0
init commit
fearful-symmetry Jun 3, 2021
cc898a1
start on linux implementation
fearful-symmetry Jun 4, 2021
b243bd0
finish linux, start work on darwin
fearful-symmetry Jun 8, 2021
59fc7d4
fix build platform issues
fearful-symmetry Jun 8, 2021
f51e0bf
fix metrics on darwin
fearful-symmetry Jun 8, 2021
484d064
add openbsd
fearful-symmetry Jun 8, 2021
fa17efd
add freebsd
fearful-symmetry Jun 9, 2021
d9da0ea
add windows, aix
fearful-symmetry Jun 9, 2021
6fea17d
fix aix build
fearful-symmetry Jun 9, 2021
b89318b
finish memory
fearful-symmetry Jun 9, 2021
13fe38c
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 15, 2021
44065b3
fix up opt changes
fearful-symmetry Jun 15, 2021
cd760cb
cleanup metricset code
fearful-symmetry Jun 15, 2021
4cec2e0
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 15, 2021
4e6618c
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 15, 2021
7c93b60
fix up folder methods
fearful-symmetry Jun 16, 2021
5b28daa
fix calculations, Opt API, gomod
fearful-symmetry Jun 16, 2021
a517ecb
make notice
fearful-symmetry Jun 17, 2021
fd8cb86
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 17, 2021
dd6a0e1
go mod tidy, mage fmt
fearful-symmetry Jun 17, 2021
87aaeaa
fix up linux/memory
fearful-symmetry Jun 21, 2021
0574d52
update fields
fearful-symmetry Jun 22, 2021
4753d23
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 23, 2021
c7fb4e7
update system tests
fearful-symmetry Jun 23, 2021
6c0bc54
fix system tests, again
fearful-symmetry Jun 23, 2021
316c501
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 23, 2021
5088c94
fix extra print statements
fearful-symmetry Jun 23, 2021
7b52da1
fix if block in fillPercentages
fearful-symmetry Jun 23, 2021
28fb3c9
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 24, 2021
d5f5ea1
vix Value API
fearful-symmetry Jun 24, 2021
0c12bd9
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 28, 2021
7e57c13
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 28, 2021
5ff4463
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 28, 2021
e3e5542
Merge remote-tracking branch 'upstream/master' into system-refactor-m…
fearful-symmetry Jun 29, 2021
8212fee
fix up tests, opt
fearful-symmetry Jun 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 0 additions & 172 deletions libbeat/metric/system/memory/memory.go

This file was deleted.

96 changes: 0 additions & 96 deletions libbeat/metric/system/memory/memory_test.go

This file was deleted.

16 changes: 12 additions & 4 deletions libbeat/metric/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/match"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/metric/system/memory"
sysinfo "github.com/elastic/go-sysinfo"
sigar "github.com/elastic/gosigar"
"github.com/elastic/gosigar/cgroup"
)
Expand Down Expand Up @@ -288,12 +288,20 @@ func GetOwnResourceUsageTimeInMillis() (int64, int64, error) {

func (procStats *Stats) getProcessEvent(process *Process) common.MapStr {

// This is a holdover until we migrate this library to metricbeat/internal
// At which point we'll use the memory code there.
var totalPhyMem uint64
baseMem, err := memory.Get()
host, err := sysinfo.Host()
if err != nil {
procStats.logger.Warnf("Getting memory details: %v", err)
procStats.logger.Warnf("Getting host details: %v", err)
} else {
totalPhyMem = baseMem.Mem.Total
memStats, err := host.Memory()
if err != nil {
procStats.logger.Warnf("Getting memory details: %v", err)
} else {
totalPhyMem = memStats.Total
}

}

proc := common.MapStr{
Expand Down
44 changes: 44 additions & 0 deletions metricbeat/internal/metrics/fold.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package metrics

import (
"github.com/elastic/go-structform"
)

// Fold implements the folder interface for OptUint
func (in *OptUint) Fold(v structform.ExtVisitor) error {
fearful-symmetry marked this conversation as resolved.
Show resolved Hide resolved
if in.exists == true {
value := in.value
v.OnUint64(value)
} else {
v.OnNil()
}
return nil
}

// Fold implements the folder interface for OptUint
func (in *OptFloat) Fold(v structform.ExtVisitor) error {
if in.exists == true {
value := in.value
v.OnFloat64(value)
} else {
v.OnNil()
}
return nil
}
Loading