Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ exports_files(glob(
# gazelle:exclude comp/core/diagnose/fx
# gazelle:exclude comp/core/diagnose/impl
# gazelle:exclude comp/core/diagnose/local
# gazelle:exclude comp/core/flare/flareimpl
# gazelle:exclude comp/core/flare/helpers
# gazelle:exclude comp/core/gui/fx
# gazelle:exclude comp/core/gui/impl
# gazelle:exclude comp/core/hostname/remotehostnameimpl
Expand Down
8 changes: 4 additions & 4 deletions cmd/agent/subcommands/flare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
"github.com/DataDog/datadog-agent/comp/core/diagnose/format"
diagnosefx "github.com/DataDog/datadog-agent/comp/core/diagnose/fx"
diagnoseLocal "github.com/DataDog/datadog-agent/comp/core/diagnose/local"
"github.com/DataDog/datadog-agent/comp/core/flare"
"github.com/DataDog/datadog-agent/comp/core/flare/helpers"
flare "github.com/DataDog/datadog-agent/comp/core/flare/def"
flarfx "github.com/DataDog/datadog-agent/comp/core/flare/fx"
flaretypes "github.com/DataDog/datadog-agent/comp/core/flare/types"
"github.com/DataDog/datadog-agent/comp/core/hostname/hostnameimpl"
ipc "github.com/DataDog/datadog-agent/comp/core/ipc/def"
Expand Down Expand Up @@ -135,7 +135,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
SysprobeConfigParams: sysprobeconfigimpl.NewParams(sysprobeconfigimpl.WithSysProbeConfFilePath(globalParams.SysProbeConfFilePath), sysprobeconfigimpl.WithFleetPoliciesDirPath(globalParams.FleetPoliciesDirPath)),
LogParams: log.ForOneShot(command.LoggerName, cliParams.logLevelDefaultOff.Value(), false),
}),
flare.Module(flareParams),
flarfx.Module(flareParams),
flareprofilerfx.Module(),
// workloadmeta setup
wmcatalog.GetCatalog(),
Expand Down Expand Up @@ -320,7 +320,7 @@ func makeFlare(flareComp flare.Component,
}
}

