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

Migrate updates to Prometheus receiver from opencensus-service #208

Merged
merged 27 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4b1f6b1
Migrate updates to Prometheus receiver from opencensus-service
dinooliva Jul 30, 2019
58f046d
Remove unnecessary configuration for adjusting metrics
dinooliva Jul 30, 2019
26593b3
Update exporters README (#210)
Jul 31, 2019
1969524
Added Jaeger gRPC receiver (#197)
jpkrohling Jul 31, 2019
9da5d05
Fix README - remove broken links and commands (#211)
huikang Jul 31, 2019
831d805
Refactor opencensus exporter to make it easily extensible (#212)
owais Jul 31, 2019
bcc9a41
Use sha256 instead of md5 in node batcher processor (#202)
songy23 Jul 31, 2019
c7eacad
Add goimports check and fix import order for all files (#209)
songy23 Jul 31, 2019
69a2ad0
Add factory and update config for tail sampling processor (#200)
songy23 Jul 31, 2019
dc4266d
Add misspell check and fix all typos (#214)
songy23 Jul 31, 2019
d0b9b47
Move tail sampling config to its own package and remove stale configs…
songy23 Aug 1, 2019
3a985da
Add Observability Vision document (#188)
tigrannajaryan Aug 1, 2019
a1ecc6f
Add Zipkin exporter factory (#207)
Aug 1, 2019
2a0f820
Update README to address reviewer comments.
dinooliva Aug 1, 2019
437c680
Update module dependencies and import order for metricfamily
dinooliva Aug 1, 2019
1660277
Improve OC Receiver Documentation (#203)
ccaraman Aug 1, 2019
79957ff
Add static check and fix all errors (#218)
songy23 Aug 2, 2019
3af9c48
Rename exporterhelp parameter (#220)
Aug 2, 2019
fdb5047
Fix build: lower casing error message (#224)
Aug 2, 2019
b39842b
Add jaeger grpc exporter (#219)
Aug 2, 2019
b1d106f
Migrate updates to Prometheus receiver from opencensus-service
dinooliva Jul 30, 2019
0e5a037
Remove unnecessary configuration for adjusting metrics
dinooliva Jul 30, 2019
0237bb0
Update README to address reviewer comments.
dinooliva Aug 1, 2019
76bd726
Update module dependencies and import order for metricfamily
dinooliva Aug 1, 2019
99d3bfa
Resolve merge conflicts
dinooliva Aug 6, 2019
14d3201
Fix goimports
dinooliva Aug 6, 2019
4389c22
Fix staticcheck issues
dinooliva Aug 6, 2019
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
4 changes: 2 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ running. By default, the Agent is available on port 55678.
there is no identifier in the first message, Agent should drop the whole
message and return an error to the client. In addition, the first message
MAY contain additional data (such as `Span`s). As long as it has a valid
identifier assoicated, Agent should handle the data properly, as if they
identifier associated, Agent should handle the data properly, as if they
were sent in a subsequent message. Identifier is no longer needed once the
streams are established.
3. On Library side, if connection to Agent failed, Library should retry
Expand Down Expand Up @@ -139,7 +139,7 @@ library, and `Node` is not required for the subsequent messages from libraries.

#### <a name="agent-impl-core"></a>Agent Core

Most functionalities of Agent are in Agent Core. Agent Core's responsibilies
Most functionalities of Agent are in Agent Core. Agent Core's responsibilities
include:

1. Accept `SpanProto` from each receiver. Note that the `SpanProto`s that are
Expand Down
48 changes: 42 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@ ALL_SRC := $(shell find . -name '*.go' \
-not -path './testbed/*' \
-type f | sort)

# All source code and documents. Used in spell check.
ALL_SRC_AND_DOC := $(shell find . \( -name "*.md" -o -name "*.go" -o -name "*.yaml" \) \
-not -path './vendor/*' \
-type f | sort)

# ALL_PKGS is used with 'go cover'
ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))

GOTEST_OPT?= -race -timeout 30s
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
GOTEST=go test
GOFMT=gofmt
GOIMPORTS=goimports
GOLINT=golint
GOVET=go vet
GOOS=$(shell go env GOOS)
ADDLICENCESE= addlicense
MISSPELL=misspell -error
MISSPELL_CORRECTION=misspell -w
STATICCHECK=staticcheck

GIT_SHA=$(shell git rev-parse --short HEAD)
BUILD_INFO_IMPORT_PATH=github.com/open-telemetry/opentelemetry-service/internal/version
Expand All @@ -30,10 +39,10 @@ all-pkgs:
all-srcs:
@echo $(ALL_SRC) | tr ' ' '\n' | sort

.DEFAULT_GOAL := addlicense-fmt-vet-lint-test
.DEFAULT_GOAL := addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test

.PHONY: addlicense-fmt-vet-lint-test
addlicense-fmt-vet-lint-test: addlicense fmt vet lint test
.PHONY: addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test
addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test: addlicense fmt vet lint goimports misspell staticcheck test

.PHONY: e2e-test
e2e-test: otelsvc
Expand All @@ -44,7 +53,7 @@ test:
$(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)

.PHONY: travis-ci
travis-ci: fmt vet lint test-with-cover otelsvc
travis-ci: fmt vet lint goimports misspell staticcheck test-with-cover otelsvc
$(MAKE) -C testbed install-tools
$(MAKE) -C testbed runtests

Expand Down Expand Up @@ -90,15 +99,42 @@ lint:
echo "Lint finished successfully"; \
fi

.PHONY: goimports
goimports:
@IMPORTSOUT=`$(GOIMPORTS) -d . 2>&1`; \
if [ "$$IMPORTSOUT" ]; then \
echo "$(GOIMPORTS) FAILED => fix the following goimports errors:\n"; \
echo "$$IMPORTSOUT\n"; \
exit 1; \
else \
echo "Goimports finished successfully"; \
fi

.PHONY: misspell
misspell:
$(MISSPELL) $(ALL_SRC_AND_DOC)

.PHONY: misspell-correction
misspell-correction:
$(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC)

.PHONY: staticcheck
staticcheck:
$(STATICCHECK) ./...

.PHONY: vet
vet:
@$(GOVET) ./...
@echo "Vet finished successfully"

.PHONY: install-tools
install-tools:
GO111MODULE=on go install github.com/google/addlicense
GO111MODULE=on go install golang.org/x/lint/golint
GO111MODULE=on go install \
github.com/google/addlicense \
golang.org/x/lint/golint \
golang.org/x/tools/cmd/goimports \
github.com/client9/misspell/cmd/misspell \
honnef.co/go/tools/cmd/staticcheck

.PHONY: otelsvc
otelsvc:
Expand Down
67 changes: 56 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ deployment methods:

For the detailed design specs, please see [DESIGN.md](DESIGN.md).

For the future vision of OpenTelemetry Service please see [vision.md](docs/vision.md).

## <a name="deploy"></a>Deployment

The OpenTelemetry Service can be deployed in a variety of different ways
Expand Down Expand Up @@ -89,23 +91,22 @@ Create an Agent [configuration](#config) file based on the options described
below. By default, the Agent has the `opencensus` receiver enabled, but no
exporters configured.

Build the Agent, see [Usage](##agent-usage),
and start it:
Build the Agent and start it with the example configuration:

```shell
$ ./bin/$(go env GOOS)/otelsvc
$ ./bin/$(go env GOOS)/otelsvc --config ./examples/demotrace/otel-agent-config.yaml
$ 2018/10/08 21:38:00 Running OpenTelemetry receiver as a gRPC service at "127.0.0.1:55678"
```

Create an Collector [configuration](#config) file based on the options
described below. By default, the Collector has the `opencensus` receiver
enabled, but no exporters configured.

Build the Collector and start it:
Build the Collector and start it with the example configuration:

```shell
$ make otelsvc
$ ./bin/$($GOOS)/otelsvc
$ ./bin/$($GOOS)/otelsvc --config ./examples/demotrace/otel-collector-config.yaml
```

Run the demo application:
Expand All @@ -121,14 +122,29 @@ exporting will resume.
## <a name="config"></a>Configuration

The OpenTelemetry Service (both the Agent and Collector) is configured via a
YAML file. In general, you need to configure one or more receivers as well as
one or more exporters. In addition, diagnostics can also be configured.
YAML file. In general, at least one enabled receiver and one enabled exporter
needs to be configured.

*Note* This documentation is still in progress. For any questions, please reach out in the
[OpenTelemetry Gitter](https://gitter.im/open-telemetry/opentelemetry-service) or
refer to the [issues page](https://github.com/open-telemetry/opentelemetry-service/issues).

There are four main parts to a config:
```yaml
receivers:
...
exporters:
...
processors:
...
pipelines:
...
```

### <a name="config-receivers"></a>Receivers

A receiver is how you get data into the OpenTelemetry Service. One or more
receivers can be configured. By default, the `opentelemetry` receiver is enabled
on the Collector and required as a defined receiver for the Agent.
A receiver is how data gets into OpenTelemetry Service. One or more receivers
must be configured.

A basic example of all available receivers is provided below. For detailed
receiver configuration, please see the [receiver
Expand Down Expand Up @@ -181,6 +197,33 @@ exporters:
endpoint: "http://127.0.0.1:9411/api/v2/spans"
```

### <a name="config-pipelines"></a>Pipelines
Pipelines can be of two types:

- metrics: collects and processes metrics data.
- traces: collects and processes trace data.

A pipeline consists of a set of receivers, processors, and exporters. Each
receiver/processor/exporter must be specified in the configuration to be
included in a pipeline and each receiver/processor/exporter can be used in more
than one pipeline.

*Note:* For processor(s) referenced in multiple pipelines, each pipeline will
get a separate instance of that processor(s). This is in contrast to
receiver(s)/exporter(s) referenced in multiple pipelines, one instance of
a receiver/exporter is reference by all the pipelines.

The following is an example pipeline configuration. For more information, refer
to [pipeline documentation](docs/pipelines.md)
```yaml
pipelines:
traces:
receivers: [examplereceiver]
processors: [exampleprocessor]
exporters: [exampleexporter]

```

### <a name="config-diagnostics"></a>Diagnostics

zPages is provided for monitoring running by default on port ``55679``.
Expand All @@ -207,7 +250,10 @@ zpages:
disabled: true
```


### <a name="global-attributes"></a> Global Attributes
**TODO** Remove this once processors have been documented since that handles
these features now.

The OpenTelemetry Service also takes some global configurations that modify its
behavior for all receivers / exporters. This configuration is typically applied
Expand Down Expand Up @@ -300,7 +346,6 @@ sampling:
```

> Note that an exporter can only have a single sampling policy today.

## <a name="collector-usage"></a>Usage

> It is recommended that you use the latest [release](https://github.com/open-telemetry/opentelemetry-service/releases).
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"google.golang.org/grpc/encoding/gzip"

"github.com/open-telemetry/opentelemetry-service/internal/compression"
"github.com/open-telemetry/opentelemetry-service/compression"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package grpc
import (
"testing"

"github.com/open-telemetry/opentelemetry-service/internal/compression"
"github.com/open-telemetry/opentelemetry-service/compression"
)

func TestGetGRPCCompressionKey(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
41 changes: 37 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const (
errPipelineExporterNotExists
errMetricPipelineCannotHaveProcessors
errUnmarshalError
errMissingReceivers
// TODO(ccaraman): Add an error for missing Processors with corresponding test cases.
)

type configError struct {
Expand Down Expand Up @@ -175,8 +177,21 @@ func loadReceivers(v *viper.Viper, factories map[string]receiver.Factory) (confi
// Get the map of "receivers" sub-keys.
keyMap := v.GetStringMap(receiversKeyName)

// Currently there is no default receiver enabled. The configuration must specify at least one receiver to enable
// functionality.
if len(keyMap) == 0 {
return nil, &configError{
code: errMissingReceivers,
msg: "no receivers specified in config",
}
}

// This boolean is used to track if there are any enabled receivers. If there are none at the end of loading
// all of the receivers, throw an error.
enabledReceiver := false

// Prepare resulting map
receivers := make(configmodels.Receivers, 0)
receivers := make(configmodels.Receivers)

// Iterate over input map and create a config for each.
for key := range keyMap {
Expand Down Expand Up @@ -211,6 +226,9 @@ func loadReceivers(v *viper.Viper, factories map[string]receiver.Factory) (confi
err = customUnmarshaler(subViper, key, receiverCfg)
} else {
// Standard viper unmarshaler is fine.
// TODO(ccaraman): UnmarshallExact should be used to catch erroneous config entries.
// This leads to quickly identifying config values that are not supported and reduce confusion for
// users.
err = subViper.UnmarshalKey(key, receiverCfg)
}

Expand All @@ -228,9 +246,20 @@ func loadReceivers(v *viper.Viper, factories map[string]receiver.Factory) (confi
}
}

// Or'ing the enabled flag for all receivers will return true if at least one is enabled.
enabledReceiver = enabledReceiver || receiverCfg.IsEnabled()

receivers[fullName] = receiverCfg
}

// There must be at least one enabled receiver for the config to be valid.
if !enabledReceiver {
return nil, &configError{
code: errMissingReceivers,
msg: "no enabled receivers specified in config",
}
}

return receivers, nil
}

Expand All @@ -242,7 +271,7 @@ func loadExporters(v *viper.Viper, factories map[string]exporter.Factory) (confi
keyMap := v.GetStringMap(exportersKeyName)

// Prepare resulting map
exporters := make(configmodels.Exporters, 0)
exporters := make(configmodels.Exporters)

// Iterate over exporters and create a config for each.
for key := range keyMap {
Expand Down Expand Up @@ -299,7 +328,7 @@ func loadProcessors(v *viper.Viper, factories map[string]processor.Factory) (con
keyMap := v.GetStringMap(processorsKeyName)

// Prepare resulting map.
processors := make(configmodels.Processors, 0)
processors := make(configmodels.Processors)

// Iterate over processors and create a config for each.
for key := range keyMap {
Expand Down Expand Up @@ -356,7 +385,7 @@ func loadPipelines(v *viper.Viper) (configmodels.Pipelines, error) {
keyMap := v.GetStringMap(pipelinesKeyName)

// Prepare resulting map.
pipelines := make(configmodels.Pipelines, 0)
pipelines := make(configmodels.Pipelines)

// Iterate over input map and create a config for each.
for key := range keyMap {
Expand Down Expand Up @@ -496,6 +525,7 @@ func validatePipelineReceivers(
zap.String("receiver", ref))
}
}

pipeline.Receivers = rs

return nil
Expand Down Expand Up @@ -594,6 +624,9 @@ func validatePipelineProcessors(
return nil
}

// TODO(ccaraman): Determine if there a way to consolidate the validate receivers apart of the loadReceivers method.
// Currently, validateReceivers needs to be invoked after validatePipelineReceivers because that bit of
// code checks if a receiver is enabled prior to finalizing the pipelines.
func validateReceivers(cfg *configmodels.Config) {
// Remove disabled receivers.
for name, rcv := range cfg.Receivers {
Expand Down
5 changes: 3 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ func TestDecodeConfig_Invalid(t *testing.T) {
}{
{name: "empty-config"},
{name: "missing-all-sections"},
{name: "missing-receivers"},
{name: "missing-enabled-receivers", expected: errMissingReceivers},
{name: "missing-receivers", expected: errMissingReceivers},
{name: "missing-exporters"},
{name: "missing-processors"},
{name: "invalid-receiver-name"},
Expand Down Expand Up @@ -215,7 +216,7 @@ func TestDecodeConfig_Invalid(t *testing.T) {
t, path.Join(".", "testdata", test.name+".yaml"), receivers, processors, exporters,
)
if err == nil {
t.Errorf("expected error but succedded on invalid config case: %s", test.name)
t.Errorf("expected error but succeeded on invalid config case: %s", test.name)
} else if test.expected != 0 {
cfgErr, ok := err.(*configError)
if !ok {
Expand Down
Loading