Skip to content

Commit

Permalink
[chore][exporter/azuremonitor] Force the telemetry to be sent to azur…
Browse files Browse the repository at this point in the history
…emonitor (open-telemetry#36520)

#### Description

1. Resolved an issue where traces weren't being sent to App Insights due
to not flushing the Telemetry Channel. Added the necessary flush
operation to ensure all traces, metrics and logs are properly sent to
the queue, leveraging App Insights' batch handling for more efficient
processing.

#### Link to tracking issue
Resolves open-telemetry#35037

---------

Signed-off-by: whitneygriffith <whitney.griffith16@gmail.com>
Co-authored-by: Andrzej Stencel <andrzej.stencel@elastic.co>
  • Loading branch information
whitneygriffith and andrzej-stencel authored Nov 25, 2024
1 parent 37129e9 commit 62998b5
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .chloggen/azuremonitor-bug-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Fixes an issue where the Azure Monitor exporter was not sending data to App Insights due to the Telemetry Channel not being flushed."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [35037]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# 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: []
1 change: 1 addition & 0 deletions exporter/azuremonitorexporter/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import "github.com/microsoft/ApplicationInsights-Go/appinsights/contracts"

type transportChannel interface {
Send(*contracts.Envelope)
Flush()
}
3 changes: 2 additions & 1 deletion exporter/azuremonitorexporter/logexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func (exporter *logExporter) onLogData(_ context.Context, logData plog.Logs) err
}
}
}

// Flush the transport channel to force the telemetry to be sent
exporter.transportChannel.Flush()
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions exporter/azuremonitorexporter/metricexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func (exporter *metricExporter) onMetricData(_ context.Context, metricData pmetr
}
}

// Flush the transport channel to force the telemetry to be sent
exporter.transportChannel.Flush()
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions exporter/azuremonitorexporter/mock_transportChannel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions exporter/azuremonitorexporter/traceexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func (v *traceVisitor) visit(
v.exporter.transportChannel.Send(envelope)
}

// Flush the transport channel to force the telemetry to be sent
v.exporter.transportChannel.Flush()
v.processed++

return true
Expand Down
1 change: 1 addition & 0 deletions exporter/azuremonitorexporter/traceexporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func TestExporterTraceDataCallbackSingleSpanNoEnvelope(t *testing.T) {
func getMockTransportChannel() *mockTransportChannel {
transportChannelMock := mockTransportChannel{}
transportChannelMock.On("Send", mock.Anything)
transportChannelMock.On("Flush", mock.Anything)
return &transportChannelMock
}

Expand Down

0 comments on commit 62998b5

Please sign in to comment.