Skip to content

Commit

Permalink
Merge branch 'main' into feature-command
Browse files Browse the repository at this point in the history
  • Loading branch information
danish9039 authored Jan 23, 2025
2 parents 4a2527a + 50de4a2 commit 829ba55
Show file tree
Hide file tree
Showing 69 changed files with 791 additions and 732 deletions.
25 changes: 25 additions & 0 deletions .chloggen/extracttesttel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: componenttest

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Extract componenttest.Telemetry as generic struct for telemetry testing

# One or more tracking issues or pull requests related to the change
issues: [12151]

# (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:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
25 changes: 25 additions & 0 deletions .chloggen/fix-bug-histogram-aggregation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix bug where Histograms were marked as not supporting temporaly aggregation

# One or more tracking issues or pull requests related to the change
issues: [12168]

# (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:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api, user]
25 changes: 25 additions & 0 deletions .chloggen/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: cmd/mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Allow passing OTel Metric SDK options to the generated `SetupTelemetry` function.

# One or more tracking issues or pull requests related to the change
issues: [12166]

# (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:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
25 changes: 25 additions & 0 deletions .chloggen/opbexp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: exporterhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Change exporter ID to be a Span level attribute instead on each event.

# One or more tracking issues or pull requests related to the change
issues: [12164]

# (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: This does not have an impact on the level of information emitted, but on the structure of the Span.

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
File renamed without changes.
6 changes: 3 additions & 3 deletions cmd/mdatagen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v0.118.0
go.opentelemetry.io/collector/component/componenttest v0.118.0
go.opentelemetry.io/collector/config/configtelemetry v0.118.0
go.opentelemetry.io/collector/confmap v1.24.0
go.opentelemetry.io/collector/confmap/provider/fileprovider v1.24.0
go.opentelemetry.io/collector/consumer v1.24.0
Expand All @@ -23,11 +22,9 @@ require (
go.opentelemetry.io/collector/scraper/scrapertest v0.118.0
go.opentelemetry.io/collector/semconv v0.118.0
go.opentelemetry.io/otel/metric v1.34.0
go.opentelemetry.io/otel/sdk v1.34.0
go.opentelemetry.io/otel/sdk/metric v1.34.0
go.opentelemetry.io/otel/trace v1.34.0
go.uber.org/goleak v1.3.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
golang.org/x/text v0.21.0
)
Expand All @@ -52,6 +49,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/collector/component/componentstatus v0.118.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.118.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.118.0 // indirect
go.opentelemetry.io/collector/consumer/xconsumer v0.118.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.118.0 // indirect
Expand All @@ -60,6 +58,8 @@ require (
go.opentelemetry.io/collector/processor/xprocessor v0.118.0 // indirect
go.opentelemetry.io/collector/receiver/xreceiver v0.118.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.29.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
Expand Down
2 changes: 1 addition & 1 deletion cmd/mdatagen/internal/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (d *Histogram) HasMonotonic() bool {
}

func (d *Histogram) HasAggregated() bool {
return false
return true
}

func (d *Histogram) Instrument() string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/mdatagen/internal/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestMetricData(t *testing.T) {
{&Sum{Async: true}, "Sum", true, true, "ObservableUpDownCounter", true},
{&Sum{MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeInt}, Async: true}, "Sum", true, true, "Int64ObservableUpDownCounter", true},
{&Sum{MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeDouble}, Async: true}, "Sum", true, true, "Float64ObservableUpDownCounter", true},
{&Histogram{}, "Histogram", false, false, "Histogram", false},
{&Histogram{}, "Histogram", true, false, "Histogram", false},
} {
assert.Equal(t, arg.wantType, arg.metricData.Type())
assert.Equal(t, arg.wantHasAggregated, arg.metricData.HasAggregated())
Expand Down

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

40 changes: 5 additions & 35 deletions cmd/mdatagen/internal/templates/telemetrytest.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,25 @@ import (
"testing"

"github.com/stretchr/testify/require"
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/sdk/trace/tracetest"
"go.uber.org/multierr"

{{- if or isConnector isExporter isExtension isProcessor isReceiver isScraper }}
"go.opentelemetry.io/collector/component"
{{- end }}
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/configtelemetry"
{{- if or isConnector isExporter isExtension isProcessor isReceiver isScraper }}
"go.opentelemetry.io/collector/{{ .Status.Class }}"
"go.opentelemetry.io/collector/{{ .Status.Class }}/{{ .Status.Class }}test"
{{- end }}
)

type Telemetry struct {
Reader *sdkmetric.ManualReader
SpanRecorder *tracetest.SpanRecorder

meterProvider *sdkmetric.MeterProvider
traceProvider *sdktrace.TracerProvider
componenttest.Telemetry
}

func SetupTelemetry() Telemetry {
reader := sdkmetric.NewManualReader()
spanRecorder := new(tracetest.SpanRecorder)
return Telemetry{
Reader: reader,
SpanRecorder: spanRecorder,

meterProvider: sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader)),
traceProvider: sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(spanRecorder)),
}
func SetupTelemetry(opts ...componenttest.TelemetryOption) Telemetry {
return Telemetry{ Telemetry: componenttest.NewTelemetry(opts...) }
}

{{- if or isConnector isExporter isExtension isProcessor isReceiver isScraper }}
Expand All @@ -52,14 +37,6 @@ func (tt *Telemetry) NewSettings() {{ .Status.Class }}.Settings {
}
{{- end }}

func (tt *Telemetry) NewTelemetrySettings() component.TelemetrySettings {
set := componenttest.NewNopTelemetrySettings()
set.MeterProvider = tt.meterProvider
set.MetricsLevel = configtelemetry.LevelDetailed
set.TracerProvider = tt.traceProvider
return set
}

func (tt *Telemetry) AssertMetrics(t *testing.T, expected []metricdata.Metrics, opts ...metricdatatest.Option) {
var md metricdata.ResourceMetrics
require.NoError(t, tt.Reader.Collect(context.Background(), &md))
Expand All @@ -73,13 +50,6 @@ func (tt *Telemetry) AssertMetrics(t *testing.T, expected []metricdata.Metrics,
require.Equal(t, len(expected), lenMetrics(md))
}

func (tt *Telemetry) Shutdown(ctx context.Context) error {
return multierr.Combine(
tt.meterProvider.Shutdown(ctx),
tt.traceProvider.Shutdown(ctx),
)
}

func getMetric(name string, got metricdata.ResourceMetrics) metricdata.Metrics {
for _, sm := range got.ScopeMetrics {
for _, m := range sm.Metrics {
Expand Down
6 changes: 3 additions & 3 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ require (
go.opentelemetry.io/contrib/bridges/otelzap v0.9.0 // indirect
go.opentelemetry.io/contrib/config v0.10.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.31.0 // indirect
go.opentelemetry.io/contrib/zpages v0.56.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.34.0 // indirect
go.opentelemetry.io/contrib/zpages v0.59.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.34.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions cmd/otelcorecol/go.sum

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

Loading

0 comments on commit 829ba55

Please sign in to comment.