-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
azureresourcetraces_unmarshaler.go
executable file
·37 lines (31 loc) · 1.3 KB
/
azureresourcetraces_unmarshaler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package azureeventhubreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azureeventhubreceiver"
import (
eventhub "github.com/Azure/azure-event-hubs-go/v3"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/azure"
)
type azureTracesEventUnmarshaler struct {
unmarshaler *azure.TracesUnmarshaler
}
func newAzureTracesUnmarshaler(buildInfo component.BuildInfo, logger *zap.Logger, timeFormat []string) eventTracesUnmarshaler {
return azureTracesEventUnmarshaler{
unmarshaler: &azure.TracesUnmarshaler{
Version: buildInfo.Version,
Logger: logger,
TimeFormats: timeFormat,
},
}
}
// UnmarshalTraces takes a byte array containing a JSON-encoded
// payload with Azure records and transforms it into
// an OpenTelemetry ptraces.traces object. The data in the Azure
// record appears as fields and attributes in the
// OpenTelemetry representation; the bodies of the
// OpenTelemetry trace records are empty.
func (r azureTracesEventUnmarshaler) UnmarshalTraces(event *eventhub.Event) (ptrace.Traces, error) {
return r.unmarshaler.UnmarshalTraces(event.Data)
}