forked from git-ecosystem/trace2receiver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform_unix.go
54 lines (45 loc) · 1.23 KB
/
platform_unix.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
//go:build !windows
// +build !windows
package trace2receiver
import (
"context"
"net"
"os"
"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_UnixSocket{
Base: &Rcvr_Base{
Settings: params,
Logger: params.Logger,
TracesConsumer: consumer,
RcvrConfig: trace2Cfg,
},
SocketPath: trace2Cfg.UnixSocketPath,
}
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, conn *net.UnixConn) {
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 {
if u, err := getPeerUsername(conn); err == nil {
tr2.pii[string(Trace2PiiUsername)] = u
}
}
}