forked from git-ecosystem/trace2receiver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform_windows.go
61 lines (51 loc) · 1.54 KB
/
platform_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//go:build windows
// +build windows
package trace2receiver
import (
"context"
"os"
"os/user"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"
)
func createTraces(_ context.Context,
params receiver.CreateSettings,
baseCfg component.Config,
consumer consumer.Traces) (receiver.Traces, error) {
if consumer == nil {
return nil, component.ErrNilNextConsumer
}
trace2Cfg := baseCfg.(*Config)
rcvr := &Rcvr_NamedPipe{
Base: &Rcvr_Base{
Settings: params,
Logger: params.Logger,
TracesConsumer: consumer,
RcvrConfig: trace2Cfg,
},
NamedPipePath: trace2Cfg.NamedPipePath,
}
return rcvr, nil
}
// Gather up any requested PII from the machine or
// possibly the connection from the client process.
// Add any requested PII data to `tr2.pii[]`.
func (tr2 *trace2Dataset) pii_gather(cfg *Config) {
if cfg.piiSettings != nil && cfg.piiSettings.Include.Hostname {
if h, err := os.Hostname(); err == nil {
tr2.pii[string(Trace2PiiHostname)] = h
}
}
if cfg.piiSettings != nil && cfg.piiSettings.Include.Username {
// TODO For now, just lookup the current user. This may
// or may not be valid when the service is officially
// installed. Ideally we should get the user-id of the
// client process. Or, since most Windows systems are
// single login, get the name of the owner of the console
// and assume it doesn't change.
if u, err := user.Current(); err == nil {
tr2.pii[string(Trace2PiiUsername)] = u.Username
}
}
}