Skip to content

Commit

Permalink
Merge branch 'main' into add-link
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Mar 27, 2024
2 parents c1e595b + 9e34895 commit 9f0364c
Show file tree
Hide file tree
Showing 107 changed files with 1,302 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Generate
run: make generate
- name: Run linters
run: make dependabot-check license-check lint vanity-import-check
run: make dependabot-check license-check lint vanity-import-check verify-readmes
- name: Build
run: make build
- name: Check clean repository
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/links-fail-fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ jobs:
uses: lycheeverse/lychee-action@v1.9.3
with:
fail: true
args: --max-concurrency 5 .
2 changes: 2 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1.9.3
with:
args: --max-concurrency 5 .

- name: Create Issue From File
if: steps.lychee.outputs.exit_code != 0
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add `go.opentelemetry.io/otel/log/global` to manage the global `LoggerProvider`.
This package is provided with the anticipation that all functionality will be migrate to `go.opentelemetry.io/otel` when `go.opentelemetry.io/otel/log` stabilizes.
At which point, users will be required to migrage their code, and this package will be deprecated then removed. (#5085)
- Add support for `Summary` metrics in the `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` exporters. (#5100)
- Add `otel.scope.name` and `otel.scope.version` tags to spans exported by `go.opentelemetry.io/otel/exporters/zipkin`. (#5108)

### Changed

Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ You can install and run a "local Go Doc site" in the following way:
[`go.opentelemetry.io/otel/metric`](https://pkg.go.dev/go.opentelemetry.io/otel/metric)
is an example of a very well-documented package.

### README files

Each (non-internal, non-test, non-documentation) package must contain a
`README.md` file containing at least a title, and a `pkg.go.dev` badge.

The README should not be a repetition of Go doc comments.

You can verify the presence of all README files with the `make verify-readmes`
command.

## Style Guide

One of the primary goals of this project is that it is actually used by
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ TIMEOUT = 60
.DEFAULT_GOAL := precommit

.PHONY: precommit ci
precommit: generate dependabot-generate license-check misspell go-mod-tidy golangci-lint-fix test-default
ci: generate dependabot-check license-check lint vanity-import-check build test-default check-clean-work-tree test-coverage
precommit: generate dependabot-generate license-check misspell go-mod-tidy golangci-lint-fix verify-readmes test-default
ci: generate dependabot-check license-check lint vanity-import-check verify-readmes build test-default check-clean-work-tree test-coverage

# Tools

Expand Down Expand Up @@ -305,3 +305,7 @@ add-tags: | $(MULTIMOD)
.PHONY: lint-markdown
lint-markdown:
docker run -v "$(CURDIR):$(WORKDIR)" avtodev/markdown-lint:v1 -c $(WORKDIR)/.markdownlint.yaml $(WORKDIR)/**/*.md

.PHONY: verify-readmes
verify-readmes:
./verify_readmes.sh
3 changes: 3 additions & 0 deletions attribute/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Attribute

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/attribute)](https://pkg.go.dev/go.opentelemetry.io/otel/attribute)
3 changes: 3 additions & 0 deletions baggage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Baggage

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/baggage)](https://pkg.go.dev/go.opentelemetry.io/otel/baggage)
3 changes: 3 additions & 0 deletions bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Bridge

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/bridge)](https://pkg.go.dev/go.opentelemetry.io/otel/bridge)
3 changes: 3 additions & 0 deletions bridge/opencensus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OpenTelemetry/OpenCensus Bridge

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/bridge/opencensus)](https://pkg.go.dev/go.opentelemetry.io/otel/bridge/opencensus)
3 changes: 3 additions & 0 deletions bridge/opentracing/migration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OpenTracing Migration

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/bridge/opentracing/migration)](https://pkg.go.dev/go.opentelemetry.io/otel/bridge/opentracing/migration)
3 changes: 3 additions & 0 deletions codes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Codes

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/codes)](https://pkg.go.dev/go.opentelemetry.io/otel/codes)
3 changes: 3 additions & 0 deletions exporters/otlp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OTLP Exporters

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/otlp)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp)
3 changes: 3 additions & 0 deletions exporters/otlp/otlpmetric/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OTLP Metric Exporters

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/otlpmetric)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlpmetric)
3 changes: 3 additions & 0 deletions exporters/otlp/otlpmetric/otlpmetricgrpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OTLP Metric gRPC Exporter

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc)
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out.Data, err = ExponentialHistogram(a)
case metricdata.ExponentialHistogram[float64]:
out.Data, err = ExponentialHistogram(a)
case metricdata.Summary:
out.Data = Summary(a)
default:
return out, fmt.Errorf("%w: %T", errUnknownAggregation, a)
}
Expand Down Expand Up @@ -307,3 +309,44 @@ func Exemplars[N int64 | float64](exemplars []metricdata.Exemplar[N]) []*mpb.Exe
}
return out
}

