Documentation
¶
Index ¶
- func DatasetPtr(dataset string) *string
- func HandleAPIError(err error, ctx ...ErrorContext) error
- func NewClientFromContext(ctx context.Context, apiUrl, authToken string) (dash0api.Client, error)
- func NewOtlpClientFromContext(ctx context.Context, otlpUrl, authToken string) (dash0api.Client, error)
- func ResolveDataset(ctx context.Context, flagDataset string) *string
- type ErrorContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatasetPtr ¶
DatasetPtr converts a dataset string to a pointer, returning nil for empty strings and for "default" (the API uses "default" implicitly when no dataset parameter is sent).
func HandleAPIError ¶
func HandleAPIError(err error, ctx ...ErrorContext) error
HandleAPIError provides user-friendly error messages for API errors. It checks for common error types and returns descriptive messages. Optional context can be provided to include asset details in error messages.
func NewClientFromContext ¶
NewClientFromContext creates a new Dash0 API client using configuration from context. Flag overrides (apiUrl, authToken) are applied on top of the context configuration.
func NewOtlpClientFromContext ¶ added in v1.1.0
func NewOtlpClientFromContext(ctx context.Context, otlpUrl, authToken string) (dash0api.Client, error)
NewOtlpClientFromContext creates a new Dash0 API client configured for OTLP using configuration from context. Flag overrides (otlpUrl, authToken) are applied on top of the context configuration.
func ResolveDataset ¶ added in v1.1.0
ResolveDataset returns the dataset to use for API calls, checking (in order): 1. The CLI flag value (flagDataset) 2. The configuration from context (profile + DASH0_DATASET env var) Returns nil when no dataset is configured or when the dataset is "default", since the API uses "default" implicitly when no dataset parameter is sent.
Types ¶
type ErrorContext ¶
type ErrorContext struct {
AssetType string // e.g., "dashboard", "check rule"
AssetID string // e.g., "a1b2c3d4-..." (optional, empty for create/list)
AssetName string // e.g., "Production Overview" (optional, for user-friendly messages)
}
ErrorContext provides context about the asset involved in an error. This context is used to generate more specific and actionable error messages.