Skip to content
Merged
Show file tree
Hide file tree
Changes from 131 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
a878428
add vcenter vSAN collection
schmikei Mar 22, 2022
c4a1025
checkpoint on getting property collection working
schmikei Mar 23, 2022
e686bb8
checkpoint before integration test
schmikei Mar 29, 2022
0311440
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 5, 2022
5dbcbc6
dual receivers under root receiver pointer
schmikei Apr 5, 2022
ee81978
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 5, 2022
a61e963
checkpoint before updated mdatagen
schmikei Apr 7, 2022
560f6c3
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 7, 2022
349148d
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 8, 2022
0a9edb4
use syslog receiver rather than tcplogreceiver
schmikei Apr 8, 2022
ffe05e4
getting more performance counter refinements
schmikei Apr 12, 2022
67f292f
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 12, 2022
4f4aeb6
remove unneccessary component addition
schmikei Apr 12, 2022
d95221f
try to fix go.mod resolution issues
schmikei Apr 12, 2022
d2f9356
try to fix go.mod resolution issues pt 2
schmikei Apr 12, 2022
d52200b
addlicense
schmikei Apr 12, 2022
a684fd5
fix go.mod by fixing require directive
schmikei Apr 12, 2022
655dbbd
Merge branch 'main' into vmwarevcenterreceiver-metricsreceiver
schmikei Apr 12, 2022
bc35c19
add readme for metrics
schmikei Apr 12, 2022
68e3313
Merge branch 'vmwarevcenterreceiver-metricsreceiver' of github.com:ob…
schmikei Apr 12, 2022
ac81137
update readme
schmikei Apr 12, 2022
85bcccd
fix go.mod referring nonexistent version
schmikei Apr 12, 2022
f92cb2b
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 12, 2022
a191060
add performance manager tests
schmikei Apr 12, 2022
bd93bd9
more tests
schmikei Apr 12, 2022
49c22ad
add more attributes to virtual machines and host systems
schmikei Apr 12, 2022
17c4ed8
add more attributes to virtual machines and host systems
schmikei Apr 12, 2022
0051336
spike changelog entry
schmikei Apr 12, 2022
fd3ba25
fix go.mod in both places
schmikei Apr 12, 2022
debfe53
fix go.mod in configschema
schmikei Apr 12, 2022
371a491
add // import github.com/open-telemetry/opentelemetry-collector-contr…
schmikei Apr 12, 2022
02a326d
add quotations
schmikei Apr 13, 2022
8d84602
add to receiver lifecycle
schmikei Apr 13, 2022
ba2ce31
remove extra go generate direction
schmikei Apr 13, 2022
87fea71
fix typo of utilizaiton in metric description
schmikei Apr 13, 2022
407819e
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 13, 2022
64109a4
small changes to interval id in performance queries to be more consis…
schmikei Apr 13, 2022
bb45c02
PR feedback including omitting company name prefix
schmikei Apr 13, 2022
ac7e105
PR feedback to not fail starting the component on potential network f…
schmikei Apr 13, 2022
05669dd
minor grammar correction in vcenter readme
schmikei Apr 13, 2022
cbd2e97
update expected metrics
schmikei Apr 13, 2022
bab0085
update host_effective attribute value
schmikei Apr 13, 2022
3c02116
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 13, 2022
3baa6f8
remove PerformanceInterval customizability
schmikei Apr 13, 2022
e554a2e
add to codeowners
schmikei Apr 14, 2022
09cd252
Merge branch 'main' into vmwarevcenterreceiver-metricsreceiver
schmikei Apr 14, 2022
9a8b9fb
fix indentation on merge conflict
schmikei Apr 14, 2022
5f90aa5
fix changelog entry place so its in the new components section
schmikei Apr 14, 2022
389caf6
update to be on 0.49.0 of the collector'
schmikei Apr 14, 2022
3ac56e9
add PR number to changelog
schmikei Apr 14, 2022
23d6fe6
regenerate with newer version of mdatagen
schmikei Apr 14, 2022
b9fb5d6
move error log if unable to connect on start to receiver.Start() rath…
schmikei Apr 14, 2022
33e0cf6
fix test cases from last commit
schmikei Apr 14, 2022
83b4570
minor update to config with tests
schmikei Apr 14, 2022
291cbea
Merge branch 'main' into vmwarevcenterreceiver-metricsreceiver
schmikei Apr 14, 2022
f1c37e4
fix metric description
schmikei Apr 15, 2022
81aaa55
Merge branch 'vmwarevcenterreceiver-metricsreceiver' of github.com:ob…
schmikei Apr 15, 2022
c458195
use utc for host vsan collection as well
schmikei Apr 15, 2022
6cd2403
Merge branch 'main' into vmwarevcenterreceiver-metricsreceiver
schmikei Apr 15, 2022
a52583b
update comments of public facing methods
schmikei Apr 18, 2022
dfc5bb0
return errors on getting clusters to the scraper errors
schmikei Apr 18, 2022
138f588
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 18, 2022
f00c1e1
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 19, 2022
dc8f2ea
PR feedback #1
schmikei Apr 19, 2022
faf80c5
instantiate new client if client is nil
schmikei Apr 20, 2022
3a2e793
update all descriptions to have punctuation
schmikei Apr 20, 2022
2cd9dc7
three more descs
schmikei Apr 20, 2022
fba2b5b
move ensureReceiver up to once we validated as a config
schmikei Apr 20, 2022
a956cd2
some more PR feedback
schmikei Apr 20, 2022
f51f366
looking into race conditions
schmikei Apr 20, 2022
c0f7609
run go tidy
schmikei Apr 20, 2022
60ab408
fix import order and remove unneccessary mutex
schmikei Apr 20, 2022
981f399
remove mutex from struct
schmikei Apr 20, 2022
39f402c
refactor client to responsible for knowing if the vsan endpoints are …
schmikei Apr 20, 2022
4f2374c
fix integration test referencing old var
schmikei Apr 20, 2022
8b23b88
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 20, 2022
a07307e
change metrics.metrics => metrics.settings, update client pr feedback
schmikei Apr 20, 2022
5d62c14
remove vSAN collection temporarily
schmikei Apr 20, 2022
1a16fc2
remove extra metric attributes for vSAN
schmikei Apr 20, 2022
13502dc
remove vsan specific variables
schmikei Apr 20, 2022
471b2b2
clean up host PerfCounter disk latency metrics and fix some descripti…
schmikei Apr 21, 2022
9fcf326
add 20s interval to extended documentation as needed
schmikei Apr 21, 2022
27bff1d
mdatagen fixes
schmikei Apr 21, 2022
c647af0
add integration test metric scrape
schmikei Apr 21, 2022
91ab463
gotidy
schmikei Apr 21, 2022
d2f840d
fix import order
schmikei Apr 21, 2022
af000cc
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 21, 2022
e64e04d
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Apr 22, 2022
a1023ca
go up to 0.49.1
schmikei Apr 22, 2022
fd560e4
gotidy
schmikei Apr 22, 2022
a914b5f
add replace directive for semconv
schmikei Apr 22, 2022
913924a
Merge branch 'main' into vmwarevcenterreceiver-metricsreceiver
schmikei Apr 29, 2022
b408153
gotidy fixes
schmikei Apr 29, 2022
4a8a674
fix component not being on 0.50.0
schmikei Apr 29, 2022
423489f
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 4, 2022
8d5bd4e
update to v0.50.1-0.20220429151328-041f39835df7
schmikei May 4, 2022
53a6529
use newer mdatagen
schmikei May 4, 2022
0f0e5ae
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 9, 2022
42246f3
remove any logging functionality change && update documentation
schmikei May 9, 2022
b552ce4
fix integration test from flattening of config
schmikei May 9, 2022
712ed6a
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 9, 2022
8357e75
fix scraper start not erroring if connection cannot be established
schmikei May 9, 2022
50aa4be
make scrapertest less flaky
schmikei May 9, 2022
b05e419
format test json
schmikei May 9, 2022
b4c9c24
Apply suggestions from code review
schmikei May 9, 2022
efa4d72
adjust metric definition for vcenter.host.disk.throughput
schmikei May 9, 2022
74a9808
Merge branch 'vmwarevcenterreceiver-metricsreceiver' of github.com:ob…
schmikei May 9, 2022
1439070
remove comment and move pm level 2 metrics to appropriate section
schmikei May 9, 2022
e7e3307
try to be respective of datacenters
schmikei May 12, 2022
9d11adf
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 12, 2022
cdf9aae
fix only vCenter server functionality
schmikei May 12, 2022
f64408e
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 17, 2022
ab1f40e
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 20, 2022
04671a3
try building out a mock server for test coverage
schmikei May 20, 2022
ba52924
make goporto
schmikei May 20, 2022
ce9a924
fix build issues
schmikei May 20, 2022
7457f1b
use latest mdatagen
schmikei May 20, 2022
08493ea
add newlines to ends of xml recordings
schmikei May 20, 2022
6dc5d7e
fix integration test
schmikei May 20, 2022
694c1a6
moved around scrapererrors because now the receiver is datacenter dep…
schmikei May 20, 2022
f4fad03
try and do an audit of performance metrics and requests/responses
schmikei May 23, 2022
17703ab
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 23, 2022
e61a5dd
update testdata with correct units
schmikei May 23, 2022
ee54511
make tidy
schmikei May 23, 2022
8a0968f
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 24, 2022
111c1e4
make tidy
schmikei May 24, 2022
2d05ac7
update collector version
schmikei May 24, 2022
6a7007b
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 24, 2022
9704501
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 24, 2022
770db40
fix local testing code including modules
schmikei May 24, 2022
0426b76
remove deprecated use of commonponenterror
schmikei May 24, 2022
8eb488c
pr feedback; add method of collection recording, return poweredOn/pow…
schmikei May 25, 2022
aaf9c21
remove content.json
schmikei May 25, 2022
8b7bd0e
fix description change in scraper_test.go
schmikei May 25, 2022
f87fe73
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 25, 2022
e66c018
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 25, 2022
c88282d
update collector version
schmikei May 25, 2022
7634f35
bump replaced module; rebuild load tests
schmikei May 26, 2022
5ee6e15
fix alibaba version auto localizing
schmikei May 26, 2022
e8bd19b
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei May 26, 2022
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ receiver/statsdreceiver/ @open-telemetry/collector-c
receiver/syslogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/tcplogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/udplogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/vcenterreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @schmikei
receiver/wavefrontreceiver/ @open-telemetry/collector-contrib-approvers @pjanotti
receiver/windowsperfcountersreceiver/ @open-telemetry/collector-contrib-approvers @dashpole
receiver/zipkinreceiver/ @open-telemetry/collector-contrib-approvers @pmm-sumo
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
### 🚀 New components 🚀