response, e := flareComp.Send(filePath, caseID, customerEmail, helpers.NewLocalFlareSource())
response, e := flareComp.Send(filePath, caseID, customerEmail, flaretypes.NewLocalFlareSource())
fmt.Println(response)
return e
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ import (
configstreamfx "github.com/DataDog/datadog-agent/comp/core/configstream/fx"
diagnose "github.com/DataDog/datadog-agent/comp/core/diagnose/def"
diagnosefx "github.com/DataDog/datadog-agent/comp/core/diagnose/fx"
"github.com/DataDog/datadog-agent/comp/core/flare"
flare "github.com/DataDog/datadog-agent/comp/core/flare/def"
flarfx "github.com/DataDog/datadog-agent/comp/core/flare/fx"
flaretypes "github.com/DataDog/datadog-agent/comp/core/flare/types"
pkgflare "github.com/DataDog/datadog-agent/pkg/flare"
guidef "github.com/DataDog/datadog-agent/comp/core/gui/def"
guifx "github.com/DataDog/datadog-agent/comp/core/gui/fx"
healthprobe "github.com/DataDog/datadog-agent/comp/core/healthprobe/def"
Expand Down Expand Up @@ -413,7 +415,8 @@ func run(log log.Component,

func getSharedFxOption() fx.Option {
return fx.Options(
flare.Module(flare.NewParams(
pkgflare.Module(),
flarfx.Module(flare.NewParams(
defaultpaths.GetDistPath(),
defaultpaths.PyChecksPath,
defaultpaths.LogFile,
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/run/command_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import (
agenttelemetry "github.com/DataDog/datadog-agent/comp/core/agenttelemetry/def"
autodiscovery "github.com/DataDog/datadog-agent/comp/core/autodiscovery/def"
"github.com/DataDog/datadog-agent/comp/core/config"
"github.com/DataDog/datadog-agent/comp/core/flare"
flare "github.com/DataDog/datadog-agent/comp/core/flare/def"
guidef "github.com/DataDog/datadog-agent/comp/core/gui/def"
"github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface/def"
ipc "github.com/DataDog/datadog-agent/comp/core/ipc/def"
Expand Down
9 changes: 5 additions & 4 deletions cmd/otel-agent/subcommands/flare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import (
"github.com/DataDog/datadog-agent/cmd/otel-agent/subcommands"
"github.com/DataDog/datadog-agent/comp/core"
"github.com/DataDog/datadog-agent/comp/core/config"
"github.com/DataDog/datadog-agent/comp/core/flare"
"github.com/DataDog/datadog-agent/comp/core/flare/helpers"
flare "github.com/DataDog/datadog-agent/comp/core/flare/def"
flarfx "github.com/DataDog/datadog-agent/comp/core/flare/fx"
flaretypes "github.com/DataDog/datadog-agent/comp/core/flare/types"
ipcfx "github.com/DataDog/datadog-agent/comp/core/ipc/fx"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
Expand Down Expand Up @@ -85,7 +86,7 @@ func MakeCommand(globalConfGetter func() *subcommands.GlobalParams) *cobra.Comma
ConfigParams: config.NewAgentParams("", config.WithConfigName(globalParams.ConfigName)),
LogParams: log.ForOneShot(globalParams.LoggerName, "info", false),
}),
flare.Module(flareParams),
flarfx.Module(flareParams),
core.Bundle(),
// Provide empty option for workloadmeta (optional dependency)
fx.Supply(option.None[workloadmeta.Component]()),
Expand Down Expand Up @@ -150,7 +151,7 @@ func makeFlare(
}

// Upload flare
response, e := flareComp.Send(filePath, caseID, customerEmail, helpers.NewLocalFlareSource())
response, e := flareComp.Send(filePath, caseID, customerEmail, flaretypes.NewLocalFlareSource())
fmt.Println(response)
return e
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/security-agent/subcommands/flare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
"github.com/DataDog/datadog-agent/cmd/security-agent/command"
"github.com/DataDog/datadog-agent/comp/core"
"github.com/DataDog/datadog-agent/comp/core/config"
"github.com/DataDog/datadog-agent/comp/core/flare/helpers"
flareimpl "github.com/DataDog/datadog-agent/comp/core/flare/impl"
flaretypes "github.com/DataDog/datadog-agent/comp/core/flare/types"
ipc "github.com/DataDog/datadog-agent/comp/core/ipc/def"
ipcfx "github.com/DataDog/datadog-agent/comp/core/ipc/fx"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
Expand Down Expand Up @@ -117,7 +118,7 @@ func requestFlare(_ log.Component, config config.Component, _ secrets.Component,
}
}

response, e := helpers.SendFlare(config, filePath, params.caseID, params.customerEmail, helpers.NewLocalFlareSource())
response, e := flareimpl.SendFlare(config, filePath, params.caseID, params.customerEmail, flaretypes.NewLocalFlareSource())
fmt.Println(response)
if e != nil {
return e
Expand Down
7 changes: 5 additions & 2 deletions cmd/systray/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"github.com/DataDog/datadog-agent/comp/core"
"github.com/DataDog/datadog-agent/comp/core/config"
diagnosefx "github.com/DataDog/datadog-agent/comp/core/diagnose/fx"
"github.com/DataDog/datadog-agent/comp/core/flare"
flare "github.com/DataDog/datadog-agent/comp/core/flare/def"
flarfx "github.com/DataDog/datadog-agent/comp/core/flare/fx"
pkgflare "github.com/DataDog/datadog-agent/pkg/flare"
"github.com/DataDog/datadog-agent/comp/core/hostname/hostnameimpl"
ipcfx "github.com/DataDog/datadog-agent/comp/core/ipc/fx"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
Expand Down Expand Up @@ -100,7 +102,8 @@ func MakeCommand() *cobra.Command {
core.Bundle(),
hostnameimpl.Module(),
// flare
flare.Module(flare.NewParams(
pkgflare.Module(),
flarfx.Module(flare.NewParams(
defaultpaths.GetDistPath(),
defaultpaths.PyChecksPath,
defaultpaths.LogFile,
Expand Down
2 changes: 1 addition & 1 deletion comp/core/diagnose/impl/diagnose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/stretchr/testify/assert"

diagnose "github.com/DataDog/datadog-agent/comp/core/diagnose/def"
flarehelpers "github.com/DataDog/datadog-agent/comp/core/flare/helpers"
flarehelpers "github.com/DataDog/datadog-agent/comp/core/flare/impl"
)

const runSuitetextresult = `=== Starting diagnose ===
Expand Down
9 changes: 8 additions & 1 deletion comp/core/flare/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# gazelle:ignore
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "flare",
srcs = ["doc.go"],
importpath = "github.com/DataDog/datadog-agent/comp/core/flare",
visibility = ["//visibility:public"],
)
43 changes: 0 additions & 43 deletions comp/core/flare/component.go

This file was deleted.

9 changes: 9 additions & 0 deletions comp/core/flare/def/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "def",
srcs = ["component.go"],
importpath = "github.com/DataDog/datadog-agent/comp/core/flare/def",
visibility = ["//visibility:public"],
deps = ["//comp/core/flare/types"],
)
80 changes: 80 additions & 0 deletions comp/core/flare/def/component.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package flare implements a component to generate flares from the agent.
//
// A flare is a archive containing all the information necessary to troubleshoot the Agent. When openeing a support
// ticket a flare might be requested. Flares contain the Agent logs, configurations and much more.
package flare

import (
"time"

"github.com/DataDog/datadog-agent/comp/core/flare/types"
)

// team: agent-configuration

// Component is the component type.
type Component interface {
// Create creates a new flare locally and returns the path to the flare file.
//
// If providerTimeout is 0 or negative, the timeout from the configuration will be used.
Create(pdata types.ProfileData, providerTimeout time.Duration, ipcError error, diagnoseResult []byte) (string, error)
// CreateWithArgs creates a new flare locally and returns the path to the flare file.
// This function is used to create a flare with specific arguments.
CreateWithArgs(flareArgs types.FlareArgs, providerTimeout time.Duration, ipcError error, diagnoseResult []byte) (string, error)
// Send sends a flare archive to Datadog. The local archive is removed after a successful upload unless the component was created with KeepArchiveAfterSend (e.g. CLI --keep-archive).
Send(flarePath string, caseID string, email string, source types.FlareSource) (string, error)
}

// Params defines the parameters for the flare component.
type Params struct {
// Local is set to true when we could not contact a running Agent and the flare is created directly from the
// CLI.
Local bool

// KeepArchiveAfterSend when true keeps the local flare archive file after a successful upload (e.g. for CLI --keep-archive).
KeepArchiveAfterSend bool

// DistPath is the fully qualified path to the 'dist' directory
DistPath string

// PythonChecksPath is the path to the python checks shipped with the agent
PythonChecksPath string

// DefaultLogFile the path to the default log file
DefaultLogFile string

// DefaultJMXLogFile the path to the default JMX log file
DefaultJMXLogFile string

// DefaultDogstatsdLogFile the path to the default dogstatsd log file
DefaultDogstatsdLogFile string

// DefaultStreamlogsLogFile the path to the default Streamlogs log file
DefaultStreamlogsLogFile string
}

// NewLocalParams returns parameters for to initialize a local flare component. Local flares are meant to be created by
// the CLI process instead of the main Agent one.
func NewLocalParams(distPath string, pythonChecksPath string, defaultLogFile string, defaultJMXLogFile string, defaultDogstatsdLogFile string, defaultStreamlogsLogFile string) Params {
p := NewParams(distPath, pythonChecksPath, defaultLogFile, defaultJMXLogFile, defaultDogstatsdLogFile, defaultStreamlogsLogFile)
p.Local = true
return p
}

// NewParams returns parameters for to initialize a non local flare component
func NewParams(distPath string, pythonChecksPath string, defaultLogFile string, defaultJMXLogFile string, defaultDogstatsdLogFile string, defaultStreamlogsLogFile string) Params {
return Params{
Local: false,
DistPath: distPath,
PythonChecksPath: pythonChecksPath,
DefaultLogFile: defaultLogFile,
DefaultJMXLogFile: defaultJMXLogFile,
DefaultDogstatsdLogFile: defaultDogstatsdLogFile,
DefaultStreamlogsLogFile: defaultStreamlogsLogFile,
}
}
8 changes: 8 additions & 0 deletions comp/core/flare/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package flare implements a component to generate flares from the agent.
// Deprecated: use comp/core/flare/def instead.
package flare
14 changes: 14 additions & 0 deletions comp/core/flare/fx/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "fx",
srcs = ["fx.go"],
importpath = "github.com/DataDog/datadog-agent/comp/core/flare/fx",
visibility = ["//visibility:public"],
deps = [
"//comp/core/flare/def",
"//comp/core/flare/impl",
"//pkg/util/fxutil",
"@org_uber_go_fx//:fx",
],
)
23 changes: 23 additions & 0 deletions comp/core/flare/fx/fx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package fx defines the fx options for the flare component.
package fx

import (
"go.uber.org/fx"

flare "github.com/DataDog/datadog-agent/comp/core/flare/def"
flareimpl "github.com/DataDog/datadog-agent/comp/core/flare/impl"
Comment thread
louis-cqrl marked this conversation as resolved.
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
)

// Module defines the fx options for this component.
func Module(params flare.Params) fxutil.Module {
return fxutil.Component(
fx.Supply(params),
fxutil.ProvideComponentConstructor(flareimpl.NewComponent),
)
}
Loading
Loading