Skip to content

Commit

Permalink
[processor/deltatocumulative]: mdatagen telemetry
Browse files Browse the repository at this point in the history
Uses recently introducted `telemetry:` feature of `mdatagen` to define
the internal telemetry exported from this component.

Leaves the general `telemetry` package in-place, as it also does error
handling (for now). Changing so requires a deeper refactor that will be
done later
  • Loading branch information
sh0rez committed Jul 18, 2024
1 parent e7c5b97 commit 52c9ae9
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 88 deletions.
14 changes: 2 additions & 12 deletions processor/deltatocumulativeprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,5 @@ There is no further configuration required. All delta samples are converted to c

## Troubleshooting

The following metrics are recorded when [telemetry is
enabled](https://opentelemetry.io/docs/collector/configuration/#telemetry):

| Name | Description | Unit |
|------------------------------------------|---------------------------------------------------------------------------------------|---------------|
| `deltatocumulative.streams.tracked` | Number of streams currently tracked by the aggregation state | `{stream}` |
| `deltatocumulative.streams.limit` | Upper limit of tracked streams | `{stream}` |
| `deltatocumulative.streams.evicted` | Number of streams removed from tracking to ingest newer streams | `{stream}` |
| `deltatocumulative.streams.max_stale` | Duration without new samples after which streams are dropped | `second` |
| `deltatocumulative.datapoints.processed` | Total number of datapoints processed, whether successful or not | `{datapoint}` |
| `deltatocumulative.datapoints.dropped` | Faulty datapoints that were dropped due to the reason given in the `reason` attribute | `{datapoint}` |
| `deltatocumulative.gaps.length` | Total length of all gaps in the streams, which occur e.g. due to lost in transit | `second` |
When [Telemetry is
enabled](https://opentelemetry.io/docs/collector/configuration/#telemetry), this component exports [several metrics](./documentation.md).
63 changes: 63 additions & 0 deletions processor/deltatocumulativeprocessor/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# deltatocumulative

## Internal Telemetry

The following telemetry is emitted by this component.

### deltatocumulative.datapoints.dropped

number of datapoints dropped due to given 'reason'

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {datapoint} | Sum | Int | true |

### deltatocumulative.datapoints.processed

number of datapoints processed

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {datapoint} | Sum | Int | true |

### deltatocumulative.gaps.length

total duration where data was expected but not received

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| s | Sum | Int | true |

### deltatocumulative.streams.evicted

number of streams evicted

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {stream} | Sum | Int | true |

### deltatocumulative.streams.limit

upper limit of tracked streams

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {stream} | Gauge | Int |

### deltatocumulative.streams.max_stale

duration after which streams inactive streams are dropped

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| s | Gauge | Int |

### deltatocumulative.streams.tracked

number of streams tracked

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| {dps} | Sum | Int | false |
8 changes: 6 additions & 2 deletions processor/deltatocumulativeprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func createMetricsProcessor(_ context.Context, set processor.Settings, cfg compo
return nil, fmt.Errorf("configuration parsing error")
}

meter := metadata.Meter(set.TelemetrySettings)
return newProcessor(pcfg, set.Logger, meter, next), nil
telb, err := metadata.NewTelemetryBuilder(set.TelemetrySettings)
if err != nil {
return nil, err
}

return newProcessor(pcfg, set.Logger, telb, next), nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/otel/metric/noop"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/data"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/delta"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/streams"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/telemetry"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/testdata/random"
Expand Down Expand Up @@ -112,10 +114,13 @@ func TestFaults(t *testing.T) {
},
}

telb, err := metadata.NewTelemetryBuilder(component.TelemetrySettings{MeterProvider: noop.NewMeterProvider()})
require.NoError(t, err)

for _, c := range cases {
t.Run(c.Name, func(t *testing.T) {
id, dp := sum.Stream()
tel := telemetry.New(noop.Meter{})
tel := telemetry.New(telb)

dps := c.Map
if dps == nil {
Expand Down
Loading

0 comments on commit 52c9ae9

Please sign in to comment.