- `iisreceiver`: Add implementation of IIS Metric Receiver (#8832)
- `vcenterreceiver`: Add metrics receiver for new vcenterreceiver component (#9224)
- `sqlserverreceiver`: Add implementation of SQL Server Metric Receiver (#8398)
- `activedirectorydsreceiver`: Add implementation of Active Directory Domain Services metric receiver (#9359)

Expand Down
4 changes: 4 additions & 0 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver v0.51.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver v0.51.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.51.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.51.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.51.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.51.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.51.0 // indirect
Expand Down Expand Up @@ -455,6 +456,7 @@ require (
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/vmware/go-vmware-nsxt v0.0.0-20220328155605-f49a14c1ef5f // indirect
github.com/vmware/govmomi v0.28.0 // indirect
github.com/wavefronthq/wavefront-sdk-go v0.9.11 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
Expand Down Expand Up @@ -839,6 +841,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplo

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver => ../../receiver/udplogreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver => ../../receiver/vcenterreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver => ../../receiver/wavefrontreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver => ../../receiver/windowsperfcountersreceiver
Expand Down
3 changes: 3 additions & 0 deletions cmd/configschema/go.sum

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

Empty file added cmd/otelcontribcol/content.json
Empty file.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver v0.51.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver v0.51.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.51.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.51.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.51.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.51.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.51.0
Expand Down Expand Up @@ -456,6 +457,7 @@ require (
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/vmware/go-vmware-nsxt v0.0.0-20220328155605-f49a14c1ef5f // indirect
github.com/vmware/govmomi v0.28.0 // indirect
github.com/wavefronthq/wavefront-sdk-go v0.9.11 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
Expand Down Expand Up @@ -841,6 +843,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplo

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver => ./receiver/udplogreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver => ./receiver/vcenterreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver => ./receiver/wavefrontreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver => ./receiver/windowsperfcountersreceiver
Expand Down
3 changes: 3 additions & 0 deletions go.sum

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

2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver"
Expand Down Expand Up @@ -245,6 +246,7 @@ func Components() (component.Factories, error) {
syslogreceiver.NewFactory(),
tcplogreceiver.NewFactory(),
udplogreceiver.NewFactory(),
vcenterreceiver.NewFactory(),
zipkinreceiver.NewFactory(),
}
receivers = append(receivers, extraReceivers()...)
Expand Down
3 changes: 3 additions & 0 deletions internal/components/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ func TestDefaultReceivers(t *testing.T) {
return cfg
},
},
{
receiver: "vcenter",
},
}

assert.Len(t, tests, len(rcvrFactories), "All receivers must be added to the lifecycle suite")
Expand Down
1 change: 1 addition & 0 deletions receiver/vcenterreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
46 changes: 46 additions & 0 deletions receiver/vcenterreceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# vCenter Receiver

This receiver fetches metrics from a vCenter or ESXi host running VMware vSphere APIs.

Supported pipeline types: `metrics`

> :construction: This receiver is in **Alpha**. Configuration fields and metric data model are subject to change.

## Prerequisites

This receiver has been built to support ESXi and vCenter versions:

- 7.0
- 6.7
- 7.5
Copy link
Member

Choose a reason for hiding this comment

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

sort()


A “Read Only” user assigned to a vSphere with permissions to the vCenter server, cluster and all subsequent resources being monitored must be specified in order for the receiver to retrieve information about them.

## Configuration


| Parameter | Default | Type | Notes |
| --- | --- | --- | --- |
| endpoint | | String | Endpoint to the vCenter Server or ESXi host that has the sdk path enabled. Required. The expected format is `<protocol>://<hostname>` <br><br> i.e: `https://vcsa.hostname.localnet` |
| username | | String | Required |
| password | | String | Required |
| tls | | TLSClientSetting | Not Required. Will use defaults for [configtls.TLSClientSetting](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md). By default insecure settings are rejected and certificate verification is on. |
| collection_interval | 2m | Duration | This receiver collects metrics on an interval. If the vCenter is fairly large, this value may need to be increased. Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h` |

### Example Configuration

```yaml
receivers:
vcenter:
endpoint: http://localhost:15672
username: otelu
password: $VCENTER_PASSWORD
collection_interval: 5m
metrics: []
```

The full list of settings exposed for this receiver are documented [here](./config.go) with detailed sample configurations [here](./testdata/config.yaml). TLS config is documented further under the [opentelemetry collector's configtls package](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md).

## Metrics

Details about the metrics produced by this receiver can be found in [metadata.yaml](./metadata.yaml) with further documentation in [documentation.md](./documentation.md)
154 changes: 154 additions & 0 deletions receiver/vcenterreceiver/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// Copyright The OpenTelemetry Authors
//
// Licensed 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 vcenterreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver"

import (
"context"
"fmt"
"net/url"

"github.com/vmware/govmomi"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/performance"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25"
vt "github.com/vmware/govmomi/vim25/types"
)

// vcenterClient is a client that
type vcenterClient struct {
moClient *govmomi.Client
vimDriver *vim25.Client
finder *find.Finder
pc *property.Collector
pm *performance.Manager
cfg *Config
}

func newVcenterClient(c *Config) *vcenterClient {
return &vcenterClient{
cfg: c,
}
}

// EnsureConnection will establish a connection to the vSphere SDK if not already established
func (vc *vcenterClient) EnsureConnection(ctx context.Context) error {
if vc.moClient != nil {
return nil
}

sdkURL, err := vc.cfg.SDKUrl()
if err != nil {
return err
}
client, err := govmomi.NewClient(ctx, sdkURL, vc.cfg.Insecure)
if err != nil {
return fmt.Errorf("unable to connect to vSphere SDK on listed endpoint: %w", err)
}
tlsCfg, err := vc.cfg.LoadTLSConfig()
if err != nil {
return err
}
client.DefaultTransport().TLSClientConfig = tlsCfg
user := url.UserPassword(vc.cfg.Username, vc.cfg.Password)
err = client.Login(ctx, user)
if err != nil {
return fmt.Errorf("unable to login to vcenter sdk: %w", err)
}
vc.moClient = client
vc.vimDriver = client.Client
vc.pc = property.DefaultCollector(vc.vimDriver)
vc.finder = find.NewFinder(vc.vimDriver)
vc.pm = performance.NewManager(vc.vimDriver)
return nil
}

// Disconnect will logout of the autenticated session
func (vc *vcenterClient) Disconnect(ctx context.Context) error {
if vc.moClient != nil {
return vc.moClient.Logout(ctx)
}
return nil
}

// Clusters returns the clusterComputeResources of the vSphere SDK
func (vc *vcenterClient) Datacenters(ctx context.Context) ([]*object.Datacenter, error) {
datacenters, err := vc.finder.DatacenterList(ctx, "*")
if err != nil {
return []*object.Datacenter{}, fmt.Errorf("unable to get datacenter lists: %w", err)
}
return datacenters, nil
}

// Clusters returns the clusterComputeResources of the vSphere SDK
func (vc *vcenterClient) Clusters(ctx context.Context, datacenter *object.Datacenter) ([]*object.ClusterComputeResource, error) {
vc.finder = vc.finder.SetDatacenter(datacenter)
clusters, err := vc.finder.ClusterComputeResourceList(ctx, "*")
if err != nil {
return []*object.ClusterComputeResource{}, err
}
return clusters, nil
}

// ResourcePools returns the resourcePools in the vSphere SDK
func (vc *vcenterClient) ResourcePools(ctx context.Context) ([]*object.ResourcePool, error) {
rps, err := vc.finder.ResourcePoolList(ctx, "*")
if err != nil {
return nil, fmt.Errorf("unable to retrieve resource pools: %w", err)
}
return rps, err
}

func (vc *vcenterClient) VMs(ctx context.Context) ([]*object.VirtualMachine, error) {
vms, err := vc.finder.VirtualMachineList(ctx, "*")
if err != nil {
return nil, fmt.Errorf("unable to retrieve resource pools: %w", err)
}
return vms, err
}

type perfSampleResult struct {
counters map[string]*vt.PerfCounterInfo
results []performance.EntityMetric
}

func (vc *vcenterClient) performanceQuery(
ctx context.Context,
spec vt.PerfQuerySpec,
names []string,
objs []vt.ManagedObjectReference,
) (*perfSampleResult, error) {
if vc.pm == nil {
return &perfSampleResult{}, nil
}
vc.pm.Sort = true
sample, err := vc.pm.SampleByName(ctx, spec, names, objs)
if err != nil {
return nil, err
}
result, err := vc.pm.ToMetricSeries(ctx, sample)
if err != nil {
return nil, err
}
counterInfoByName, err := vc.pm.CounterInfoByName(ctx)
if err != nil {
return nil, err
}
return &perfSampleResult{
counters: counterInfoByName,
results: result,
}, nil
}
66 changes: 66 additions & 0 deletions receiver/vcenterreceiver/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright The OpenTelemetry Authors
//
// Licensed 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 vcenterreceiver // import github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver

import (
"context"
"testing"

"github.com/stretchr/testify/require"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/simulator"
"github.com/vmware/govmomi/vim25"
)

func TestGetClusters(t *testing.T) {
simulator.Test(func(ctx context.Context, c *vim25.Client) {
finder := find.NewFinder(c)
client := vcenterClient{
vimDriver: c,
finder: finder,
}
dc, err := finder.DefaultDatacenter(ctx)
require.NoError(t, err)
clusters, err := client.Clusters(ctx, dc)
require.NoError(t, err)
require.NotEmpty(t, clusters, 0)
})
}

func TestGetResourcePools(t *testing.T) {
simulator.Test(func(ctx context.Context, c *vim25.Client) {
finder := find.NewFinder(c)
client := vcenterClient{
vimDriver: c,
finder: finder,
}
resourcePools, err := client.ResourcePools(ctx)
require.NoError(t, err)
require.NotEmpty(t, resourcePools)
})
}

func TestGetVMs(t *testing.T) {
simulator.Test(func(ctx context.Context, c *vim25.Client) {
finder := find.NewFinder(c)
client := vcenterClient{
vimDriver: c,
finder: finder,
}
vms, err := client.VMs(ctx)
require.NoError(t, err)
require.NotEmpty(t, vms)
})
}
Loading