-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port spanmetrics processor to spanmetrics connector (#18535)
* Port spanmetrics processor to spanmetrics connector
- Loading branch information
1 parent
aaf5063
commit eedb371
Showing
23 changed files
with
1,580 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: new_component | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: spanmetricsconnector | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add preliminary implementation as a connector. | ||
|
||
# One or more tracking issues related to the change | ||
issues: [18535] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
Validating CODEOWNERS rules …
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
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,107 @@ | ||
# Span Metrics Connector | ||
|
||
| Status | | | ||
|------------------------- |---------------------------------------------------------- | | ||
| Stability | [development] | | ||
| Supported pipeline types | See [Supported Pipeline Types](#supported-pipeline-types) | | ||
| Distributions | [] | | ||
|
||
## Supported Pipeline Types | ||
|
||
| [Exporter Pipeline Type] | [Receiver Pipeline Type] | | ||
| ------------------------ | ------------------------ | | ||
| traces | metrics | | ||
|
||
## Overview | ||
|
||
Aggregates Request, Error and Duration (R.E.D) metrics from span data. | ||
|
||
**Request** counts are computed as the number of spans seen per unique set of dimensions, including Errors. | ||
For example, the following metric shows 142 calls: | ||
``` | ||
calls_total{http_method="GET",http_status_code="200",operation="/Address",service_name="shippingservice",span_kind="SPAN_KIND_SERVER",status_code="STATUS_CODE_UNSET"} 142 | ||
``` | ||
Multiple metrics can be aggregated if, for instance, a user wishes to view call counts just on `service_name` and `operation`. | ||
|
||
**Error** counts are computed from the Request counts which have an "Error" Status Code metric dimension. | ||
For example, the following metric indicates 220 errors: | ||
``` | ||
calls_total{http_method="GET",http_status_code="503",operation="/checkout",service_name="frontend",span_kind="SPAN_KIND_CLIENT",status_code="STATUS_CODE_ERROR"} 220 | ||
``` | ||
|
||
**Duration** is computed from the difference between the span start and end times and inserted into the | ||
relevant latency histogram time bucket for each unique set dimensions. | ||
For example, the following latency buckets indicate the vast majority of spans (9K) have a 100ms latency: | ||
``` | ||
latency_bucket{http_method="GET",http_status_code="200",label1="value1",operation="/Address",service_name="shippingservice",span_kind="SPAN_KIND_SERVER",status_code="STATUS_CODE_UNSET",le="2"} 327 | ||
latency_bucket{http_method="GET",http_status_code="200",label1="value1",operation="/Address",service_name="shippingservice",span_kind="SPAN_KIND_SERVER",status_code="STATUS_CODE_UNSET",le="6"} 751 | ||
latency_bucket{http_method="GET",http_status_code="200",label1="value1",operation="/Address",service_name="shippingservice",span_kind="SPAN_KIND_SERVER",status_code="STATUS_CODE_UNSET",le="10"} 1195 | ||
latency_bucket{http_method="GET",http_status_code="200",label1="value1",operation="/Address",service_name="shippingservice",span_kind="SPAN_KIND_SERVER",status_code="STATUS_CODE_UNSET",le="100"} 10180 | ||
latency_bucket{http_method="GET",http_status_code="200",label1="value1",operation="/Address",service_name="shippingservice",span_kind="SPAN_KIND_SERVER",status_code="STATUS_CODE_UNSET",le="250"} 10180 | ||
... | ||
``` | ||
|
||
Each metric will have _at least_ the following dimensions because they are common across all spans: | ||
- Service name | ||
- Operation | ||
- Span kind | ||
- Status code | ||
|
||
The following settings can be optionally configured: | ||
|
||
- `latency_histogram_buckets`: the list of durations defining the latency histogram buckets. | ||
- Default: `[2ms, 4ms, 6ms, 8ms, 10ms, 50ms, 100ms, 200ms, 400ms, 800ms, 1s, 1400ms, 2s, 5s, 10s, 15s]` | ||
- `dimensions`: the list of dimensions to add together with the default dimensions defined above. | ||
|
||
Each additional dimension is defined with a `name` which is looked up in the span's collection of attributes or | ||
resource attributes (AKA process tags) such as `ip`, `host.name` or `region`. | ||
|
||
If the `name`d attribute is missing in the span, the optional provided `default` is used. | ||
|
||
If no `default` is provided, this dimension will be **omitted** from the metric. | ||
- `dimensions_cache_size`: the max items number of `metric_key_to_dimensions_cache`. If not provided, will | ||
use default value size `1000`. | ||
- `aggregation_temporality`: Defines the aggregation temporality of the generated metrics. | ||
One of either `AGGREGATION_TEMPORALITY_CUMULATIVE` or `AGGREGATION_TEMPORALITY_DELTA`. | ||
- Default: `AGGREGATION_TEMPORALITY_CUMULATIVE` | ||
|
||
## Examples | ||
|
||
The following is a simple example usage of the spanmetrics connector. | ||
|
||
For configuration examples on other use cases, please refer to [More Examples](#more-examples). | ||
|
||
The full list of settings exposed for this connector are documented [here](../../processor/spanmetricsprocessor/config.go). | ||
|
||
```yaml | ||
receivers: | ||
nop: | ||
|
||
exporters: | ||
nop: | ||
|
||
connector: | ||
spanmetrics: | ||
latency_histogram_buckets: [100us, 1ms, 2ms, 6ms, 10ms, 100ms, 250ms] | ||
dimensions: | ||
- name: http.method | ||
default: GET | ||
- name: http.status_code | ||
dimensions_cache_size: 1000 | ||
aggregation_temporality: "AGGREGATION_TEMPORALITY_CUMULATIVE" | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [nop] | ||
exporters: [spanmetrics] | ||
metrics: | ||
receivers: [spanmetrics] | ||
exporters: [nop] | ||
``` | ||
### More Examples | ||
For more example configuration covering various other use cases, please visit the [testdata directory](../../processor/spanmetricsprocessor/testdata). | ||
[development]: https://github.com/open-telemetry/opentelemetry-collector#development |
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,19 @@ | ||
// Copyright The 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 spanmetricsconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector" | ||
|
||
import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanmetricsprocessor" | ||
|
||
var NewFactory = spanmetricsprocessor.NewConnectorFactory |
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,65 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector | ||
|
||
go 1.19 | ||
|
||
require github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanmetricsprocessor v0.71.0 | ||
|
||
require ( | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/hashicorp/golang-lru v0.6.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/knadh/koanf v1.5.0 // indirect | ||
github.com/mitchellh/copystructure v1.2.0 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.71.0 // indirect | ||
github.com/tilinna/clock v1.1.0 // indirect | ||
go.opentelemetry.io/collector v0.71.0 // indirect | ||
go.opentelemetry.io/collector/component v0.71.0 // indirect | ||
go.opentelemetry.io/collector/confmap v0.71.0 // indirect | ||
go.opentelemetry.io/collector/consumer v0.71.0 // indirect | ||
go.opentelemetry.io/collector/featuregate v0.71.0 // indirect | ||
go.opentelemetry.io/collector/pdata v1.0.0-rc5 // indirect | ||
go.opentelemetry.io/collector/semconv v0.71.0 // indirect | ||
go.opentelemetry.io/otel v1.13.0 // indirect | ||
go.opentelemetry.io/otel/metric v0.36.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.13.0 // indirect | ||
go.uber.org/atomic v1.10.0 // indirect | ||
go.uber.org/multierr v1.9.0 // indirect | ||
go.uber.org/zap v1.24.0 // indirect | ||
golang.org/x/net v0.5.0 // indirect | ||
golang.org/x/sys v0.4.0 // indirect | ||
golang.org/x/text v0.6.0 // indirect | ||
google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2 // indirect | ||
google.golang.org/grpc v1.52.3 // indirect | ||
google.golang.org/protobuf v1.28.1 // indirect | ||
) | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite => ../../pkg/translator/prometheusremotewrite | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter => ../../exporter/prometheusremotewriteexporter | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus => ../../pkg/translator/prometheus | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger => ../../pkg/translator/jaeger | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver => ../../receiver/jaegerreceiver | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => ../../receiver/prometheusreceiver | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter => ../../exporter/jaegerexporter | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanmetricsprocessor => ../../processor/spanmetricsprocessor | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry => ../../pkg/resourcetotelemetry | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter => ../../exporter/prometheusexporter | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil |
Oops, something went wrong.