|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed |
| 2 | +// under the Apache License Version 2.0. |
| 3 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 4 | +// Copyright 2016-present Datadog, Inc. |
| 5 | + |
| 6 | +// Package flare defines the flare component interface and its parameters. |
| 7 | +package flare |
| 8 | + |
| 9 | +import ( |
| 10 | + "time" |
| 11 | + |
| 12 | + "github.com/DataDog/datadog-agent/comp/core/flare/types" |
| 13 | +) |
| 14 | + |
| 15 | +// team: agent-configuration |
| 16 | + |
| 17 | +// Component is the component type. |
| 18 | +type Component interface { |
| 19 | + // Create creates a new flare locally and returns the path to the flare file. |
| 20 | + // |
| 21 | + // If providerTimeout is 0 or negative, the timeout from the configuration will be used. |
| 22 | + Create(pdata types.ProfileData, providerTimeout time.Duration, ipcError error, diagnoseResult []byte) (string, error) |
| 23 | + // CreateWithArgs creates a new flare locally and returns the path to the flare file. |
| 24 | + // This function is used to create a flare with specific arguments. |
| 25 | + CreateWithArgs(flareArgs types.FlareArgs, providerTimeout time.Duration, ipcError error, diagnoseResult []byte) (string, error) |
| 26 | + // 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). |
| 27 | + Send(flarePath string, caseID string, email string, source types.FlareSource) (string, error) |
| 28 | +} |
| 29 | + |
| 30 | +// Params defines the parameters for the flare component. |
| 31 | +type Params struct { |
| 32 | + // local is set to true when we could not contact a running Agent and the flare is created directly from the |
| 33 | + // CLI. |
| 34 | + Local bool |
| 35 | + |
| 36 | + // KeepArchiveAfterSend when true keeps the local flare archive file after a successful upload (e.g. for CLI --keep-archive). |
| 37 | + KeepArchiveAfterSend bool |
| 38 | + |
| 39 | + // DistPath is the fully qualified path to the 'dist' directory |
| 40 | + DistPath string |
| 41 | + |
| 42 | + // PythonChecksPath is the path to the python checks shipped with the agent |
| 43 | + PythonChecksPath string |
| 44 | + |
| 45 | + // DefaultLogFile the path to the default log file |
| 46 | + DefaultLogFile string |
| 47 | + |
| 48 | + // DefaultJMXLogFile the path to the default JMX log file |
| 49 | + DefaultJMXLogFile string |
| 50 | + |
| 51 | + // DefaultDogstatsdLogFile the path to the default dogstatsd log file |
| 52 | + DefaultDogstatsdLogFile string |
| 53 | + |
| 54 | + // DefaultStreamlogsLogFile the path to the default Streamlogs log file |
| 55 | + DefaultStreamlogsLogFile string |
| 56 | +} |
| 57 | + |
| 58 | +// NewLocalParams returns parameters to initialize a local flare component. Local flares are meant to be created by |
| 59 | +// the CLI process instead of the main Agent one. |
| 60 | +func NewLocalParams(distPath string, pythonChecksPath string, defaultLogFile string, defaultJMXLogFile string, defaultDogstatsdLogFile string, defaultStreamlogsLogFile string) Params { |
| 61 | + p := NewParams(distPath, pythonChecksPath, defaultLogFile, defaultJMXLogFile, defaultDogstatsdLogFile, defaultStreamlogsLogFile) |
| 62 | + p.Local = true |
| 63 | + return p |
| 64 | +} |
| 65 | + |
| 66 | +// NewParams returns parameters to initialize a non local flare component. |
| 67 | +func NewParams(distPath string, pythonChecksPath string, defaultLogFile string, defaultJMXLogFile string, defaultDogstatsdLogFile string, defaultStreamlogsLogFile string) Params { |
| 68 | + return Params{ |
| 69 | + Local: false, |
| 70 | + DistPath: distPath, |
| 71 | + PythonChecksPath: pythonChecksPath, |
| 72 | + DefaultLogFile: defaultLogFile, |
| 73 | + DefaultJMXLogFile: defaultJMXLogFile, |
| 74 | + DefaultDogstatsdLogFile: defaultDogstatsdLogFile, |
| 75 | + DefaultStreamlogsLogFile: defaultStreamlogsLogFile, |
| 76 | + } |
| 77 | +} |
0 commit comments