Skip to content

Commit

Permalink
Merge branch 'main' into origin/zcross/jaegerremotesampling/support-r…
Browse files Browse the repository at this point in the history
…emote-policy-ttl-caching
  • Loading branch information
Aneurysm9 authored Aug 11, 2023
2 parents caca5b5 + e42f386 commit d061cb3
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .chloggen/awsemfexporter-publish-initial-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# 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. filelogreceiver)
component: awsemfexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add retain_initial_value_of_delta_metric to translateOTelToGroupedMetric, allowing the initial set of metrics to be published

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [24051]

# (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:
12 changes: 7 additions & 5 deletions exporter/awsemfexporter/metric_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (mt metricTranslator) translateOTelToGroupedMetric(rm pmetric.ResourceMetri
var instrumentationScopeName string
cWNamespace := getNamespace(rm, config.Namespace)
logGroup, logStream, patternReplaceSucceeded := getLogInfo(rm, cWNamespace, config)
deltaInitialValue := config.RetainInitialValueOfDeltaMetric

ilms := rm.ScopeMetrics()
var metricReceiver string
Expand All @@ -134,11 +135,12 @@ func (mt metricTranslator) translateOTelToGroupedMetric(rm pmetric.ResourceMetri
metric := metrics.At(k)
metadata := cWMetricMetadata{
groupedMetricMetadata: groupedMetricMetadata{
namespace: cWNamespace,
timestampMs: timestamp,
logGroup: logGroup,
logStream: logStream,
metricDataType: metric.Type(),
namespace: cWNamespace,
timestampMs: timestamp,
logGroup: logGroup,
logStream: logStream,
metricDataType: metric.Type(),
retainInitialValueForDelta: deltaInitialValue,
},
instrumentationScopeName: instrumentationScopeName,
receiver: metricReceiver,
Expand Down
30 changes: 30 additions & 0 deletions exporter/awsemfexporter/metric_translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,36 @@ func TestTranslateOtToGroupedMetricForLogGroupAndStream(t *testing.T) {
}
}

func TestTranslateOtToGroupedMetricForInitialDeltaValue(t *testing.T) {
for _, test := range logGroupStreamTestCases {
t.Run(test.name, func(t *testing.T) {
config := &Config{
Namespace: "",
LogGroupName: test.inLogGroupName,
LogStreamName: test.inLogStreamName,
DimensionRollupOption: zeroAndSingleDimensionRollup,
logger: zap.NewNop(),
RetainInitialValueOfDeltaMetric: true,
}

translator := newMetricTranslator(*config)

groupedMetrics := make(map[interface{}]*groupedMetric)

rm := test.inputMetrics.ResourceMetrics().At(0)
err := translator.translateOTelToGroupedMetric(rm, groupedMetrics, config)
assert.Nil(t, err)

assert.NotNil(t, groupedMetrics)
assert.Equal(t, 1, len(groupedMetrics))

for _, actual := range groupedMetrics {
assert.True(t, actual.metadata.retainInitialValueForDelta)
}
})
}
}

func generateTestMetrics(tm testMetric) pmetric.Metrics {
md := pmetric.NewMetrics()
now := time.Now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func SerializeMetric(logger *zap.Logger, prefix string, metric pmetric.Metric, d

ce := logger.Check(zap.DebugLevel, "SerializeMetric")
var points int

//exhaustive:enforce
switch metric.Type() {
case pmetric.MetricTypeGauge:
metricLines = serializeGauge(logger, prefix, metric, defaultDimensions, staticDimensions, metricLines)
Expand Down
1 change: 1 addition & 0 deletions exporter/googlecloudpubsubexporter/watermark.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func traverseMetrics(metrics pmetric.Metrics, collect collectFunc) {
l := r.ScopeMetrics().At(lix)
for dix := 0; dix < l.Metrics().Len(); dix++ {
d := l.Metrics().At(dix)
//exhaustive:enforce
switch d.Type() {
case pmetric.MetricTypeHistogram:
for pix := 0; pix < d.Histogram().DataPoints().Len(); pix++ {
Expand Down
3 changes: 3 additions & 0 deletions exporter/skywalkingexporter/metricrecord_to_metricdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func doubleSummaryMetricsToData(name string, data pmetric.SummaryDataPointSlice,
}

func metricDataToSwMetricData(md pmetric.Metric, defaultLabels []*metricpb.Label) (metrics []*metricpb.MeterData) {
//exhaustive:enforce
switch md.Type() {
case pmetric.MetricTypeEmpty:
break
Expand All @@ -196,6 +197,8 @@ func metricDataToSwMetricData(md pmetric.Metric, defaultLabels []*metricpb.Label
return doubleHistogramMetricsToData(md.Name(), md.Histogram().DataPoints(), defaultLabels)
case pmetric.MetricTypeSummary:
return doubleSummaryMetricsToData(md.Name(), md.Summary().DataPoints(), defaultLabels)
case pmetric.MetricTypeExponentialHistogram:
return nil
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/sumologicexporter/carbon_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func carbon2NumberRecord(record metricPair, dataPoint pmetric.NumberDataPoint) s
// carbon2metric2String converts metric to Carbon2 formatted string.
func carbon2Metric2String(record metricPair) string {
var nextLines []string

//exhaustive:enforce
switch record.metric.Type() {
case pmetric.MetricTypeGauge:
dps := record.metric.Gauge().DataPoints()
Expand Down
2 changes: 1 addition & 1 deletion exporter/sumologicexporter/graphite_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (gf *graphiteFormatter) metric2String(record metricPair) string {
var nextLines []string
fs := newFields(record.attributes)
name := record.metric.Name()

//exhaustive:enforce
switch record.metric.Type() {
case pmetric.MetricTypeGauge:
dps := record.metric.Gauge().DataPoints()
Expand Down
3 changes: 2 additions & 1 deletion exporter/sumologicexporter/prometheus_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (f *prometheusFormatter) histogram2Strings(record metricPair) []string {
// metric2String returns stringified metricPair
func (f *prometheusFormatter) metric2String(record metricPair) string {
var lines []string

//exhaustive:enforce
switch record.metric.Type() {
case pmetric.MetricTypeGauge:
lines = f.gauge2Strings(record)
Expand All @@ -321,6 +321,7 @@ func (f *prometheusFormatter) metric2String(record metricPair) string {
lines = f.summary2Strings(record)
case pmetric.MetricTypeHistogram:
lines = f.histogram2Strings(record)
case pmetric.MetricTypeExponentialHistogram:
}
return strings.Join(lines, "\n")
}

0 comments on commit d061cb3

Please sign in to comment.