|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// ApmDependencyStatName The APM dependency statistic to query. |
| 14 | +type ApmDependencyStatName string |
| 15 | + |
| 16 | +// List of ApmDependencyStatName. |
| 17 | +const ( |
| 18 | + APMDEPENDENCYSTATNAME_AVG_DURATION ApmDependencyStatName = "avg_duration" |
| 19 | + APMDEPENDENCYSTATNAME_AVG_ROOT_DURATION ApmDependencyStatName = "avg_root_duration" |
| 20 | + APMDEPENDENCYSTATNAME_AVG_SPANS_PER_TRACE ApmDependencyStatName = "avg_spans_per_trace" |
| 21 | + APMDEPENDENCYSTATNAME_ERROR_RATE ApmDependencyStatName = "error_rate" |
| 22 | + APMDEPENDENCYSTATNAME_PCT_EXEC_TIME ApmDependencyStatName = "pct_exec_time" |
| 23 | + APMDEPENDENCYSTATNAME_PCT_OF_TRACES ApmDependencyStatName = "pct_of_traces" |
| 24 | + APMDEPENDENCYSTATNAME_TOTAL_TRACES_COUNT ApmDependencyStatName = "total_traces_count" |
| 25 | +) |
| 26 | + |
| 27 | +var allowedApmDependencyStatNameEnumValues = []ApmDependencyStatName{ |
| 28 | + APMDEPENDENCYSTATNAME_AVG_DURATION, |
| 29 | + APMDEPENDENCYSTATNAME_AVG_ROOT_DURATION, |
| 30 | + APMDEPENDENCYSTATNAME_AVG_SPANS_PER_TRACE, |
| 31 | + APMDEPENDENCYSTATNAME_ERROR_RATE, |
| 32 | + APMDEPENDENCYSTATNAME_PCT_EXEC_TIME, |
| 33 | + APMDEPENDENCYSTATNAME_PCT_OF_TRACES, |
| 34 | + APMDEPENDENCYSTATNAME_TOTAL_TRACES_COUNT, |
| 35 | +} |
| 36 | + |
| 37 | +// GetAllowedValues reeturns the list of possible values. |
| 38 | +func (v *ApmDependencyStatName) GetAllowedValues() []ApmDependencyStatName { |
| 39 | + return allowedApmDependencyStatNameEnumValues |
| 40 | +} |
| 41 | + |
| 42 | +// UnmarshalJSON deserializes the given payload. |
| 43 | +func (v *ApmDependencyStatName) UnmarshalJSON(src []byte) error { |
| 44 | + var value string |
| 45 | + err := datadog.Unmarshal(src, &value) |
| 46 | + if err != nil { |
| 47 | + return err |
| 48 | + } |
| 49 | + *v = ApmDependencyStatName(value) |
| 50 | + return nil |
| 51 | +} |
| 52 | + |
| 53 | +// NewApmDependencyStatNameFromValue returns a pointer to a valid ApmDependencyStatName |
| 54 | +// for the value passed as argument, or an error if the value passed is not allowed by the enum. |
| 55 | +func NewApmDependencyStatNameFromValue(v string) (*ApmDependencyStatName, error) { |
| 56 | + ev := ApmDependencyStatName(v) |
| 57 | + if ev.IsValid() { |
| 58 | + return &ev, nil |
| 59 | + } |
| 60 | + return nil, fmt.Errorf("invalid value '%v' for ApmDependencyStatName: valid values are %v", v, allowedApmDependencyStatNameEnumValues) |
| 61 | +} |
| 62 | + |
| 63 | +// IsValid return true if the value is valid for the enum, false otherwise. |
| 64 | +func (v ApmDependencyStatName) IsValid() bool { |
| 65 | + for _, existing := range allowedApmDependencyStatNameEnumValues { |
| 66 | + if existing == v { |
| 67 | + return true |
| 68 | + } |
| 69 | + } |
| 70 | + return false |
| 71 | +} |
| 72 | + |
| 73 | +// Ptr returns reference to ApmDependencyStatName value. |
| 74 | +func (v ApmDependencyStatName) Ptr() *ApmDependencyStatName { |
| 75 | + return &v |
| 76 | +} |
0 commit comments