-
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.
googlecloud: renamed stackdriver exporter to googlecloud (2 of 2) (#2713
) * add back deprecated stackdriverexporter which wraps googlecloudexporter * use delegate * Apply suggestions from code review Co-authored-by: Punya Biswal <[email protected]> * Address punya's comment, log deprecation warning Co-authored-by: Punya Biswal <[email protected]>
- Loading branch information
Showing
10 changed files
with
1,800 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
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,33 @@ | ||
# Deprecated Stackdriver Exporter | ||
|
||
This exporter has been renamed to the [Google Cloud exporter](../googlecloudexporter/README.md). | ||
`stackdriver` exporter configurations will continue to work for the sake of backwards compatibility. | ||
|
||
`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] | ||
``` |
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,76 @@ | ||
// Copyright 2021, 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" | ||
"sync" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config/configmodels" | ||
"go.uber.org/zap" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlecloudexporter" | ||
) | ||
|
||
type factory struct { | ||
component.ExporterFactory | ||
} | ||
|
||
const ( | ||
// The value of "type" key in configuration. | ||
typeVal = configmodels.Type("stackdriver") | ||
) | ||
|
||
var once sync.Once | ||
|
||
// NewFactory creates a factory for the stackdriver exporter | ||
func NewFactory() component.ExporterFactory { | ||
return &factory{ExporterFactory: googlecloudexporter.NewFactory()} | ||
} | ||
|
||
func logDeprecation(logger *zap.Logger) { | ||
once.Do(func() { | ||
logger.Warn("stackdriver exporter is deprecated. Use googlecloudexporter instead.") | ||
}) | ||
} | ||
|
||
func (f *factory) Type() configmodels.Type { | ||
return typeVal | ||
} | ||
|
||
func (f *factory) CreateDefaultConfig() configmodels.Exporter { | ||
cfg := f.ExporterFactory.CreateDefaultConfig() | ||
cfg.(*googlecloudexporter.Config).TypeVal = f.Type() | ||
return cfg | ||
} | ||
|
||
func (f *factory) CreateTracesExporter( | ||
ctx context.Context, | ||
params component.ExporterCreateParams, | ||
cfg configmodels.Exporter, | ||
) (component.TracesExporter, error) { | ||
logDeprecation(params.Logger) | ||
return f.ExporterFactory.CreateTracesExporter(ctx, params, cfg) | ||
} | ||
|
||
func (f *factory) CreateMetricsExporter( | ||
ctx context.Context, | ||
params component.ExporterCreateParams, | ||
cfg configmodels.Exporter, | ||
) (component.MetricsExporter, error) { | ||
logDeprecation(params.Logger) | ||
return f.ExporterFactory.CreateMetricsExporter(ctx, params, cfg) | ||
} |
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,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") | ||
} |
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,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 |
Oops, something went wrong.