Skip to content

Commit

Permalink
Merge pull request #15 from influxdata/main
Browse files Browse the repository at this point in the history
Chore: Merge fro main
  • Loading branch information
Jayclifford345 authored Oct 12, 2023
2 parents 2d0089d + d0aa707 commit b91966b
Show file tree
Hide file tree
Showing 37 changed files with 1,518 additions and 1,233 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ jobs:

- name: build
run: >
go install go.opentelemetry.io/collector/cmd/builder@v0.81.0 &&
go install go.opentelemetry.io/collector/cmd/builder@v0.87.0 &&
cd otelcol-influxdb &&
builder --config build.yml
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
docker:
Expand Down
11 changes: 8 additions & 3 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
MetricHistogramSumFieldKey = "sum"
MetricHistogramMinFieldKey = "min"
MetricHistogramMaxFieldKey = "max"
MetricHistogramInfFieldKey = "inf"
MetricHistogramInfFieldKey = "+Inf"
MetricHistogramBoundKeyV2 = "le"
MetricHistogramCountSuffix = "_count"
MetricHistogramSumSuffix = "_sum"
Expand All @@ -43,13 +43,17 @@ const (
MetricSummaryQuantileKeyV2 = "quantile"
MetricSummaryCountSuffix = "_count"
MetricSummarySumSuffix = "_sum"
MetricExemplarSuffix = "_exemplar"

// These attribute key names are influenced by the proto message keys.
// https://github.com/open-telemetry/opentelemetry-proto/blob/abbf7b7b49a5342d0d6c0e86e91d713bbedb6580/opentelemetry/proto/trace/v1/trace.proto
// https://github.com/open-telemetry/opentelemetry-proto/blob/abbf7b7b49a5342d0d6c0e86e91d713bbedb6580/opentelemetry/proto/metrics/v1/metrics.proto
// https://github.com/open-telemetry/opentelemetry-proto/blob/abbf7b7b49a5342d0d6c0e86e91d713bbedb6580/opentelemetry/proto/logs/v1/logs.proto
AttributeTime = "time"
AttributeStartTimeUnixNano = "start_time_unix_nano"
AttributeTime = "time"
AttributeStartTimeUnixNano = "start_time_unix_nano"
AttributeObservedTimeUnixNano = "observed_time_unix_nano"
// string formatted RFC3339, used by the otel statsd input plugin
AttributeStartTimeStatsd = "start_time"
AttributeTraceID = "trace_id"
AttributeSpanID = "span_id"
AttributeTraceState = "trace_state"
Expand All @@ -67,4 +71,5 @@ const (
AttributeSeverityNumber = "severity_number"
AttributeSeverityText = "severity_text"
AttributeBody = "body"
AttributeFlags = "flags"
)
2 changes: 1 addition & 1 deletion common/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/semconv v0.82.0
go.opentelemetry.io/collector/semconv v0.87.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions common/go.sum

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

3 changes: 2 additions & 1 deletion demo/docker-compose-development.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:

jaeger-query:
image: jaegertracing/jaeger-query:1.45
image: jaegertracing/jaeger-query:1.49
stop_grace_period: 10s
ports:
- "16686:16686" # web UI
Expand All @@ -16,6 +16,7 @@ services:
QUERY_HTTP_SERVER_HOST_PORT: :16686
ADMIN_HTTP_HOST_PORT: :16687
QUERY_UI_CONFIG: /jaeger-ui-config.json
QUERY_ENABLE_TRACING: false
volumes:
- ./demo/jaeger-ui-config.json:/jaeger-ui-config.json:ro

Expand Down
6 changes: 3 additions & 3 deletions demo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
jaeger-query:
image: jaegertracing/jaeger-query:1.45
image: jaegertracing/jaeger-query:1.49
stop_grace_period: 10s
ports:
- "16686:16686" # web UI
Expand All @@ -19,7 +19,7 @@ services:
- ./demo/jaeger-ui-config.json:/jaeger-ui-config.json:ro

jaeger-influxdb:
image: jacobmarble/jaeger-influxdb:0.5.2
image: jacobmarble/jaeger-influxdb:0.5.9
stop_grace_period: 10s
environment:
LOG_LEVEL: debug
Expand All @@ -41,7 +41,7 @@ services:
command: ["all", "-m", "prometheus"]

otelcol-influxdb:
image: otel/opentelemetry-collector-contrib:0.81.0
image: otel/opentelemetry-collector-contrib:0.87.0
command: [ "--config", "/config.yml" ]
stop_grace_period: 10s
volumes:
Expand Down
20 changes: 10 additions & 10 deletions influx2otel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/influxdata/influxdb-observability/influx2otel
go 1.19

require (
github.com/influxdata/influxdb-observability/common v0.5.5
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.82.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.82.0
github.com/influxdata/influxdb-observability/common v0.5.8
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.87.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.87.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014
go.opentelemetry.io/collector/semconv v0.82.0
go.opentelemetry.io/collector/pdata v1.0.0-rcv0016
go.opentelemetry.io/collector/semconv v0.87.0
)

require (
Expand All @@ -21,11 +21,11 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.57.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.2 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
38 changes: 19 additions & 19 deletions influx2otel/go.sum

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

27 changes: 15 additions & 12 deletions influx2otel/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package influx2otel
import (
"errors"
"fmt"
"math"
"sort"
"time"

Expand Down Expand Up @@ -91,7 +92,7 @@ func (b *MetricsBatch) lookupMetric(metricName string, tags map[string]string, v
rAttributes.PutStr(k, v)
case k == "temporality" && v == "delta":
isDelta = true
case k == "start_time":
case k == common.AttributeStartTimeStatsd:
default:
mAttributes.PutStr(k, v)
}
Expand All @@ -111,10 +112,10 @@ func (b *MetricsBatch) lookupMetric(metricName string, tags map[string]string, v

ilmKey := ilName + ":" + ilVersion
if _, found := b.ilmByRMAttributesAndIL[rKey][ilmKey]; !found {
ilMetrics := resourceMetrics.ScopeMetrics().AppendEmpty()
ilMetrics.Scope().SetName(ilName)
ilMetrics.Scope().SetVersion(ilVersion)
b.ilmByRMAttributesAndIL[rKey][ilmKey] = ilMetrics
isMetrics := resourceMetrics.ScopeMetrics().AppendEmpty()
isMetrics.Scope().SetName(ilName)
isMetrics.Scope().SetVersion(ilVersion)
b.ilmByRMAttributesAndIL[rKey][ilmKey] = isMetrics
b.metricByRMIL[rKey][ilmKey] = make(map[string]pmetric.Metric)
}

Expand Down Expand Up @@ -178,16 +179,18 @@ func (b *MetricsBatch) lookupMetric(metricName string, tags map[string]string, v

func (b *MetricsBatch) GetMetrics() pmetric.Metrics {
metrics := pmetric.NewMetrics()
// Ensure that the extra bucket counts have been added.
// Ensure that infinity histogram buckets exist.
for _, resourceMetrics := range b.rmByAttributes {
for i := 0; i < resourceMetrics.ScopeMetrics().Len(); i++ {
ilMetrics := resourceMetrics.ScopeMetrics().At(i)
for j := 0; j < ilMetrics.Metrics().Len(); j++ {
metric := ilMetrics.Metrics().At(j)
isMetrics := resourceMetrics.ScopeMetrics().At(i)
for j := 0; j < isMetrics.Metrics().Len(); j++ {
metric := isMetrics.Metrics().At(j)
if metric.Type() == pmetric.MetricTypeHistogram {
for k := 0; k < metric.Histogram().DataPoints().Len(); k++ {
dataPoint := metric.Histogram().DataPoints().At(k)
if dataPoint.BucketCounts().Len() == dataPoint.ExplicitBounds().Len() {
if dataPoint.ExplicitBounds().Len() > 0 && math.IsInf(dataPoint.ExplicitBounds().At(dataPoint.ExplicitBounds().Len()-1), +1) {
dataPoint.ExplicitBounds().FromRaw(dataPoint.ExplicitBounds().AsRaw()[:dataPoint.ExplicitBounds().Len()-1])
} else if dataPoint.BucketCounts().Len() == dataPoint.ExplicitBounds().Len() {
infBucketCount := dataPoint.Count()
for l := 0; l < dataPoint.BucketCounts().Len(); l++ {
infBucketCount -= dataPoint.BucketCounts().At(l)
Expand All @@ -214,7 +217,7 @@ func (b *MetricsBatch) addPointWithUnknownSchema(measurement string, tags map[st
}

for k, v := range fields {
if k == "start_time" {
if k == common.AttributeStartTimeStatsd {
continue
}
var floatValue *float64
Expand Down Expand Up @@ -242,7 +245,7 @@ func (b *MetricsBatch) addPointWithUnknownSchema(measurement string, tags map[st
dataPoint.SetTimestamp(pcommon.NewTimestampFromTime(ts))
// set start_time, if exists and is RFC3339
// used by statsd input plugin
if startTimeObj, ok := fields["start_time"]; ok {
if startTimeObj, ok := fields[common.AttributeStartTimeStatsd]; ok {
if startTimeStr, ok := startTimeObj.(string); ok {
if t, err := time.Parse(time.RFC3339, startTimeStr); err == nil {
dataPoint.SetStartTimestamp(pcommon.NewTimestampFromTime(t))
Expand Down
Loading

0 comments on commit b91966b

Please sign in to comment.