// Summary returns an OTLP Metric_Summary generated from s.
func Summary(s metricdata.Summary) *mpb.Metric_Summary {
return &mpb.Metric_Summary{
Summary: &mpb.Summary{
DataPoints: SummaryDataPoints(s.DataPoints),
},
}
}

// SummaryDataPoints returns a slice of OTLP SummaryDataPoint generated from
// dPts.
func SummaryDataPoints(dPts []metricdata.SummaryDataPoint) []*mpb.SummaryDataPoint {
out := make([]*mpb.SummaryDataPoint, 0, len(dPts))
for _, dPt := range dPts {
sdp := &mpb.SummaryDataPoint{
Attributes: AttrIter(dPt.Attributes.Iter()),
StartTimeUnixNano: timeUnixNano(dPt.StartTime),
TimeUnixNano: timeUnixNano(dPt.Time),
Count: dPt.Count,
Sum: dPt.Sum,
QuantileValues: QuantileValues(dPt.QuantileValues),
}
out = append(out, sdp)
}
return out
}

// QuantileValues returns a slice of OTLP SummaryDataPoint_ValueAtQuantile
// generated from quantiles.
func QuantileValues(quantiles []metricdata.QuantileValue) []*mpb.SummaryDataPoint_ValueAtQuantile {
out := make([]*mpb.SummaryDataPoint_ValueAtQuantile, 0, len(quantiles))
for _, q := range quantiles {
quantile := &mpb.SummaryDataPoint_ValueAtQuantile{
Quantile: q.Quantile,
Value: q.Value,
}
out = append(out, quantile)
}
return out
}
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,83 @@ var (
DataPoints: pbEHDPFloat64,
}

quantileValuesA = []metricdata.QuantileValue{
{
Quantile: 0.0,
Value: 0.1,
},
{
Quantile: 0.5,
Value: 1.0,
},
{
Quantile: 1.0,
Value: 10.4,
},
}
quantileValuesB = []metricdata.QuantileValue{
{
Quantile: 0.0,
Value: 0.5,
},
{
Quantile: 0.5,
Value: 3.1,
},
{
Quantile: 1.0,
Value: 8.3,
},
}

pbQuantileValuesA = []*mpb.SummaryDataPoint_ValueAtQuantile{
{
Quantile: 0.0,
Value: 0.1,
},
{
Quantile: 0.5,
Value: 1.0,
},
{
Quantile: 1.0,
Value: 10.4,
},
}
pbQuantileValuesB = []*mpb.SummaryDataPoint_ValueAtQuantile{
{
Quantile: 0.0,
Value: 0.5,
},
{
Quantile: 0.5,
Value: 3.1,
},
{
Quantile: 1.0,
Value: 8.3,
},
}

otelSummaryDPts = []metricdata.SummaryDataPoint{
{
Attributes: alice,
StartTime: start,
Time: end,
Count: 20,
Sum: sumA,
QuantileValues: quantileValuesA,
},
{
Attributes: bob,
StartTime: start,
Time: end,
Count: 26,
Sum: sumB,
QuantileValues: quantileValuesB,
},
}

otelDPtsInt64 = []metricdata.DataPoint[int64]{
{
Attributes: alice,
Expand Down Expand Up @@ -498,6 +575,25 @@ var (
},
}

pbDPtsSummary = []*mpb.SummaryDataPoint{
{
Attributes: []*cpb.KeyValue{pbAlice},
StartTimeUnixNano: uint64(start.UnixNano()),
TimeUnixNano: uint64(end.UnixNano()),
Count: 20,
Sum: sumA,
QuantileValues: pbQuantileValuesA,
},
{
Attributes: []*cpb.KeyValue{pbBob},
StartTimeUnixNano: uint64(start.UnixNano()),
TimeUnixNano: uint64(end.UnixNano()),
Count: 26,
Sum: sumB,
QuantileValues: pbQuantileValuesB,
},
}

otelSumInt64 = metricdata.Sum[int64]{
Temporality: metricdata.CumulativeTemporality,
IsMonotonic: true,
Expand Down Expand Up @@ -551,6 +647,10 @@ var (
},
}}

