Skip to content

Commit

Permalink
Merge branch 'main' into batch-no-poll
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Mar 27, 2024
2 parents 2b9e12c + 321219b commit c3ac6de
Show file tree
Hide file tree
Showing 96 changed files with 458 additions and 33 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/[email protected]
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/[email protected]
with:
args: --max-concurrency 5 .

- name: Create Issue From File
if: steps.lychee.outputs.exit_code != 0
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
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)
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)
3 changes: 3 additions & 0 deletions exporters/otlp/otlptrace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OTLP Trace Exporter

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

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

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

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

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

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/stdout/stdoutmetric)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/stdout/stdoutmetric)
3 changes: 3 additions & 0 deletions exporters/stdout/stdouttrace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# STDOUT Trace Exporter

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

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/zipkin)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/zipkin)
27 changes: 14 additions & 13 deletions exporters/zipkin/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import (
)

const (
keyInstrumentationLibraryName = "otel.library.name"
keyInstrumentationLibraryVersion = "otel.library.version"

keyPeerHostname attribute.Key = "peer.hostname"
keyPeerAddress attribute.Key = "peer.address"
)
Expand Down Expand Up @@ -180,17 +177,19 @@ func attributeToStringPair(kv attribute.KeyValue) (string, string) {
}
}

// extraZipkinTags are those that may be added to every outgoing span.
var extraZipkinTags = []string{
"otel.status_code",
keyInstrumentationLibraryName,
keyInstrumentationLibraryVersion,
}
// extraZipkinTagsLen is a count of tags that may be added to every outgoing span.
var extraZipkinTagsLen = len([]attribute.Key{
semconv.OTelStatusCodeKey,
semconv.OTelScopeNameKey,
semconv.OTelScopeVersionKey,
semconv.OTelLibraryNameKey,
semconv.OTelLibraryVersionKey,
})

