### Full Exceptionless Event Building Example (Go) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Demonstrates the process of building a comprehensive Exceptionless event by chaining multiple enrichment functions. This example shows how to add source, tags, geo-location, value, reference ID, count, and custom data before submitting the event. ```go var event Event referenceID := uuid.Must(uuid.NewV4()) date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("error", "testing", date) event = exceptionless.AddSource(event, "line 206 app.js") event = exceptionless.AddTags(event, []string{"one", "two", "three"}) event = exceptionless.AddGeo(event, "44.14561, -172.32262") event = exceptionless.AddValue(event, 21) event = exceptionless.AddReferenceID(event, referenceID) event = exceptionless.AddCount(event, 99) data := map[string]interface{}{} data["custom_key"] = "custom string value" event = exceptionless.AddData(event, data) json, err := json.Marshal(event) if err != nil { fmt.Println(err) } resp := exceptionless.SubmitEvent(string(json)) if resp == "" { fmt.Println("Test failed") } ``` -------------------------------- ### Get Base Event for Custom Event Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Creates a base event object required for building custom events. It takes event type, message, and a timestamp as arguments. ```go import ( "time" "github.com/Exceptionless/Exceptionless.Go" ) var event exceptionless.Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) ``` -------------------------------- ### Import Exceptionless Go Client Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Demonstrates how to import the Exceptionless Go client library into your project. This is a prerequisite for using the client's functionalities. ```go import ( "github.com/Exceptionless/Exceptionless.Go" ) ``` -------------------------------- ### Configure Exceptionless Client (Struct) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Illustrates configuring the Exceptionless client by creating a configuration struct and passing it to the Configure function. This method allows setting multiple configuration options simultaneously. ```go config := exceptionless.Exceptionless{ ApiKey: "YOUR API KEY", ServerURL: "OPTIONAL SELF HOSTED URL", } exceptionless.Configure(config) ``` -------------------------------- ### Configure Exceptionless Client (Direct Property) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Shows how to set the API key directly on the globally accessible ExceptionlessClient instance. This is a straightforward method for client configuration. ```go exceptionless.ExceptionlessClient.ApiKey = "YOUR API KEY" ``` -------------------------------- ### Exceptionless Event Data Model (JSON) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Provides a reference schema for the structure of an Exceptionless event. It details common fields like type, source, reference_id, message, geo, date, value, and tags, as well as the flexible 'data' object which can contain nested structures like user information or stack traces. ```json { "type": "error", "source": "Website", "reference_id": "123", "message": "some event message", "geo": "latitude}, longitude", "date":"2030-01-01T12:00:00.0000000-05:00", "data": { "@ref": { "id": "parent event reference id", "name": "parent event reference name" }, "@user": { "identity": "email or something", "name": "John Doe", "data": "Anything we want" }, "@user_description": { "email_address": "email", "description": "super cool user", "data": "Anything we want" }, "@stack": { "signature_data": { "ManualStackingKey": "manual key we set" }, "title": "stack title" } }, "value": "some number", "tags": ["string", "string", "string"] } ``` -------------------------------- ### Submit Exceptionless Event (Go) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Submits a fully constructed Exceptionless event to the Exceptionless service. This function typically takes the event, often marshaled into a JSON string, as input. It returns a response string. ```go json, err := json.Marshal(event) if err != nil { fmt.Println(err) } resp := exceptionless.SubmitEvent(string(json)) ``` -------------------------------- ### Add Source to Exceptionless Event Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Adds source location information to an existing Exceptionless event. This helps in pinpointing where an event occurred within the application. ```go import ( "time" "github.com/Exceptionless/Exceptionless.Go" ) var event exceptionless.Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) event = exceptionless.AddSource(event, "line 66 main.go") ``` -------------------------------- ### Submit Log Event with Exceptionless Go Client Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Submits a log message with a specified log level to Exceptionless. This function is a simple wrapper for sending log events and returns a string response. ```go import ( "fmt" "github.com/Exceptionless/Exceptionless.Go" ) func MyGoFunction() { message := "Info log!" level := "info" resp := exceptionless.SubmitLog(message, level) fmt.Println(resp) } ``` -------------------------------- ### Add Custom Data to Exceptionless Event (Go) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Enriches an Exceptionless event with custom key-value data using a string map. This allows for flexible data submission. The function takes the event and a map[string]interface{} as arguments. Certain keys are recognized as first-class citizens by Exceptionless. ```go var event Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) data := map[string]interface{}{} data["custom_key"] = "custom string value" exceptionless.AddData(event, data) ``` -------------------------------- ### Submit Error Event with Exceptionless Go Client Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Submits a Go error type as an event to Exceptionless. This convenience function simplifies sending basic error information and returns a string response. ```go import ( "errors" "fmt" "github.com/Exceptionless/Exceptionless.Go" ) func MyGoFunction() { e := errors.New(fmt.Sprintf("This is an error")) resp := exceptionless.SubmitError(e) fmt.Println(resp) } ``` -------------------------------- ### Add Tags to Exceptionless Event Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Appends a string array of tags to an Exceptionless event. Tags are useful for filtering and categorizing events within the Exceptionless platform. ```go import ( "time" "github.com/Exceptionless/Exceptionless.Go" ) var event exceptionless.Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) event = exceptionless.AddTags(event, []string{"one", "two", "three"}) ``` -------------------------------- ### Add Log Level to Exceptionless Event (Go) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Applies a log level string to log-type Exceptionless events, aiding in filtering and categorization. The function accepts the event and a string representing the log level, such as 'info' or 'error'. ```go var event Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) event = exceptionless.AddLogLevel(event, "info") ``` -------------------------------- ### Add Geo Location to Exceptionless Event Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Adds geographical location data (latitude and longitude) to an Exceptionless event. This enriches events with user location information. ```go import ( "time" "github.com/Exceptionless/Exceptionless.Go" ) var event exceptionless.Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) event = exceptionless.AddGeo(event, "44.14561, -172.32262") ``` -------------------------------- ### Add Count to Exceptionless Event (Go) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Adds an integer count to an Exceptionless event, facilitating the tracking of occurrences. This function takes the event and the count value as input. The count is directly added to the event data. ```go var event Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) event = exceptionless.AddCount(event, 99) ``` -------------------------------- ### Add Integer Value to Exceptionless Event (Go) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Adds an arbitrary integer value to an Exceptionless event. This function is useful for tracking numerical data associated with an event. It takes the current event and the integer value as arguments. ```go var event Event date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) event = exceptionless.AddValue(event, 21) ``` -------------------------------- ### Add Reference ID to Exceptionless Event (Go) Source: https://github.com/exceptionless/exceptionless.go/blob/main/README.md Adds a unique UUID reference ID to an Exceptionless event, allowing for later identification. Note that SubmitEvent and SubmitLog helpers automatically generate a referenceID. The function requires the event and a UUID type referenceID. ```go var event Event referenceID := uuid.Must(uuid.NewV4()) date := time.Now().Format(time.RFC3339) event = exceptionless.GetBaseEvent("log", "test log", date) event = exceptionless.AddReferenceID(event, referenceID) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.