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

[exporter/azuremonitor] Add metrics support #14916

Merged
16 changes: 16 additions & 0 deletions .chloggen/azuremonitorexporter-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# 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: Adds metrics exporting

# One or more tracking issues related to the change
issues: [14915]

# (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:
5 changes: 4 additions & 1 deletion exporter/azuremonitorexporter/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Azure Monitor Exporter

This exporter sends logs and trace data to [Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/).
This exporter sends logs, traces and metrics to [Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/).

## Configuration

Expand Down Expand Up @@ -58,3 +58,6 @@ All attributes are also mapped to custom properties if they are booleans or stri
### Logs
This exporter saves log records to Application Insights `traces` table.
[TraceId](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-traceid) is mapped to `operation_id` column and [SpanId](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-spanid) is mapped to `operation_parentId` column.

### Traces
eedorenko marked this conversation as resolved.
Show resolved Hide resolved
This exporter saves traces to Application Insights `customMetrics` table.
18 changes: 17 additions & 1 deletion exporter/azuremonitorexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func NewFactory() component.ExporterFactory {
typeStr,
createDefaultConfig,
component.WithTracesExporter(f.createTracesExporter, stability),
component.WithLogsExporter(f.createLogsExporter, stability))
component.WithLogsExporter(f.createLogsExporter, stability),
component.WithMetricsExporter(f.createMetricsExporter, stability))
eedorenko marked this conversation as resolved.
Show resolved Hide resolved
}

// Implements the interface from go.opentelemetry.io/collector/exporter/factory.go
Expand Down Expand Up @@ -91,6 +92,21 @@ func (f *factory) createLogsExporter(
return newLogsExporter(exporterConfig, tc, set)
}

func (f *factory) createMetricsExporter(
ctx context.Context,
set component.ExporterCreateSettings,
cfg config.Exporter,
) (component.MetricsExporter, error) {
exporterConfig, ok := cfg.(*Config)

if !ok {
return nil, errUnexpectedConfigurationType
}

tc := f.getTransportChannel(exporterConfig, set.Logger)
return newMetricsExporter(exporterConfig, tc, set)
}

// Configures the transport channel.
// This method is not thread-safe
func (f *factory) getTransportChannel(exporterConfig *Config, logger *zap.Logger) transportChannel {
Expand Down
16 changes: 9 additions & 7 deletions exporter/azuremonitorexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,28 @@ require (
go.opentelemetry.io/collector/pdata v0.62.0
go.opentelemetry.io/collector/semconv v0.62.0
go.uber.org/zap v1.23.0
golang.org/x/net v0.0.0-20220225172249-27dd8689420f
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
)

require (
code.cloudfoundry.org/clock v1.0.0 // indirect
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/knadh/koanf v1.4.3 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
go.opencensus.io v0.23.0 // indirect
Expand All @@ -37,11 +39,11 @@ require (
go.opentelemetry.io/otel/trace v1.10.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.50.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
33 changes: 14 additions & 19 deletions exporter/azuremonitorexporter/go.sum

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

Loading