Skip to content

Commit

Permalink
Change Host to not implement GetExportersWithSignal (open-telemetry#1…
Browse files Browse the repository at this point in the history
…1444)

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Oct 14, 2024
1 parent 65dcab1 commit a7d019f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 46 deletions.
25 changes: 25 additions & 0 deletions .chloggen/GetExportersWithSignal.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: Change Host to not implement GetExportersWithSignal

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

# (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: Use Host.GetExporters if still needed.

# 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: [api]
19 changes: 0 additions & 19 deletions service/internal/graph/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ type getExporters interface {
GetExporters() map[pipeline.Signal]map[component.ID]component.Component
}

// TODO: remove as part of https://github.com/open-telemetry/opentelemetry-collector/issues/7370 for service 1.0
//
// nolint
type getExportersWithSignal interface {
GetExportersWithSignal() map[pipeline.Signal]map[component.ID]component.Component
}

var _ getExporters = (*Host)(nil)
var _ getExportersWithSignal = (*Host)(nil)
var _ component.Host = (*Host)(nil)

type Host struct {
Expand Down Expand Up @@ -85,17 +77,6 @@ func (host *Host) GetExporters() map[pipeline.Signal]map[component.ID]component.
return host.Pipelines.GetExporters()
}

// Deprecated: [0.79.0] This function will be removed in the future.
// Several components in the contrib repository use this function so it cannot be removed
// before those cases are removed. In most cases, use of this function can be replaced by a
// connector. See https://github.com/open-telemetry/opentelemetry-collector/issues/7370 and
// https://github.com/open-telemetry/opentelemetry-collector/pull/7390#issuecomment-1483710184
// for additional information.
// If you still need this, use GetExporters instead.
func (host *Host) GetExportersWithSignal() map[pipeline.Signal]map[component.ID]component.Component {
return host.Pipelines.GetExporters()
}

func (host *Host) NotifyComponentStatusChange(source *componentstatus.InstanceID, event *componentstatus.Event) {
host.ServiceExtensions.NotifyComponentStatusChange(source, event)
if event.Status() == componentstatus.StatusFatalError {
Expand Down
27 changes: 0 additions & 27 deletions service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,33 +246,6 @@ func TestServiceGetExporters(t *testing.T) {
assert.Contains(t, expMap[pipelineprofiles.SignalProfiles], component.NewID(nopType))
}

func TestServiceGetExportersWithSignal(t *testing.T) {
srv, err := New(context.Background(), newNopSettings(), newNopConfig())
require.NoError(t, err)

assert.NoError(t, srv.Start(context.Background()))
t.Cleanup(func() {
assert.NoError(t, srv.Shutdown(context.Background()))
})

// nolint
expMap := srv.host.GetExportersWithSignal()

v, ok := expMap[pipeline.SignalTraces]
assert.True(t, ok)
assert.NotNil(t, v)

assert.Len(t, expMap, 4)
assert.Len(t, expMap[pipeline.SignalTraces], 1)
assert.Contains(t, expMap[pipeline.SignalTraces], component.NewID(nopType))
assert.Len(t, expMap[pipeline.SignalMetrics], 1)
assert.Contains(t, expMap[pipeline.SignalMetrics], component.NewID(nopType))
assert.Len(t, expMap[pipeline.SignalLogs], 1)
assert.Contains(t, expMap[pipeline.SignalLogs], component.NewID(nopType))
assert.Len(t, expMap[pipelineprofiles.SignalProfiles], 1)
assert.Contains(t, expMap[pipelineprofiles.SignalProfiles], component.NewID(nopType))
}

// TestServiceTelemetryCleanupOnError tests that if newService errors due to an invalid config telemetry is cleaned up
// and another service with a valid config can be started right after.
func TestServiceTelemetryCleanupOnError(t *testing.T) {
Expand Down

0 comments on commit a7d019f

Please sign in to comment.