pbSummary = &mpb.Summary{DataPoints: pbDPtsSummary}

otelSummary = metricdata.Summary{DataPoints: otelSummaryDPts}

unknownAgg unknownAggT
otelMetrics = []metricdata.Metrics{
{
Expand Down Expand Up @@ -631,6 +731,12 @@ var (
Unit: "1",
Data: otelGaugeZeroStartTime,
},
{
Name: "summary",
Description: "Summary metric",
Unit: "1",
Data: otelSummary,
},
}

pbMetrics = []*mpb.Metric{
Expand Down Expand Up @@ -688,6 +794,12 @@ var (
Unit: "1",
Data: &mpb.Metric_Gauge{Gauge: pbGaugeZeroStartTime},
},
{
Name: "summary",
Description: "Summary metric",
Unit: "1",
Data: &mpb.Metric_Summary{Summary: pbSummary},
},
}

otelScopeMetrics = []metricdata.ScopeMetrics{
Expand Down Expand Up @@ -761,6 +873,7 @@ func TestTransformations(t *testing.T) {
assert.Equal(t, pbEHDPInt64, ExponentialHistogramDataPoints(otelEHDPInt64))
assert.Equal(t, pbEHDPFloat64, ExponentialHistogramDataPoints(otelEHDPFloat64))
assert.Equal(t, pbEHDPBA, ExponentialHistogramDataPointBuckets(otelEBucketA))
assert.Equal(t, pbDPtsSummary, SummaryDataPoints(otelSummaryDPts))

// Aggregations.
h, err := Histogram(otelHistInt64)
Expand Down Expand Up @@ -796,6 +909,8 @@ func TestTransformations(t *testing.T) {
assert.ErrorIs(t, err, errUnknownTemporality)
assert.Nil(t, e)

require.Equal(t, &mpb.Metric_Summary{Summary: pbSummary}, Summary(otelSummary))

// Metrics.
m, err := Metrics(otelMetrics)
assert.ErrorIs(t, err, errUnknownTemporality)
Expand Down
3 changes: 3 additions & 0 deletions exporters/otlp/otlpmetric/otlpmetrichttp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OTLP Metric HTTP Exporter

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp)
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out.Data, err = ExponentialHistogram(a)
case metricdata.ExponentialHistogram[float64]:
out.Data, err = ExponentialHistogram(a)
case metricdata.Summary:
out.Data = Summary(a)
default:
return out, fmt.Errorf("%w: %T", errUnknownAggregation, a)
}
Expand Down Expand Up @@ -307,3 +309,44 @@ func Exemplars[N int64 | float64](exemplars []metricdata.Exemplar[N]) []*mpb.Exe
}
return out
}

// Summary returns an OTLP Metric_Summary generated from s.
func Summary(s metricdata.Summary) *mpb.Metric_Summary {
return &mpb.Metric_Summary{
Summary: &mpb.Summary{
DataPoints: SummaryDataPoints(s.DataPoints),
},
}
}

// SummaryDataPoints returns a slice of OTLP SummaryDataPoint generated from
// dPts.
func SummaryDataPoints(dPts []metricdata.SummaryDataPoint) []*mpb.SummaryDataPoint {
out := make([]*mpb.SummaryDataPoint, 0, len(dPts))
for _, dPt := range dPts {
sdp := &mpb.SummaryDataPoint{
Attributes: AttrIter(dPt.Attributes.Iter()),
StartTimeUnixNano: timeUnixNano(dPt.StartTime),
TimeUnixNano: timeUnixNano(dPt.Time),
Count: dPt.Count,
Sum: dPt.Sum,
QuantileValues: QuantileValues(dPt.QuantileValues),
}
out = append(out, sdp)
}
return out
}

// QuantileValues returns a slice of OTLP SummaryDataPoint_ValueAtQuantile
// generated from quantiles.
func QuantileValues(quantiles []metricdata.QuantileValue) []*mpb.SummaryDataPoint_ValueAtQuantile {
out := make([]*mpb.SummaryDataPoint_ValueAtQuantile, 0, len(quantiles))
for _, q := range quantiles {
quantile := &mpb.SummaryDataPoint_ValueAtQuantile{
Quantile: q.Quantile,
Value: q.Value,
}
out = append(out, quantile)
}
return out
}

0 comments on commit 9f0364c

Please sign in to comment.