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

Move stackdriver trace exporter to new interface and pdata #486

Merged
merged 40 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
120c4ff
initial changes
stevencl1013 Jul 10, 2020
32b8f93
implement factory and fix bugs
stevencl1013 Jul 13, 2020
4811519
add translation for attributes, links, and events
stevencl1013 Jul 14, 2020
1d1a071
update go.mod and go.sum
stevencl1013 Jul 15, 2020
0759ada
initial changes
stevencl1013 Jul 10, 2020
63413c4
implement factory and fix bugs
stevencl1013 Jul 13, 2020
75698ea
add translation for attributes, links, and events
stevencl1013 Jul 14, 2020
926ac33
update go.mod and go.sum
stevencl1013 Jul 15, 2020
3a02d94
go.sum change
stevencl1013 Jul 15, 2020
6d9d8d8
reset unwanted changes to go.mod and go.sum
stevencl1013 Jul 15, 2020
5432bae
implement MetricExporter
stevencl1013 Jul 17, 2020
db1db6e
remove cloud logging
stevencl1013 Jul 17, 2020
16ea74f
cleanup
stevencl1013 Jul 20, 2020
efe20d3
update factory test under new exporter implementation
stevencl1013 Jul 20, 2020
619c749
update stackdriver test to use pdata
stevencl1013 Jul 21, 2020
fd3178a
add check for null status
stevencl1013 Jul 21, 2020
2423032
fix bug in stackdriver test
stevencl1013 Jul 21, 2020
1285b8d
test for pdata to OT span data conversion
stevencl1013 Jul 21, 2020
2d4ed44
revert port change in stackdriver test
stevencl1013 Jul 21, 2020
41910d9
update go.mod and go.sum for OT Go stackdriver exporter
stevencl1013 Jul 21, 2020
6d681b0
fix import order
stevencl1013 Jul 21, 2020
7f94ea5
uncapitalize error
stevencl1013 Jul 21, 2020
b4f771c
lint and dependencies
stevencl1013 Jul 21, 2020
40c7a61
Merge branch 'master' into stackdriver-pdata
stevencl1013 Jul 22, 2020
157f220
fix mistake in factory test
stevencl1013 Jul 23, 2020
a67846e
pr comments
stevencl1013 Jul 23, 2020
7696b52
gofmt
stevencl1013 Jul 23, 2020
a89ffea
Merge branch 'master' into stackdriver-pdata
stevencl1013 Jul 24, 2020
e2b1ee4
Create new context in pushTraces
stevencl1013 Jul 27, 2020
9b910dd
gofmt
stevencl1013 Jul 27, 2020
9ff0844
Merge branch 'master' into stackdriver-pdata
stevencl1013 Jul 27, 2020
1f17001
use factory helpers
stevencl1013 Jul 28, 2020
cfe37d6
Merge branch 'stackdriver-pdata' of github.com:stevencl1013/opentelem…
stevencl1013 Jul 28, 2020
e558d1b
go.sum
stevencl1013 Jul 28, 2020
dbd0c4d
use stackdriverexporter.NewFactory() in components.go
stevencl1013 Jul 28, 2020
1fc7b43
Merge branch 'master' into stackdriver-pdata
stevencl1013 Jul 28, 2020
1e9b672
Merge branch 'master' into stackdriver-pdata
stevencl1013 Jul 29, 2020
1c32b56
Merge branch 'master' into stackdriver-pdata
stevencl1013 Jul 30, 2020
4e047d0
use latest ot stackdriver exporter
stevencl1013 Jul 31, 2020
ca94625
Merge branch 'master' into stackdriver-pdata
stevencl1013 Aug 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func components() (component.Factories, error) {
}

