-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add telemetryClient interface and update trace exporter unit tests
Signed-off-by: whitneygriffith <[email protected]>
- Loading branch information
1 parent
1df90fd
commit 8abcfc1
Showing
5 changed files
with
176 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package azuremonitorexporter | ||
|
||
import "github.com/microsoft/ApplicationInsights-Go/appinsights" | ||
|
||
// telemetryClient is an interface for telemetry clients. | ||
type telemetryClient interface { | ||
Track(telemetry appinsights.Telemetry) | ||
Channel() telemetryChannel | ||
} | ||
|
||
// telemetryChannel is an interface for telemetry channels. | ||
type telemetryChannel interface { | ||
Flush() | ||
Close() | ||
} | ||
|
||
// appInsightsTelemetryClient is a wrapper around appinsights.TelemetryClient. | ||
type appInsightsTelemetryClient struct { | ||
client appinsights.TelemetryClient | ||
} | ||
|
||
// Track sends telemetry data using the underlying client. | ||
func (t *appInsightsTelemetryClient) Track(telemetry appinsights.Telemetry) { | ||
t.client.Track(telemetry) | ||
} | ||
|
||
// Channel returns the telemetry channel of the underlying client. | ||
func (t *appInsightsTelemetryClient) Channel() telemetryChannel { | ||
return &appInsightsTelemetryChannel{channel: t.client.Channel()} | ||
} | ||
|
||
// appInsightsTelemetryChannel is a wrapper around appinsights.TelemetryChannel. | ||
type appInsightsTelemetryChannel struct { | ||
channel appinsights.TelemetryChannel | ||
} | ||
|
||
// Flush flushes the telemetry data. | ||
func (t *appInsightsTelemetryChannel) Flush() { | ||
t.channel.Flush() | ||
} | ||
|
||
// Close closes the telemetry channel. | ||
func (t *appInsightsTelemetryChannel) Close() { | ||
t.channel.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters