Skip to content

Commit 00887bc

Browse files
Add a LightStep exporter. (#136)
Co-Authored-By: Paulo Janotti <[email protected]>
1 parent b175604 commit 00887bc

File tree

14 files changed

+1133
-1
lines changed

14 files changed

+1133
-1
lines changed

cmd/otelcontribcol/components.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter"
2828
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/honeycombexporter"
2929
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kinesisexporter"
30+
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lightstepexporter"
3031
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter"
3132
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter"
3233
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/stackdriverexporter"
@@ -71,6 +72,7 @@ func components() (config.Factories, error) {
7172
&awsxrayexporter.Factory{},
7273
&carbonexporter.Factory{},
7374
&honeycombexporter.Factory{},
75+
&lightstepexporter.Factory{},
7476
}
7577
for _, exp := range factories.Exporters {
7678
exporters = append(exporters, exp)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile.Common
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# LightStep Exporter
2+
3+
This exporter supports sending trace data to [LightStep](https://www.lightstep.com)
4+
5+
The following configuration options are supported:
6+
7+
* `access_token` (Required): The access token for your LightStep project.
8+
* `satellite_host` (Optional): Your LightStep Satellite Pool URL. Defaults to `https://ingest.lightstep.com`.
9+
* `satellite_port` (Optional): Your LightStep Satellite Pool Port. Defaults to `443`.
10+
* `service_name` (Optional): The service name for spans reported by this collector. Defaults to `opentelemetry-collector`.
11+
12+
Example:
13+
14+
```yaml
15+
exporters:
16+
lightstep:
17+
access_token: "abcdef12345"
18+
satellite_host: "https://my.satellite.pool.coolcat.com"
19+
satellite_port: 8000
20+
service_name: "myService"
21+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2020 OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package lightstepexporter
16+
17+
import "github.com/open-telemetry/opentelemetry-collector/config/configmodels"
18+
19+
// Config defines configuration options for the LightStep exporter.
20+
type Config struct {
21+
configmodels.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
22+
// AccessToken is your project access token in LightStep.
23+
AccessToken string `mapstructure:"access_token"`
24+
// SatelliteHost is the satellite pool URL.
25+
SatelliteHost string `mapstructure:"satellite_host"`
26+
// SatellitePort is the satellite pool port.
27+
SatellitePort int `mapstructure:"satellite_port"`
28+
// ServiceName is the LightStep service name for your spans.
29+
ServiceName string `mapstructure:"service_name"`
30+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2020 OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package lightstepexporter
16+
17+
import (
18+
"path"
19+
"testing"
20+
21+
"github.com/open-telemetry/opentelemetry-collector/config"
22+
"github.com/open-telemetry/opentelemetry-collector/config/configmodels"
23+
"github.com/stretchr/testify/assert"
24+
"github.com/stretchr/testify/require"
25+
)
26+
27+
func TestLoadConfig(t *testing.T) {
28+
factories, err := config.ExampleComponents()
29+
assert.Nil(t, err)
30+
31+
factory := &Factory{}
32+
factories.Exporters[typeStr] = factory
33+
cfg, err := config.LoadConfigFile(
34+
t, path.Join(".", "testdata", "config.yaml"), factories,
35+
)
36+
37+
require.NoError(t, err)
38+
require.NotNil(t, cfg)
39+
40+
assert.Equal(t, len(cfg.Exporters), 2)
41+
42+
r0 := cfg.Exporters["lightstep"]
43+
assert.Equal(t, r0, factory.CreateDefaultConfig())
44+
45+
r1 := cfg.Exporters["lightstep/customname"].(*Config)
46+
assert.Equal(t, r1, &Config{
47+
ExporterSettings: configmodels.ExporterSettings{TypeVal: typeStr, NameVal: "lightstep/customname"},
48+
AccessToken: "abcdef12345",
49+
SatelliteHost: "https://custom.lightstep.com",
50+
SatellitePort: 8000,
51+
ServiceName: "myService",
52+
})
53+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2020 OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package lightstepexporter
16+
17+
import (
18+
"github.com/open-telemetry/opentelemetry-collector/config/configerror"
19+
"github.com/open-telemetry/opentelemetry-collector/config/configmodels"
20+
"github.com/open-telemetry/opentelemetry-collector/exporter"
21+
"go.uber.org/zap"
22+
)
23+
24+
const (
25+
typeStr = "lightstep"
26+
)
27+
28+
// Factory is the factory for the LightStep exporter.
29+
type Factory struct {
30+
}
31+
32+
// Type gets the type of the exporter configuration created by this factory.
33+
func (f *Factory) Type() string {
34+
return typeStr
35+
}
36+
37+
// CreateDefaultConfig creates a default configuration for this exporter.
38+
func (f *Factory) CreateDefaultConfig() configmodels.Exporter {
39+
return &Config{
40+
ExporterSettings: configmodels.ExporterSettings{
41+
TypeVal: typeStr,
42+
NameVal: typeStr,
43+
},
44+
AccessToken: "",
45+
SatelliteHost: "https://ingest.lightstep.com",
46+
SatellitePort: 443,
47+
ServiceName: "opentelemetry-collector",
48+
}
49+
}
50+
51+
// CreateTraceExporter creates a LightStep trace exporter for this configuration.
52+
func (f *Factory) CreateTraceExporter(logger *zap.Logger, cfg configmodels.Exporter) (exporter.TraceExporter, error) {
53+
lsConfig := cfg.(*Config)
54+
return newLightStepTraceExporter(lsConfig)
55+
}
56+
57+
// CreateMetricsExporter returns nil.
58+
func (f *Factory) CreateMetricsExporter(logger *zap.Logger, cfg configmodels.Exporter) (exporter.MetricsExporter, error) {
59+
return nil, configerror.ErrDataTypeIsNotSupported
60+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2020 OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package lightstepexporter
16+
17+
import (
18+
"path"
19+
"testing"
20+
21+
"github.com/open-telemetry/opentelemetry-collector/config"
22+
"github.com/open-telemetry/opentelemetry-collector/config/configcheck"
23+
"github.com/stretchr/testify/assert"
24+
"github.com/stretchr/testify/require"
25+
"go.uber.org/zap"
26+
)
27+
28+
func TestCreateDefaultConfig(t *testing.T) {
29+
factory := Factory{}
30+
cfg := factory.CreateDefaultConfig()
31+
assert.NotNil(t, cfg, "failed to create default config")
32+
assert.NoError(t, configcheck.ValidateConfig(cfg))
33+
}
34+
35+
func TestCreateTraceExporter(t *testing.T) {
36+
logger := zap.NewNop()
37+
38+
factories, err := config.ExampleComponents()
39+
require.NoError(t, err)
40+
factory := Factory{}
41+
factories.Exporters[typeStr] = &factory
42+
cfg, err := config.LoadConfigFile(
43+
t, path.Join(".", "testdata", "config.yaml"), factories,
44+
)
45+
require.NoError(t, err)
46+
47+
exporter, err := factory.CreateTraceExporter(logger, cfg.Exporters["lightstep/customname"])
48+
assert.Nil(t, err)
49+
assert.NotNil(t, exporter)
50+
}
51+
52+
func TestCreateMetricsExporter(t *testing.T) {
53+
logger := zap.NewNop()
54+
55+
factories, err := config.ExampleComponents()
56+
require.NoError(t, err)
57+
factory := Factory{}
58+
factories.Exporters[typeStr] = &factory
59+
cfg, err := config.LoadConfigFile(
60+
t, path.Join(".", "testdata", "config.yaml"), factories,
61+
)
62+
require.NoError(t, err)
63+
64+
exporter, err := factory.CreateMetricsExporter(logger, cfg.Exporters["lightstep/customname"])
65+
assert.NotNil(t, err)
66+
assert.Nil(t, exporter)
67+
}

exporter/lightstepexporter/go.mod

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lightstepexporter
2+
3+
go 1.12
4+
5+
require (
6+
github.com/lightstep/opentelemetry-exporter-go v0.1.5
7+
github.com/open-telemetry/opentelemetry-collector v0.2.6
8+
github.com/stretchr/testify v1.4.0
9+
go.opentelemetry.io/otel v0.2.3
10+
go.uber.org/zap v1.14.0
11+
)
12+
13+
replace github.com/apache/thrift => github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7

0 commit comments

Comments
 (0)