azureresourcelogs_unmarshaler.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package azureeventhubreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azureeventhubreceiver"
  4. import (
  5. eventhub "github.com/Azure/azure-event-hubs-go/v3"
  6. "go.opentelemetry.io/collector/component"
  7. "go.opentelemetry.io/collector/pdata/plog"
  8. "go.uber.org/zap"
  9. "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/azure"
  10. )
  11. type AzureResourceLogsEventUnmarshaler struct {
  12. unmarshaler *azure.ResourceLogsUnmarshaler
  13. }
  14. func newAzureResourceLogsUnmarshaler(buildInfo component.BuildInfo, logger *zap.Logger) eventLogsUnmarshaler {
  15. return AzureResourceLogsEventUnmarshaler{
  16. unmarshaler: &azure.ResourceLogsUnmarshaler{
  17. Version: buildInfo.Version,
  18. Logger: logger,
  19. },
  20. }
  21. }
  22. // UnmarshalLogs takes a byte array containing a JSON-encoded
  23. // payload with Azure log records and transforms it into
  24. // an OpenTelemetry plog.Logs object. The data in the Azure
  25. // log record appears as fields and attributes in the
  26. // OpenTelemetry representation; the bodies of the
  27. // OpenTelemetry log records are empty.
  28. func (r AzureResourceLogsEventUnmarshaler) UnmarshalLogs(event *eventhub.Event) (plog.Logs, error) {
  29. return r.unmarshaler.UnmarshalLogs(event.Data)
  30. }