2017-08-23 11:36:49 +03:00
|
|
|
package contracts
|
|
|
|
|
|
|
|
// NOTE: This file was automatically generated.
|
|
|
|
|
|
|
|
// Instances of Event represent structured event records that can be grouped
|
|
|
|
// and searched by their properties. Event data item also creates a metric of
|
|
|
|
// event count by name.
|
|
|
|
type EventData struct {
|
|
|
|
Domain
|
|
|
|
|
|
|
|
// Schema version
|
|
|
|
Ver int `json:"ver"`
|
|
|
|
|
|
|
|
// Event name. Keep it low cardinality to allow proper grouping and useful
|
|
|
|
// metrics.
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
|
|
// Collection of custom properties.
|
2017-08-26 11:38:32 +03:00
|
|
|
Properties map[string]string `json:"properties,omitempty"`
|
2017-08-23 11:36:49 +03:00
|
|
|
|
|
|
|
// Collection of custom measurements.
|
2017-08-26 11:38:32 +03:00
|
|
|
Measurements map[string]float64 `json:"measurements,omitempty"`
|
2017-08-23 11:36:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the name used when this is embedded within an Envelope container.
|
|
|
|
func (data *EventData) EnvelopeName() string {
|
|
|
|
return "Microsoft.ApplicationInsights.Event"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the base type when placed within a Data object container.
|
|
|
|
func (data *EventData) BaseType() string {
|
|
|
|
return "EventData"
|
|
|
|
}
|
2017-08-25 10:58:59 +03:00
|
|
|
|
2017-11-22 11:04:51 +03:00
|
|
|
// Truncates string fields that exceed their maximum supported sizes for this
|
|
|
|
// object and all objects it references. Returns a warning for each affected
|
|
|
|
// field.
|
2017-11-20 06:30:20 +03:00
|
|
|
func (data *EventData) Sanitize() []string {
|
|
|
|
var warnings []string
|
|
|
|
|
|
|
|
if len(data.Name) > 512 {
|
|
|
|
data.Name = data.Name[:512]
|
|
|
|
warnings = append(warnings, "EventData.Name exceeded maximum length of 512")
|
|
|
|
}
|
|
|
|
|
|
|
|
if data.Properties != nil {
|
|
|
|
for k, v := range data.Properties {
|
|
|
|
if len(v) > 8192 {
|
|
|
|
data.Properties[k] = v[:8192]
|
|
|
|
warnings = append(warnings, "EventData.Properties has value with length exceeding max of 8192: "+k)
|
|
|
|
}
|
|
|
|
if len(k) > 150 {
|
|
|
|
data.Properties[k[:150]] = data.Properties[k]
|
|
|
|
delete(data.Properties, k)
|
|
|
|
warnings = append(warnings, "EventData.Properties has key with length exceeding max of 150: "+k)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if data.Measurements != nil {
|
|
|
|
for k, v := range data.Measurements {
|
|
|
|
if len(k) > 150 {
|
|
|
|
data.Measurements[k[:150]] = v
|
|
|
|
delete(data.Measurements, k)
|
|
|
|
warnings = append(warnings, "EventData.Measurements has key with length exceeding max of 150: "+k)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return warnings
|
|
|
|
}
|
|
|
|
|
2017-08-25 10:58:59 +03:00
|
|
|
// Creates a new EventData instance with default values set by the schema.
|
|
|
|
func NewEventData() *EventData {
|
|
|
|
return &EventData{
|
2017-11-20 06:30:20 +03:00
|
|
|
Ver: 2,
|
2017-08-25 10:58:59 +03:00
|
|
|
}
|
|
|
|
}
|