exporters := []component.ExporterFactoryBase{
&stackdriverexporter.Factory{},
stackdriverexporter.NewFactory(),
&azuremonitorexporter.Factory{},
&signalfxexporter.Factory{},
sapmexporter.NewFactory(),
Expand Down
2 changes: 1 addition & 1 deletion exporter/stackdriverexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestLoadConfig(t *testing.T) {
factories, err := componenttest.ExampleComponents()
assert.Nil(t, err)

factory := &Factory{}
factory := NewFactory()
factories.Exporters[configmodels.Type(typeStr)] = factory
cfg, err := configtest.LoadConfigFile(
t, path.Join(".", "testdata", "config.yaml"), factories,
Expand Down
37 changes: 23 additions & 14 deletions exporter/stackdriverexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@
package stackdriverexporter

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configmodels"
"go.uber.org/zap"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

const (
// The value of "type" key in configuration.
typeStr = "stackdriver"
)

// Factory is the factory for Stackdriver exporter.
type Factory struct {
}

// Type gets the type of the Exporter config created by this factory.
func (f *Factory) Type() configmodels.Type {
return configmodels.Type(typeStr)
// NewFactory creates a factory for the stackdriver exporter
func NewFactory() component.ExporterFactory {
return exporterhelper.NewFactory(
typeStr,
createDefaultConfig,
exporterhelper.WithTraces(createTraceExporter),
exporterhelper.WithMetrics(createMetricsExporter),
)
}

// CreateDefaultConfig creates the default configuration for exporter.
func (f *Factory) CreateDefaultConfig() configmodels.Exporter {
// createDefaultConfig creates the default configuration for exporter.
func createDefaultConfig() configmodels.Exporter {
return &Config{
ExporterSettings: configmodels.ExporterSettings{
TypeVal: configmodels.Type(typeStr),
Expand All @@ -44,14 +47,20 @@ func (f *Factory) CreateDefaultConfig() configmodels.Exporter {
}
}

// CreateTraceExporter creates a trace exporter based on this config.
func (f *Factory) CreateTraceExporter(logger *zap.Logger, cfg configmodels.Exporter) (component.TraceExporterOld, error) {
// createTraceExporter creates a trace exporter based on this config.
func createTraceExporter(
_ context.Context,
_ component.ExporterCreateParams,
cfg configmodels.Exporter) (component.TraceExporter, error) {
eCfg := cfg.(*Config)
return newStackdriverTraceExporter(eCfg)
}

// CreateMetricsExporter creates a metrics exporter based on this config.
func (f *Factory) CreateMetricsExporter(logger *zap.Logger, cfg configmodels.Exporter) (component.MetricsExporterOld, error) {
// createMetricsExporter creates a metrics exporter based on this config.
func createMetricsExporter(
_ context.Context,
_ component.ExporterCreateParams,
cfg configmodels.Exporter) (component.MetricsExporter, error) {
eCfg := cfg.(*Config)
return newStackdriverMetricsExporter(eCfg)
}
15 changes: 11 additions & 4 deletions exporter/stackdriverexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
package stackdriverexporter

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configcheck"
"go.uber.org/zap"
)

func TestCreateDefaultConfig(t *testing.T) {
factory := Factory{}
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
assert.NotNil(t, cfg, "failed to create default config")
assert.NoError(t, configcheck.ValidateConfig(cfg))
Expand All @@ -34,16 +36,21 @@ func TestCreateExporter(t *testing.T) {
if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" {
t.Skip("Default credentials not set, skip creating Stackdriver exporter")
}
factory := Factory{}
ctx := context.Background()
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
eCfg := cfg.(*Config)
eCfg.ProjectID = "test"

te, err := factory.CreateTraceExporter(zap.NewNop(), eCfg)
te, err := factory.CreateTraceExporter(ctx, component.ExporterCreateParams{
Logger: zap.NewNop(),
}, eCfg)
assert.Nil(t, err)
assert.NotNil(t, te, "failed to create trace exporter")

me, err := factory.CreateMetricsExporter(zap.NewNop(), eCfg)
me, err := factory.CreateMetricsExporter(ctx, component.ExporterCreateParams{
Logger: zap.NewNop(),
}, eCfg)
assert.Nil(t, err)
assert.NotNil(t, me, "failed to create metrics exporter")
}
2 changes: 2 additions & 0 deletions exporter/stackdriverexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ go 1.14

require (
contrib.go.opencensus.io/exporter/stackdriver v0.13.1
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v0.2.2-0.20200728233621-2752da7eaab7
github.com/census-instrumentation/opencensus-proto v0.3.0
github.com/golang/protobuf v1.4.2
github.com/stretchr/testify v1.6.1
go.opencensus.io v0.22.4
go.opentelemetry.io/collector v0.7.0
go.opentelemetry.io/otel v0.9.0
go.uber.org/zap v1.15.0
google.golang.org/api v0.29.0
google.golang.org/genproto v0.0.0-20200624020401-64a14ca9d1ad
Expand Down
Loading