Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add TelemetryCreateSettings #3984

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions component/componenttest/nop_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package componenttest
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenthelper"
"go.opentelemetry.io/collector/config"
Expand All @@ -29,9 +26,8 @@ import (
// NewNopExporterCreateSettings returns a new nop settings for Create*Exporter functions.
func NewNopExporterCreateSettings() component.ExporterCreateSettings {
return component.ExporterCreateSettings{
Logger: zap.NewNop(),
TracerProvider: trace.NewNoopTracerProvider(),
BuildInfo: component.DefaultBuildInfo(),
TelemetryCreateSettings: NewNopTelemetryCreateSettings(),
BuildInfo: component.DefaultBuildInfo(),
}
}

Expand Down
8 changes: 2 additions & 6 deletions component/componenttest/nop_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package componenttest
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenthelper"
"go.opentelemetry.io/collector/config"
Expand All @@ -28,9 +25,8 @@ import (
// NewNopExtensionCreateSettings returns a new nop settings for Create*Extension functions.
func NewNopExtensionCreateSettings() component.ExtensionCreateSettings {
return component.ExtensionCreateSettings{
Logger: zap.NewNop(),
TracerProvider: trace.NewNoopTracerProvider(),
BuildInfo: component.DefaultBuildInfo(),
TelemetryCreateSettings: NewNopTelemetryCreateSettings(),
BuildInfo: component.DefaultBuildInfo(),
}
}

Expand Down
8 changes: 2 additions & 6 deletions component/componenttest/nop_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package componenttest
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenthelper"
"go.opentelemetry.io/collector/config"
Expand All @@ -30,9 +27,8 @@ import (
// NewNopProcessorCreateSettings returns a new nop settings for Create*Processor functions.
func NewNopProcessorCreateSettings() component.ProcessorCreateSettings {
return component.ProcessorCreateSettings{
Logger: zap.NewNop(),
TracerProvider: trace.NewNoopTracerProvider(),
BuildInfo: component.DefaultBuildInfo(),
TelemetryCreateSettings: NewNopTelemetryCreateSettings(),
BuildInfo: component.DefaultBuildInfo(),
}
}

Expand Down
8 changes: 2 additions & 6 deletions component/componenttest/nop_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package componenttest
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenthelper"
"go.opentelemetry.io/collector/config"
Expand All @@ -29,9 +26,8 @@ import (
// NewNopReceiverCreateSettings returns a new nop settings for Create*Receiver functions.
func NewNopReceiverCreateSettings() component.ReceiverCreateSettings {
return component.ReceiverCreateSettings{
Logger: zap.NewNop(),
TracerProvider: trace.NewNoopTracerProvider(),
BuildInfo: component.DefaultBuildInfo(),
TelemetryCreateSettings: NewNopTelemetryCreateSettings(),
BuildInfo: component.DefaultBuildInfo(),
}
}

Expand Down
30 changes: 30 additions & 0 deletions component/componenttest/nop_telemetry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package componenttest

import (
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
)

// NewNopTelemetryCreateSettings returns a new nop telemetry settings for Create* functions.
func NewNopTelemetryCreateSettings() component.TelemetryCreateSettings {
return component.TelemetryCreateSettings{
Logger: zap.NewNop(),
TracerProvider: trace.NewNoopTracerProvider(),
}
}
10 changes: 1 addition & 9 deletions component/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package component
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
)
Expand Down Expand Up @@ -49,12 +46,7 @@ type LogsExporter interface {

// ExporterCreateSettings configures Exporter creators.
type ExporterCreateSettings struct {
// Logger that the factory can use during creation and can pass to the created
// component to be used later as well.
Logger *zap.Logger

// TracerProvider that the factory can pass to other instrumented third-party libraries.
TracerProvider trace.TracerProvider
TelemetryCreateSettings

// BuildInfo can be used by components for informational purposes
BuildInfo BuildInfo
Expand Down
10 changes: 1 addition & 9 deletions component/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package component
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/config"
)

Expand Down Expand Up @@ -49,12 +46,7 @@ type PipelineWatcher interface {

// ExtensionCreateSettings is passed to ExtensionFactory.Create* functions.
type ExtensionCreateSettings struct {
// Logger that the factory can use during creation and can pass to the created
// component to be used later as well.
Logger *zap.Logger

// TracerProvider that the factory can pass to other instrumented third-party libraries.
TracerProvider trace.TracerProvider
TelemetryCreateSettings

// BuildInfo can be used by components for informational purposes
BuildInfo BuildInfo
Expand Down
10 changes: 1 addition & 9 deletions component/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package component
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
Expand Down Expand Up @@ -51,12 +48,7 @@ type LogsProcessor interface {

// ProcessorCreateSettings is passed to Create* functions in ProcessorFactory.
type ProcessorCreateSettings struct {
// Logger that the factory can use during creation and can pass to the created
// component to be used later as well.
Logger *zap.Logger

// TracerProvider that the factory can pass to other instrumented third-party libraries.
TracerProvider trace.TracerProvider
TelemetryCreateSettings

// BuildInfo can be used by components for informational purposes
BuildInfo BuildInfo
Expand Down
10 changes: 1 addition & 9 deletions component/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package component
import (
"context"

"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
)
Expand Down Expand Up @@ -58,12 +55,7 @@ type LogsReceiver interface {

// ReceiverCreateSettings configures Receiver creators.
type ReceiverCreateSettings struct {
// Logger that the factory can use during creation and can pass to the created
// component to be used later as well.
Logger *zap.Logger

// TracerProvider that the factory can pass to other instrumented third-party libraries.
TracerProvider trace.TracerProvider
TelemetryCreateSettings

// BuildInfo can be used by components for informational purposes.
BuildInfo BuildInfo
Expand Down
29 changes: 29 additions & 0 deletions component/telemetry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package component

import (
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
)

type TelemetryCreateSettings struct {
// Logger that the factory can use during creation and can pass to the created
// component to be used later as well.
Logger *zap.Logger

// TracerProvider that the factory can pass to other instrumented third-party libraries.
TracerProvider trace.TracerProvider
}
8 changes: 5 additions & 3 deletions service/internal/builder/exporters_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ func BuildExporters(
// Build exporters exporters based on configuration and required input data types.
for expID, expCfg := range cfg.Exporters {
set := component.ExporterCreateSettings{
Logger: logger.With(zap.String(zapNameKey, expID.String())),
TracerProvider: tracerProvider,
BuildInfo: buildInfo,
TelemetryCreateSettings: component.TelemetryCreateSettings{
Logger: logger.With(zap.String(zapNameKey, expID.String())),
TracerProvider: tracerProvider,
},
BuildInfo: buildInfo,
}

factory, exists := factories[expID.Type()]
Expand Down
12 changes: 7 additions & 5 deletions service/internal/builder/extensions_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ func BuildExtensions(
}

set := component.ExtensionCreateSettings{
Logger: logger.With(
zap.String(zapKindKey, zapKindExtension),
zap.String(zapNameKey, extID.String())),
TracerProvider: tracerProvider,
BuildInfo: buildInfo,
TelemetryCreateSettings: component.TelemetryCreateSettings{
Logger: logger.With(
zap.String(zapKindKey, zapKindExtension),
zap.String(zapNameKey, extID.String())),
TracerProvider: tracerProvider,
},
BuildInfo: buildInfo,
}
ext, err := buildExtension(context.Background(), factory, set, extCfg)
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions service/internal/builder/pipelines_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ func (pb *pipelinesBuilder) buildPipeline(ctx context.Context, pipelineCfg *conf
// which we will build in the next loop iteration).
var err error
set := component.ProcessorCreateSettings{
Logger: pb.logger.With(zap.String(zapKindKey, zapKindProcessor), zap.String(zapNameKey, procID.String())),
TracerProvider: pb.tracerProvider,
BuildInfo: pb.buildInfo,
TelemetryCreateSettings: component.TelemetryCreateSettings{
Logger: pb.logger.With(zap.String(zapKindKey, zapKindProcessor), zap.String(zapNameKey, procID.String())),
TracerProvider: pb.tracerProvider,
},
BuildInfo: pb.buildInfo,
}

switch pipelineCfg.InputType {
Expand Down
8 changes: 5 additions & 3 deletions service/internal/builder/receivers_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ func BuildReceivers(
receivers := make(Receivers)
for recvID, recvCfg := range cfg.Receivers {
set := component.ReceiverCreateSettings{
Logger: logger.With(zap.String(zapKindKey, zapKindReceiver), zap.String(zapNameKey, recvID.String())),
TracerProvider: tracerProvider,
BuildInfo: buildInfo,
TelemetryCreateSettings: component.TelemetryCreateSettings{
Logger: logger.With(zap.String(zapKindKey, zapKindReceiver), zap.String(zapNameKey, recvID.String())),
TracerProvider: tracerProvider,
},
BuildInfo: buildInfo,
}

rcv, err := rb.buildReceiver(context.Background(), set, recvCfg)
Expand Down