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

[service] remove deprecated Telemetry struct and New func #10285

Merged
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
25 changes: 25 additions & 0 deletions .chloggen/codeboten_rm-deprecated-telemetry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: service

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: remove deprecated Telemetry struct and New func

# One or more tracking issues or pull requests related to the change
issues: [10285]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
54 changes: 0 additions & 54 deletions service/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,8 @@
package telemetry // import "go.opentelemetry.io/collector/service/telemetry"

import (
"context"
"fmt"

sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
"go.uber.org/multierr"
"go.uber.org/zap"

"go.opentelemetry.io/collector/service/telemetry/internal"
)

// Telemetry is the service telemetry.
// Deprecated: [v0.99.0] Use Factory.
type Telemetry struct {
logger *zap.Logger
tracerProvider trace.TracerProvider
}

func (t *Telemetry) TracerProvider() trace.TracerProvider {
return t.tracerProvider
}

func (t *Telemetry) Logger() *zap.Logger {
return t.logger
}

func (t *Telemetry) Shutdown(ctx context.Context) error {
// TODO: Sync logger.
if tp, ok := t.tracerProvider.(*sdktrace.TracerProvider); ok {
return multierr.Combine(
tp.Shutdown(ctx),
)
}
// should this return an error?
return nil
}

// Settings holds configuration for building Telemetry.
type Settings = internal.CreateSettings

// New creates a new Telemetry from Config.
// Deprecated: [v0.99.0] Use NewFactory.
func New(ctx context.Context, set Settings, cfg Config) (*Telemetry, error) {
f := NewFactory()
logger, err := f.CreateLogger(ctx, set, &cfg)
if err != nil {
return nil, fmt.Errorf("failed to created logger: %w", err)
}

tracerProvider, err := f.CreateTracerProvider(ctx, set, &cfg)
if err != nil {
return nil, fmt.Errorf("failed to create tracer provider: %w", err)
}

return &Telemetry{
logger: logger,
tracerProvider: tracerProvider,
}, nil
}
26 changes: 0 additions & 26 deletions service/telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

Expand Down Expand Up @@ -122,26 +119,3 @@ func TestSampledLogger(t *testing.T) {
})
}
}

func TestTelemetryShutdown(t *testing.T) {
tests := []struct {
name string
provider trace.TracerProvider
wantErr error
}{
{
name: "No provider",
},
{
name: "Non-SDK provider",
provider: noop.NewTracerProvider(),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
telemetry := Telemetry{tracerProvider: tt.provider}
err := telemetry.Shutdown(context.Background())
require.Equal(t, tt.wantErr, err)
})
}
}
Loading