Skip to content

Commit

Permalink
Fix linter complaints and cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoog committed Jun 28, 2024
1 parent 000fbe7 commit 591ddde
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 58 deletions.
3 changes: 2 additions & 1 deletion x-pack/filebeat/input/azureeventhub/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"

"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/monitoring"
"github.com/stretchr/testify/assert"
)

func TestDecodeRecords(t *testing.T) {
Expand Down
56 changes: 1 addition & 55 deletions x-pack/filebeat/input/azureeventhub/v1_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (in *eventHubInputV1) processEvents(event *eventhub.Event) {
processingStartTime := time.Now()
eventHubMetadata := mapstr.M{
// The `partition_id` is not available in the
// current version of the SDK.
// legacy version of the SDK.
"eventhub": in.config.EventHubName,
"consumer_group": in.config.ConsumerGroup,
}
Expand Down Expand Up @@ -298,60 +298,6 @@ func stripConnectionString(c string) string {
return "(redacted)"
}

//// unpackRecords will try to split the message into multiple ones based on the group field provided by the configuration
//func (in *eventHubInputV1) unpackRecords(bMessage []byte) []string {
// var mapObject map[string][]interface{}
// var messages []string
//
// // Clean up the message for known issues [1] where Azure services produce malformed JSON documents.
// // Sanitization occurs if options are available and the message contains an invalid JSON.
// //
// // [1]: https://learn.microsoft.com/en-us/answers/questions/1001797/invalid-json-logs-produced-for-function-apps
// if len(in.config.SanitizeOptions) != 0 && !json.Valid(bMessage) {
// bMessage = sanitize(bMessage, in.config.SanitizeOptions...)
// in.metrics.sanitizedMessages.Inc()
// }
//
// // check if the message is a "records" object containing a list of events
// err := json.Unmarshal(bMessage, &mapObject)
// if err == nil {
// if len(mapObject[expandEventListFromField]) > 0 {
// for _, ms := range mapObject[expandEventListFromField] {
// js, err := json.Marshal(ms)
// if err == nil {
// messages = append(messages, string(js))
// in.metrics.receivedEvents.Inc()
// } else {
// in.log.Errorw(fmt.Sprintf("serializing message %s", ms), "error", err)
// }
// }
// }
// } else {
// in.log.Debugf("deserializing multiple messages to a `records` object returning error: %s", err)
// // in some cases the message is an array
// var arrayObject []interface{}
// err = json.Unmarshal(bMessage, &arrayObject)
// if err != nil {
// // return entire message
// in.log.Debugf("deserializing multiple messages to an array returning error: %s", err)
// in.metrics.decodeErrors.Inc()
// return []string{string(bMessage)}
// }
//
// for _, ms := range arrayObject {
// js, err := json.Marshal(ms)
// if err == nil {
// messages = append(messages, string(js))
// in.metrics.receivedEvents.Inc()
// } else {
// in.log.Errorw(fmt.Sprintf("serializing message %s", ms), "error", err)
// }
// }
// }
//
// return messages
//}

func getAzureEnvironment(overrideResManager string) (azure.Environment, error) {
// if no override is set then the azure public cloud is used
if overrideResManager == "" || overrideResManager == "<no value>" {
Expand Down
6 changes: 4 additions & 2 deletions x-pack/filebeat/input/azureeventhub/v2_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
"net/url"
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"

"github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"

"github.com/elastic/elastic-agent-libs/logp"
)

Expand Down

0 comments on commit 591ddde

Please sign in to comment.