Skip to content

Commit

Permalink
add back deprecated stackdriverexporter which wraps googlecloudexporter
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Mar 16, 2021
1 parent ef7486d commit 4f9ea45
Show file tree
Hide file tree
Showing 9 changed files with 1,771 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ updates:
directory: "/exporter/splunkhecexporter"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/exporter/stackdriverexporter"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/exporter/sumologicexporter"
schedule:
Expand Down
32 changes: 20 additions & 12 deletions exporter/googlecloudexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,38 @@ var once sync.Once

// NewFactory creates a factory for the googlecloud exporter
func NewFactory() component.ExporterFactory {
return NewFactoryWithTypeStr(typeStr)
}

// creates a factory for the googlecloud exporter, overriding the type string
// used in config
func NewFactoryWithTypeStr(ts string) component.ExporterFactory {
// register view for self-observability
once.Do(func() {
view.Register(viewPointCount)
})

return exporterhelper.NewFactory(
typeStr,
createDefaultConfig,
configmodels.Type(ts),
createDefaultConfigWithTypeStr(ts),
exporterhelper.WithTraces(createTraceExporter),
exporterhelper.WithMetrics(createMetricsExporter),
)
}

// createDefaultConfig creates the default configuration for exporter.
func createDefaultConfig() configmodels.Exporter {
return &Config{
ExporterSettings: configmodels.ExporterSettings{
TypeVal: configmodels.Type(typeStr),
NameVal: typeStr,
},
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout},
RetrySettings: exporterhelper.DefaultRetrySettings(),
QueueSettings: exporterhelper.DefaultQueueSettings(),
UserAgent: "opentelemetry-collector-contrib {{version}}",
func createDefaultConfigWithTypeStr(ts string) exporterhelper.CreateDefaultConfig {
return func() configmodels.Exporter {
return &Config{
ExporterSettings: configmodels.ExporterSettings{
TypeVal: configmodels.Type(ts),
NameVal: ts,
},
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout},
RetrySettings: exporterhelper.DefaultRetrySettings(),
QueueSettings: exporterhelper.DefaultQueueSettings(),
UserAgent: "opentelemetry-collector-contrib {{version}}",
}
}
}

Expand Down
1 change: 1 addition & 0 deletions exporter/stackdriverexporter/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
34 changes: 34 additions & 0 deletions exporter/stackdriverexporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Deprecated Stackdriver Exporter

This exporter has been replaced by the [Google Cloud exporter](../googlecloudexporter/README.md).
`stackdriver` exporter configurations will continue to work but are deprecated. Please use [Google
Cloud exporter](../googlecloudexporter/README.md) instead.

`stackdriver` exporter supports the same configuration options as [Google Cloud
exporter](../googlecloudexporter/README.md).

# Recommendations

Please use the [Google Cloud exporter](../googlecloudexporter/README.md) or migrate to it by
changing the exporter entry in your config from `stackdriver` to `googlecloud` and updating your
pipelines to use this new key. All other configuration can rename the same. An example migration
diff might look like this:

```diff
exporters:
- stackdriver:
+ googlecloud
project: otel-starter-project
use_insecure: false

processors:
batch:

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
- exporters: [stackdriver]
+ exporters: [googlecloud]
```
31 changes: 31 additions & 0 deletions exporter/stackdriverexporter/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2019, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package stackdriverexporter

import (
"go.opentelemetry.io/collector/component"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlecloudexporter"
)

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

// NewFactory creates a factory for the stackdriver exporter
func NewFactory() component.ExporterFactory {
return googlecloudexporter.NewFactoryWithTypeStr(typeStr)
}
58 changes: 58 additions & 0 deletions exporter/stackdriverexporter/factory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2019, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

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"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlecloudexporter"
)

func TestCreateDefaultConfig(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
assert.NotNil(t, cfg, "failed to create default config")
assert.NoError(t, configcheck.ValidateConfig(cfg))
}

func TestCreateExporter(t *testing.T) {
if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" {
t.Skip("Default credentials not set, skip creating Stackdriver exporter")
}
ctx := context.Background()
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
eCfg := cfg.(*googlecloudexporter.Config)
eCfg.ProjectID = "test"

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

me, err := factory.CreateMetricsExporter(ctx, component.ExporterCreateParams{
Logger: zap.NewNop(),
}, eCfg)
assert.Nil(t, err)
assert.NotNil(t, me, "failed to create metrics exporter")
}
12 changes: 12 additions & 0 deletions exporter/stackdriverexporter/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/stackdriverexporter

go 1.16

require (
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlecloudexporter v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.22.1-0.20210313012550-03904de3dd61
go.uber.org/zap v1.16.0
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlecloudexporter => ../googlecloudexporter
Loading

0 comments on commit 4f9ea45

Please sign in to comment.