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/skywalking] Add skywalking metrics exporter #6528

Merged
merged 17 commits into from
Jan 3, 2022
Merged
2 changes: 1 addition & 1 deletion cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ require (
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
skywalking.apache.org/repo/goapi v0.0.0-20210820070710-e10b78bbf481 // indirect
skywalking.apache.org/repo/goapi v0.0.0-20211122071111-ffc517fbfe21 // indirect
)

// Replace references to modules that are in this repository with their relateive paths
Expand Down
4 changes: 2 additions & 2 deletions cmd/configschema/go.sum

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

2 changes: 1 addition & 1 deletion exporter/skywalkingexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Exports data via gRPC using [skywalking-data-collect-protocol](https://github.com/apache/skywalking-data-collect-protocol) format. By default, this exporter requires TLS and offers queued retry capabilities.

Supported pipeline types: logs
Supported pipeline types: logs, metrics

## Getting Started

Expand Down
20 changes: 18 additions & 2 deletions exporter/skywalkingexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func NewFactory() component.ExporterFactory {
return exporterhelper.NewFactory(
typeStr,
createDefaultConfig,
exporterhelper.WithLogs(createLogsExporter))
exporterhelper.WithLogs(createLogsExporter),
exporterhelper.WithMetrics(createMetricsExporter))
}

func createDefaultConfig() config.Exporter {
Expand All @@ -58,7 +59,7 @@ func createLogsExporter(
cfg config.Exporter,
) (component.LogsExporter, error) {
oCfg := cfg.(*Config)
oce := newExporter(ctx, oCfg, set.TelemetrySettings)
oce := newLogsExporter(ctx, oCfg, set.TelemetrySettings)
return exporterhelper.NewLogsExporter(
cfg,
set,
Expand All @@ -71,3 +72,18 @@ func createLogsExporter(
exporterhelper.WithShutdown(oce.shutdown),
)
}

func createMetricsExporter(ctx context.Context, set component.ExporterCreateSettings, cfg config.Exporter) (component.MetricsExporter, error) {
oCfg := cfg.(*Config)
oce := newMetricsExporter(ctx, oCfg, set.TelemetrySettings)
return exporterhelper.NewMetricsExporter(
cfg,
set,
oce.pushMetrics,
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithRetry(oCfg.RetrySettings),
exporterhelper.WithQueue(oCfg.QueueSettings),
exporterhelper.WithTimeout(oCfg.TimeoutSettings),
exporterhelper.WithStart(oce.start),
exporterhelper.WithShutdown(oce.shutdown))
}
2 changes: 2 additions & 0 deletions exporter/skywalkingexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func TestCreateTracesExporter(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
tExporter, tErr := createLogsExporter(context.Background(), set, &tt.config)
checkErrorsAndStartAndShutdown(t, tExporter, tErr, tt.mustFailOnCreate, tt.mustFailOnStart)
tExporter2, tErr2 := createMetricsExporter(context.Background(), set, &tt.config)
checkErrorsAndStartAndShutdown(t, tExporter2, tErr2, tt.mustFailOnCreate, tt.mustFailOnStart)
})
}
}
Expand Down
7 changes: 5 additions & 2 deletions exporter/skywalkingexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
)

require (
cloud.google.com/go v0.81.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.2.1 // indirect
Expand All @@ -34,9 +35,11 @@ require (
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
Expand All @@ -46,7 +49,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.41.0
github.com/rogpeppe/go-internal v1.8.0 // indirect
google.golang.org/grpc v1.43.0
skywalking.apache.org/repo/goapi v0.0.0-20210820070710-e10b78bbf481
skywalking.apache.org/repo/goapi v0.0.0-20211122071111-ffc517fbfe21
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal
17 changes: 13 additions & 4 deletions exporter/skywalkingexporter/go.sum

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

3 changes: 0 additions & 3 deletions exporter/skywalkingexporter/logrecord_to_logdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ func resourceToLogData(resource pdata.Resource, logData *logpb.LogData) {
}

attrs.Range(func(k string, v pdata.AttributeValue) bool {
if k == conventions.AttributeServiceName || k == conventions.AttributeServiceInstanceID {
return true
}
liqiangz marked this conversation as resolved.
Show resolved Hide resolved
logData.Tags.Data = append(logData.Tags.Data, &common.KeyStringValuePair{
Key: k,
Value: v.AsString(),
Expand Down
Loading