Skip to content

Commit b53cde9

Browse files
whitneygriffithandrzej-stencel
authored andcommitted
[chore][exporter/azuremonitor] Force the telemetry to be sent to azuremonitor (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 <[email protected]> Co-authored-by: Andrzej Stencel <[email protected]>
1 parent 27c2c68 commit b53cde9

File tree

7 files changed

+39
-1
lines changed

7 files changed

+39
-1
lines changed

.chloggen/azuremonitor-bug-fix.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'bug_fix'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: azuremonitorexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Fixes an issue where the Azure Monitor exporter was not sending data to App Insights due to the Telemetry Channel not being flushed."
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [35037]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

exporter/azuremonitorexporter/channels.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ import "github.com/microsoft/ApplicationInsights-Go/appinsights/contracts"
77

88
type transportChannel interface {
99
Send(*contracts.Envelope)
10+
Flush()
1011
}

exporter/azuremonitorexporter/logexporter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ func (exporter *logExporter) onLogData(_ context.Context, logData plog.Logs) err
3535
}
3636
}
3737
}
38-
38+
// Flush the transport channel to force the telemetry to be sent
39+
exporter.transportChannel.Flush()
3940
return nil
4041
}
4142

exporter/azuremonitorexporter/metricexporter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func (exporter *metricExporter) onMetricData(_ context.Context, metricData pmetr
3737
}
3838
}
3939

40+
// Flush the transport channel to force the telemetry to be sent
41+
exporter.transportChannel.Flush()
4042
return nil
4143
}
4244

exporter/azuremonitorexporter/mock_transportChannel.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exporter/azuremonitorexporter/traceexporter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func (v *traceVisitor) visit(
4646
v.exporter.transportChannel.Send(envelope)
4747
}
4848

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

5153
return true

exporter/azuremonitorexporter/traceexporter_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func TestExporterTraceDataCallbackSingleSpanNoEnvelope(t *testing.T) {
116116
func getMockTransportChannel() *mockTransportChannel {
117117
transportChannelMock := mockTransportChannel{}
118118
transportChannelMock.On("Send", mock.Anything)
119+
transportChannelMock.On("Flush", mock.Anything)
119120
return &transportChannelMock
120121
}
121122

0 commit comments

Comments
 (0)