forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.go
More file actions
67 lines (54 loc) · 2.33 KB
/
extension.go
File metadata and controls
67 lines (54 loc) · 2.33 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package azureencodingextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/azureencodingextension"
import (
"context"
"errors"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/azureencodingextension/internal/metadata"
)
var (
_ encoding.TracesUnmarshalerExtension = (*azureExtension)(nil)
_ encoding.LogsUnmarshalerExtension = (*azureExtension)(nil)
_ encoding.MetricsUnmarshalerExtension = (*azureExtension)(nil)
)
type azureExtension struct {
config *Config
logger *zap.Logger
logUnmarshaler plog.Unmarshaler
traceUnmarshaler ptrace.Unmarshaler
metricUnmarshaler pmetric.Unmarshaler
}
func (ex *azureExtension) UnmarshalTraces(buf []byte) (ptrace.Traces, error) {
return ex.traceUnmarshaler.UnmarshalTraces(buf)
}
func (ex *azureExtension) UnmarshalLogs(buf []byte) (plog.Logs, error) {
return ex.logUnmarshaler.UnmarshalLogs(buf)
}
func (ex *azureExtension) UnmarshalMetrics(buf []byte) (pmetric.Metrics, error) {
return ex.metricUnmarshaler.UnmarshalMetrics(buf)
}
func (ex *azureExtension) Start(_ context.Context, _ component.Host) error {
if metadata.ExtensionAzureencodingDontEmitV0LogConventionsFeatureGate.IsEnabled() &&
!metadata.ExtensionAzureencodingEmitV1LogConventionsFeatureGate.IsEnabled() {
err := errors.New("extension.azureencoding.DontEmitV0LogConventions cannot be enabled without enabling extension.azureencoding.EmitV1LogConventions")
ex.logger.Error("Invalid feature gate combination", zap.Error(err))
return err
}
if !metadata.ExtensionAzureencodingDontEmitV0LogConventionsFeatureGate.IsEnabled() {
ex.logger.Warn(
"[WARNING] Azure encoding logs currently emit legacy semconv attributes. " +
"To opt in to v1 semconv attributes, enable extension.azureencoding.EmitV1LogConventions and " +
"extension.azureencoding.DontEmitV0LogConventions feature gates.",
)
}
return nil
}
func (*azureExtension) Shutdown(context.Context) error {
return nil
}