Skip to content

Commit

Permalink
Merge main into new_sdk/main (#2996)
Browse files Browse the repository at this point in the history
* Use already enabled revive linter and add depguard (#2883)

* Refactor golangci-lint conf

Order settings alphabetically.

* Add revive settings to golangci conf

* Check blank imports

* Check bool-literal-in-expr

* Check constant-logical-expr

* Check context-as-argument

* Check context-key-type

* Check deep-exit

* Check defer

* Check dot-imports

* Check duplicated-imports

* Check early-return

* Check empty-block

* Check empty-lines

* Check error-naming

* Check error-return

* Check error-strings

* Check errorf

* Stop ignoring context first arg in tests

* Check exported comments

* Check flag-parameter

* Check identical branches

* Check if-return

* Check increment-decrement

* Check indent-error-flow

* Check deny list of go imports

* Check import shadowing

* Check package comments

* Check range

* Check range val in closure

* Check range val address

* Check redefines builtin id

* Check string-format

* Check struct tag

* Check superfluous else

* Check time equal

* Check var naming

* Check var declaration

* Check unconditional recursion

* Check unexported return

* Check unhandled errors

* Check unnecessary stmt

* Check unnecessary break

* Check waitgroup by value

* Exclude deep-exit check in example*_test.go files

* Move the minimum version to go 1.17 (#2917)

* Move the minimum version to go 1.17

* Update readme and changelog

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>

* Use ByteSliceToString from golang.org/x/sys/unix (#2924)

Use unix.ByteSliceToString to convert Utsname []byte fields to strings.

This also allows to drop the charsToString helper which serves the same
purpose and matches ByteSliceToString's implementation.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* docs: fix typo (#2935)

* add timeout to grpc connection in otel-collector example (#2939)

* Closes: #2951 (#2952)

This PR updates the example listed in the getting started doc
so that it will compile without error.  It also makes this
example consistent with the code found in
https://github.com/open-telemetry/opentelemetry-go/blob/main/example/fib/main.go

Signed-off-by: Brad Topol <btopol@us.ibm.com>

* fix data-model link (#2955)

* Bump go.opentelemetry.io/proto/otlp from v0.16.0 to v0.18.0 (#2960)

* Move to using Instrumentation Scope (#2976)

* Move to using Instrumentation Scope

* Use type alias, not definition

* Add a changelog entry

* docs(website_docs): fix exporting_data.md and getting-started.md toc (#2930)

* docs(website_docs): fix toc

* docs(website_docs): fix toc

* update exporting_data.md for rerun check-links

* update exporting_data.md for rerun check-links

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update getting-started.md (#2984)

grammar edit for line 175 of readme

* fix typo (#2986)

* fix typo

* spell fix

* typo fix (#2991)

* added traces.txt to gitignore for fib (#2993)

* Deprecate Library and move all uses to Scope (#2977)

* Deprecate Library and move all uses to Scope

* Add PR number to changelog

* Don't change signatures in stable modules

* Revert some changes

* Rename internal struct names

* A bit more renaming

* Update sdk/trace/span.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update based on feedback

* Revert change

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* Feat/bridge support text map (#2911)

* feat: support TextMap

* doc: add comment

* test: support for ot.TextMap

* Retrieve lost code due to merge

* fix: retrieve lost code due to merge. test: support for ot.HTTPHeaders

* go mod tidy

* Optimized code style, add changelog

* doc: Restore comments

* wip: add test cases

* test: fix args error

* delete empty line

* Fix syntax and changelog errors

* Fix formatting errors

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* Add a release template (#2863)

* Add a release template

* Update the about field

Co-authored-by: Damien Mathieu <42@dmathieu.com>

* Fix linting Issues

* Add ignore for template link

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* Fix merge of CHANGELOG.md

Co-authored-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tobias Klauser <tobias.klauser@gmail.com>
Co-authored-by: petrie <244236866@qq.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Brad Topol <btopol@us.ibm.com>
Co-authored-by: Craig Pastro <pastro.craig@gmail.com>
Co-authored-by: Kshitija Murudi <kmurudi@ncsu.edu>
Co-authored-by: Petrie Liu <lpfvip2008@gmail.com>
Co-authored-by: Guangya Liu <gyliu513@gmail.com>
Co-authored-by: Craig Pastro <craig.pastro@auth0.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: ttoad <qq530901331@outlook.com>
  • Loading branch information
14 people committed Jul 7, 2022
1 parent c250227 commit 2bd0e1a
Show file tree
Hide file tree
Showing 46 changed files with 775 additions and 213 deletions.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/version_release.md
@@ -0,0 +1,22 @@
---
name: Version Release
about: Checklist to follow when shipping a new release.
title: 'Release <V1.x.x> Checklist'
labels: ''
assignees: ''

---

<!-- markdownlint-disable MD034 -->
<!--- The current milestones can be found at https://github.com/open-telemetry/opentelemetry-go/milestones -->
- [ ] Complete [Milestone](https://github.com/open-telemetry/opentelemetry-go/milestone/<Release Milesone>)
<!-- markdownlint-enable MD034 -->
- [ ] Update contrib codebase to support changes about to be released (use a git sha version)
- [ ] [Pre-release](https://github.com/open-telemetry/opentelemetry-go/blob/main/RELEASING.md#pre-release)
- [ ] [Tag](https://github.com/open-telemetry/opentelemetry-go/blob/main/RELEASING.md#tag)
- [ ] [Release](https://github.com/open-telemetry/opentelemetry-go/blob/main/RELEASING.md#release)
- [ ] [Check examples](https://github.com/open-telemetry/opentelemetry-go/blob/main/RELEASING.md#verify-examples)
- [ ] [Sync with Contrib](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/RELEASING.md#upgrade-goopentelemetryiootel-packages)
- [ ] [Release contrib](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/RELEASING.md#release-process)
- [ ] [Sync website docs](https://github.com/open-telemetry/opentelemetry-go/blob/main/RELEASING.md#website-documentation)
- [ ] Close the milestone
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,6 +11,7 @@ coverage.*
gen/

/example/fib/fib
/example/fib/traces.txt
/example/jaeger/jaeger
/example/namedtracer/namedtracer
/example/opencensus/opencensus
Expand Down
1 change: 1 addition & 0 deletions .lycheeignore
@@ -1,2 +1,3 @@
http://localhost
http://jaeger-collector
https://github.com/open-telemetry/opentelemetry-go/milestone/
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,14 +8,27 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Added

- Add support for `opentracing.TextMap` format in the `Inject` and `Extract` methods
of the `"go.opentelemetry.io/otel/bridge/opentracing".BridgeTracer` type. (#2911)

### Changed

- The `crosslink` make target has been updated to use the `go.opentelemetry.io/build-tools/crosslink` package. (#2886)
- In the `go.opentelemetry.io/otel/sdk/instrumentation` package rename `Library` to `Scope` and alias `Library` as `Scope` (#2976)

### Removed

- Support for go1.16. Support is now only for go1.17 and go1.18 (#2917)

### Deprecated

- The `Library` struct in the `go.opentelemetry.io/otel/sdk/instrumentation` package is deprecated.
Use the equivalent `Scope` struct instead. (#2977)
- The `ReadOnlySpan.InstrumentationLibrary` method from the `go.opentelemetry.io/otel/sdk/trace` package is deprecated.
Use the equivalent `ReadOnlySpan.InstrumentationScope` method instead. (#2977)

## [1.7.0/0.30.0] - 2022-04-28

### Added
Expand Down
6 changes: 3 additions & 3 deletions baggage/baggage.go
Expand Up @@ -157,7 +157,7 @@ func (p Property) Key() string {
return p.key
}

// Value returns the Property value. Additionally a boolean value is returned
// Value returns the Property value. Additionally, a boolean value is returned
// indicating if the returned value is the empty if the Property has a value
// that is empty or if the value is not set.
func (p Property) Value() (string, bool) {
Expand Down Expand Up @@ -392,7 +392,7 @@ func New(members ...Member) (Baggage, error) {
}
}

// Check member numbers after deduplicating.
// Check member numbers after deduplication.
if len(b) > maxMembers {
return Baggage{}, errMemberNumber
}
Expand Down Expand Up @@ -454,7 +454,7 @@ func Parse(bStr string) (Baggage, error) {
func (b Baggage) Member(key string) Member {
v, ok := b.list[key]
if !ok {
// We do not need to worry about distiguising between the situation
// We do not need to worry about distinguishing between the situation
// where a zero-valued Member is included in the Baggage because a
// zero-valued Member is invalid according to the W3C Baggage
// specification (it has an empty key).
Expand Down
167 changes: 153 additions & 14 deletions bridge/opentracing/bridge.go
Expand Up @@ -634,7 +634,7 @@ func (s fakeSpan) SpanContext() trace.SpanContext {
// Inject is a part of the implementation of the OpenTracing Tracer
// interface.
//
// Currently only the HTTPHeaders format is supported.
// Currently only the HTTPHeaders and TextMap formats are supported.
func (t *BridgeTracer) Inject(sm ot.SpanContext, format interface{}, carrier interface{}) error {
bridgeSC, ok := sm.(*bridgeSpanContext)
if !ok {
Expand All @@ -643,38 +643,75 @@ func (t *BridgeTracer) Inject(sm ot.SpanContext, format interface{}, carrier int
if !bridgeSC.otelSpanContext.IsValid() {
return ot.ErrInvalidSpanContext
}
if builtinFormat, ok := format.(ot.BuiltinFormat); !ok || builtinFormat != ot.HTTPHeaders {

builtinFormat, ok := format.(ot.BuiltinFormat)
if !ok {
return ot.ErrUnsupportedFormat
}
hhcarrier, ok := carrier.(ot.HTTPHeadersCarrier)
if !ok {
return ot.ErrInvalidCarrier

var textCarrier propagation.TextMapCarrier

switch builtinFormat {
case ot.HTTPHeaders:
hhcarrier, ok := carrier.(ot.HTTPHeadersCarrier)
if !ok {
return ot.ErrInvalidCarrier
}

textCarrier = propagation.HeaderCarrier(hhcarrier)
case ot.TextMap:
if textCarrier, ok = carrier.(propagation.TextMapCarrier); !ok {
var err error
if textCarrier, err = newTextMapWrapperForInject(carrier); err != nil {
return err
}
}
default:
return ot.ErrUnsupportedFormat
}
header := http.Header(hhcarrier)

fs := fakeSpan{
Span: noopSpan,
sc: bridgeSC.otelSpanContext,
}
ctx := trace.ContextWithSpan(context.Background(), fs)
ctx = baggage.ContextWithBaggage(ctx, bridgeSC.bag)
t.getPropagator().Inject(ctx, propagation.HeaderCarrier(header))
t.getPropagator().Inject(ctx, textCarrier)
return nil
}

// Extract is a part of the implementation of the OpenTracing Tracer
// interface.
//
// Currently only the HTTPHeaders format is supported.
// Currently only the HTTPHeaders and TextMap formats are supported.
func (t *BridgeTracer) Extract(format interface{}, carrier interface{}) (ot.SpanContext, error) {
if builtinFormat, ok := format.(ot.BuiltinFormat); !ok || builtinFormat != ot.HTTPHeaders {
builtinFormat, ok := format.(ot.BuiltinFormat)
if !ok {
return nil, ot.ErrUnsupportedFormat
}
hhcarrier, ok := carrier.(ot.HTTPHeadersCarrier)
if !ok {
return nil, ot.ErrInvalidCarrier

var textCarrier propagation.TextMapCarrier

switch builtinFormat {
case ot.HTTPHeaders:
hhcarrier, ok := carrier.(ot.HTTPHeadersCarrier)
if !ok {
return nil, ot.ErrInvalidCarrier
}

textCarrier = propagation.HeaderCarrier(hhcarrier)
case ot.TextMap:
if textCarrier, ok = carrier.(propagation.TextMapCarrier); !ok {
var err error
if textCarrier, err = newTextMapWrapperForExtract(carrier); err != nil {
return nil, err
}
}
default:
return nil, ot.ErrUnsupportedFormat
}
header := http.Header(hhcarrier)
ctx := t.getPropagator().Extract(context.Background(), propagation.HeaderCarrier(header))

ctx := t.getPropagator().Extract(context.Background(), textCarrier)
bag := baggage.FromContext(ctx)
bridgeSC := &bridgeSpanContext{
bag: bag,
Expand All @@ -692,3 +729,105 @@ func (t *BridgeTracer) getPropagator() propagation.TextMapPropagator {
}
return otel.GetTextMapPropagator()
}

// textMapWrapper Provides operating.TextMapWriter and operating.TextMapReader to
// propagation.TextMapCarrier compatibility.
// Usually, Inject method will only use the write-related interface.
// Extract method will only use the reade-related interface.
// To avoid panic,
// when the carrier implements only one of the interfaces,
// it provides a default implementation of the other interface (textMapWriter and textMapReader).
type textMapWrapper struct {
ot.TextMapWriter
ot.TextMapReader
readerMap map[string]string
}

func (t *textMapWrapper) Get(key string) string {
if t.readerMap == nil {
t.loadMap()
}

return t.readerMap[key]
}

func (t *textMapWrapper) Set(key string, value string) {
t.TextMapWriter.Set(key, value)
}

func (t *textMapWrapper) Keys() []string {
if t.readerMap == nil {
t.loadMap()
}

str := make([]string, 0, len(t.readerMap))
for key := range t.readerMap {
str = append(str, key)
}

return str
}

func (t *textMapWrapper) loadMap() {
t.readerMap = make(map[string]string)

_ = t.ForeachKey(func(key, val string) error {
t.readerMap[key] = val

return nil
})
}

func newTextMapWrapperForExtract(carrier interface{}) (*textMapWrapper, error) {
t := &textMapWrapper{}

reader, ok := carrier.(ot.TextMapReader)
if !ok {
return nil, ot.ErrInvalidCarrier
}

t.TextMapReader = reader

writer, ok := carrier.(ot.TextMapWriter)
if ok {
t.TextMapWriter = writer
} else {
t.TextMapWriter = &textMapWriter{}
}

return t, nil
}

func newTextMapWrapperForInject(carrier interface{}) (*textMapWrapper, error) {
t := &textMapWrapper{}

writer, ok := carrier.(ot.TextMapWriter)
if !ok {
return nil, ot.ErrInvalidCarrier
}

t.TextMapWriter = writer

reader, ok := carrier.(ot.TextMapReader)
if ok {
t.TextMapReader = reader
} else {
t.TextMapReader = &textMapReader{}
}

return t, nil
}

type textMapWriter struct {
}

func (t *textMapWriter) Set(key string, value string) {
// maybe print a warning log.
}

type textMapReader struct {
}

func (t *textMapReader) ForeachKey(handler func(key, val string) error) error {
return nil // maybe print a warning log.
}

0 comments on commit 2bd0e1a

Please sign in to comment.