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

[*/datadog] Bump opentelemetry-mapping-go to v0.13.0 #30680

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Amend gohai to adapt to new types
  • Loading branch information
mx-psi committed Jan 19, 2024
commit ef7b3f13fda841839d36ffb4d3c098382dc0b265
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,43 @@ func newGohai(logger *zap.Logger) *gohai.Gohai {

if p, err := new(cpu.Cpu).Collect(); err != nil {
logger.Info("Failed to retrieve cpu metadata", zap.Error(err))
} else if cpu, ok := p.(map[string]string); !ok {
logger.Warn("Internal error: Failed to cast cpu metadata to map[string]string", zap.Any("cpu", p))
} else {
res.CPU = p
res.CPU = cpu
}

if p, err := new(filesystem.FileSystem).Collect(); err != nil {
logger.Info("Failed to retrieve filesystem metadata", zap.Error(err))
} else if fs, ok := p.([]any); !ok {
logger.Warn("Internal error: Failed to cast filesystem metadata to []any", zap.Any("filesystem", p))
} else {
res.FileSystem = p
res.FileSystem = fs
}

if p, err := new(memory.Memory).Collect(); err != nil {
logger.Info("Failed to retrieve memory metadata", zap.Error(err))
} else if mem, ok := p.(map[string]string); !ok {
logger.Warn("Internal error: Failed to cast memory metadata to map[string]string", zap.Any("memory", p))
} else {
res.Memory = p
res.Memory = mem
}

// in case of containerized environment, this would return pod id not node's ip
if p, err := new(network.Network).Collect(); err != nil {
logger.Info("Failed to retrieve network metadata", zap.Error(err))
} else if net, ok := p.(map[string]any); !ok {
logger.Warn("Internal error: Failed to cast network metadata to map[string]any", zap.Any("network", p))
} else {
res.Network = p
res.Network = net
}

if p, err := new(platform.Platform).Collect(); err != nil {
logger.Info("Failed to retrieve platform metadata", zap.Error(err))
} else if platform, ok := p.(map[string]string); !ok {
logger.Warn("Internal error: Failed to cast platform metadata to map[string]string", zap.Any("platform", p))
} else {
res.Platform = p
res.Platform = platform
}

return res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ func TestGetPayload(t *testing.T) {
logger := zap.NewNop()
gohai := NewPayload(logger)
assert.NotNil(t, gohai.Gohai.Gohai.CPU)
assert.NotPanics(t, func() { gohai.CPU() })
assert.NotNil(t, gohai.Gohai.Gohai.FileSystem)
assert.NotNil(t, gohai.Gohai.Gohai.Memory)
assert.NotNil(t, gohai.Gohai.Gohai.Network)
assert.NotPanics(t, func() { gohai.Network() })
assert.NotNil(t, gohai.Gohai.Gohai.Platform)
assert.NotPanics(t, func() { gohai.Platform() })
}