func toZipkinTags(data tracesdk.ReadOnlySpan) map[string]string {
attr := data.Attributes()
resourceAttr := data.Resource().Attributes()
m := make(map[string]string, len(attr)+len(resourceAttr)+len(extraZipkinTags))
m := make(map[string]string, len(attr)+len(resourceAttr)+extraZipkinTagsLen)
for _, kv := range attr {
k, v := attributeToStringPair(kv)
m[k] = v
Expand All @@ -203,7 +202,7 @@ func toZipkinTags(data tracesdk.ReadOnlySpan) map[string]string {
if data.Status().Code != codes.Unset {
// Zipkin expect to receive uppercase status values
// rather than default capitalized ones.
m["otel.status_code"] = strings.ToUpper(data.Status().Code.String())
m[string(semconv.OTelStatusCodeKey)] = strings.ToUpper(data.Status().Code.String())
}

if data.Status().Code == codes.Error {
Expand All @@ -213,9 +212,11 @@ func toZipkinTags(data tracesdk.ReadOnlySpan) map[string]string {
}

if is := data.InstrumentationScope(); is.Name != "" {
m[keyInstrumentationLibraryName] = is.Name
m[string(semconv.OTelScopeNameKey)] = is.Name
m[string(semconv.OTelLibraryNameKey)] = is.Name
if is.Version != "" {
m[keyInstrumentationLibraryVersion] = is.Version
m[string(semconv.OTelScopeVersionKey)] = is.Version
m[string(semconv.OTelLibraryVersionKey)] = is.Version
}
}

Expand Down
3 changes: 3 additions & 0 deletions exporters/zipkin/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ func TestTagsTransformation(t *testing.T) {
},
},
want: map[string]string{
"otel.scope.name": instrLibName,
"otel.library.name": instrLibName,
},
},
Expand All @@ -1040,6 +1041,8 @@ func TestTagsTransformation(t *testing.T) {
},
},
want: map[string]string{
"otel.scope.name": instrLibName,
"otel.scope.version": instrLibVersion,
"otel.library.name": instrLibName,
"otel.library.version": instrLibVersion,
},
Expand Down
8 changes: 0 additions & 8 deletions log/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,6 @@ However, in this approach we would need have factory functions for both types.
It would make the API surface unnecessarily big,
and we may even have problems naming the functions.
## Open issues
The Logs Bridge API MUST NOT be released as stable
before all issues below are closed:
- [Clarify attributes parameter type of Get a Logger operation](https://github.com/open-telemetry/opentelemetry-specification/issues/3841)
- [Add an Enabled method to Logger](https://github.com/open-telemetry/opentelemetry-specification/issues/3917)
[^1]: [Handle structured body and attributes](https://github.com/pellared/opentelemetry-go/pull/7)
[^2]: Jonathan Amsterdam, [The Go Blog: Structured Logging with slog](https://go.dev/blog/slog)
[^3]: Jonathan Amsterdam, [GopherCon Europe 2023: A Fast Structured Logging Package](https://www.youtube.com/watch?v=tC4Jt3i62ns)
Expand Down
3 changes: 3 additions & 0 deletions log/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Log API

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/sdk/instrumentation)](https://pkg.go.dev/go.opentelemetry.io/otel/sdk/instrumentation)
9 changes: 0 additions & 9 deletions sdk/log/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,6 @@ provided via API.
Moreover it is safer to have these abstraction decoupled.
E.g. there can be a need for some fields that can be set via API and cannot be modified by the processors.

## Open issues

The Logs SDK MUST NOT be released as stable before all issues below are closed:

- [Clarify that ReadableLogRecord and ReadWriteLogRecord can be represented using a single type](https://github.com/open-telemetry/opentelemetry-specification/pull/3898)
- [Fix what can be modified via ReadWriteLogRecord](https://github.com/open-telemetry/opentelemetry-specification/pull/3907)
- [logs: Allow duplicate keys](https://github.com/open-telemetry/opentelemetry-specification/issues/3931)
- [Add an Enabled method to Logger](https://github.com/open-telemetry/opentelemetry-specification/issues/3917)

[^1]: [OpenTelemetry Logging](https://opentelemetry.io/docs/specs/otel/logs)
[^2]: [Conversation on representing LogRecordProcessor and LogRecordExporter via a single Expoter interface](https://github.com/open-telemetry/opentelemetry-go/pull/4954#discussion_r1515050480)
[^3]: [Introduce Processor](https://github.com/pellared/opentelemetry-go/pull/9)
3 changes: 3 additions & 0 deletions sdk/log/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Log SDK

[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/sdk/log)](https://pkg.go.dev/go.opentelemetry.io/otel/sdk/log)
50 changes: 50 additions & 0 deletions sdk/log/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package log // import "go.opentelemetry.io/otel/sdk/log"

import (
"context"

"go.opentelemetry.io/otel"
)

// Exporter handles the delivery of log records to external receivers.
Expand Down Expand Up @@ -50,3 +52,51 @@ func (noopExporter) Export(context.Context, []Record) error { return nil }
func (noopExporter) Shutdown(context.Context) error { return nil }

func (noopExporter) ForceFlush(context.Context) error { return nil }

// exportSync exports all data from input using exporter in a spawned
// goroutine. The returned chan will be closed when the spawned goroutine
// completes.
func exportSync(input <-chan exportData, exporter Exporter) (done chan struct{}) {
done = make(chan struct{})
go func() {
defer close(done)
for data := range input {
data.DoExport(exporter.Export)
}
}()
return done
}

// exportData is data related to an export.
type exportData struct {
ctx context.Context
records []Record

// respCh is the channel any error returned from the export will be sent
// on. If this is nil, and the export error is non-nil, the error will
// passed to the OTel error handler.
respCh chan<- error
}

// DoExport calls exportFn with the data contained in e. The error response
// will be returned on e's respCh if not nil. The error will be handled by the
// default OTel error handle if it is not nil and respCh is nil or full.
func (e exportData) DoExport(exportFn func(context.Context, []Record) error) {
if len(e.records) == 0 {
e.respond(nil)
return
}

e.respond(exportFn(e.ctx, e.records))
}

func (e exportData) respond(err error) {
select {
case e.respCh <- err:
default:
// e.respCh is nil or busy, default to otel.Handler.
if err != nil {
otel.Handle(err)
}
}
}
Loading

0 comments on commit c3ac6de

Please sign in to comment.