Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
pree-dew committed Nov 1, 2024
2 parents 26387ea + 06ee6f2 commit 8275538
Show file tree
Hide file tree
Showing 60 changed files with 302 additions and 206 deletions.
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,3 @@ go.work
go.work.sum

gen/

/example/dice/dice
/example/namedtracer/namedtracer
/example/otel-collector/otel-collector
/example/opencensus/opencensus
/example/passthrough/passthrough
/example/prometheus/prometheus
/example/zipkin/zipkin
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ linters-settings:
- "**/metric/**/*.go"
- "**/bridge/*.go"
- "**/bridge/**/*.go"
- "**/example/*.go"
- "**/example/**/*.go"
- "**/trace/*.go"
- "**/trace/**/*.go"
- "**/log/*.go"
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add `ReservoirProvider`, `HistogramReservoirProvider` and `FixedSizeReservoirProvider` to `go.opentelemetry.io/otel/sdk/metric/exemplar` to make it convenient to use providers of Reservoirs. (#5861)
- The `go.opentelemetry.io/otel/semconv/v1.27.0` package.
The package contains semantic conventions from the `v1.27.0` version of the OpenTelemetry Semantic Conventions. (#5894)
- Add `Attributes attribute.Set` field to `Scope` in `go.opentelemetry.io/otel/sdk/instrumentation`. (#5903)
- Add `Attributes attribute.Set` field to `ScopeRecords` in `go.opentelemetry.io/otel/log/logtest`. (#5927)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` adds instrumentation scope attributes. (#5934)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` adds instrumentation scope attributes. (#5934)
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` adds instrumentation scope attributes. (#5935)
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` adds instrumentation scope attributes. (#5935)
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` adds instrumentation scope attributes. (#5933)
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` adds instrumentation scope attributes. (#5933)

### Fixed

Expand All @@ -28,8 +36,16 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` now keeps the metadata already present in the context when `WithHeaders` is used. (#5892)
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` now keeps the metadata already present in the context when `WithHeaders` is used. (#5911)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` now keeps the metadata already present in the context when `WithHeaders` is used. (#5915)
- Support scope attributes and make them as identifying for `Tracer` in `go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/trace`. (#5924)
- Support scope attributes and make them as identifying for `Meter` in `go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/metric`. (#5926)
- Support scope attributes and make them as identifying for `Logger` in `go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/log`. (#5925)
- Make schema URL and scope attributes as identifying for `Tracer` in `go.opentelemetry.io/otel/bridge/opentracing`. (#5931)
- Add int64Measures and float64Measures to `go.opentelemetry.io/otel/sdk/metric` pipeline to call the measure of specific pipeline while calling Collect method. (#5900)

### Removed

- Remove all examples under `go.opentelemetry.io/otel/example` as they are moved to [Contrib repository](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples). (#5930)

<!-- Released section -->
<!-- Don't change this section unless doing release -->

Expand Down
5 changes: 5 additions & 0 deletions bridge/opentracing/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package opentracing // import "go.opentelemetry.io/otel/bridge/opentracing"
import (
"sync"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
)
Expand Down Expand Up @@ -38,6 +39,8 @@ func NewTracerProvider(bridge *BridgeTracer, provider trace.TracerProvider) *Tra
type wrappedTracerKey struct {
name string
version string
schema string
attrs attribute.Set
}

// Tracer creates a WrappedTracer that wraps the OpenTelemetry tracer for each call to
Expand All @@ -51,6 +54,8 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T
key := wrappedTracerKey{
name: name,
version: c.InstrumentationVersion(),
schema: c.SchemaURL(),
attrs: c.InstrumentationAttributes(),
}

if t, ok := p.tracers[key]; ok {
Expand Down
42 changes: 31 additions & 11 deletions bridge/opentracing/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package opentracing
import (
"testing"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/bridge/opentracing/internal"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
Expand Down Expand Up @@ -58,18 +59,37 @@ func TestTracerProvider(t *testing.T) {
})

t.Run("Repeated requests to create a tracer should provide the existing tracer", func(t *testing.T) {
tracer1 := provider.Tracer(foobar)
assertMockTracerName(t, tracer1, foobar)
tracer2 := provider.Tracer(foobar)
assertMockTracerName(t, tracer2, foobar)
tracer3 := provider.Tracer(bazbar)
assertMockTracerName(t, tracer3, bazbar)

if tracer1 != tracer2 {
t.Errorf("expected the same tracer, got different tracers")
tracerFns := []func() trace.Tracer{
func() trace.Tracer {
return provider.Tracer(foobar)
},
func() trace.Tracer {
return provider.Tracer(bazbar)
},
func() trace.Tracer {
return provider.Tracer(foobar, trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0"))
},
func() trace.Tracer {
return provider.Tracer(foobar, trace.WithInstrumentationAttributes(attribute.String("foo", "bar")))
},
func() trace.Tracer {
return provider.Tracer(foobar, trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0"), trace.WithInstrumentationAttributes(attribute.String("foo", "bar")))
},
}
if tracer1 == tracer3 || tracer2 == tracer3 {
t.Errorf("expected different tracers, got the same tracer")

for i, fn1 := range tracerFns {
for j, fn2 := range tracerFns {
tracer1, tracer2 := fn1(), fn2()
if i == j {
if tracer1 != tracer2 {
t.Errorf("expected the same tracer, got different tracers; i=%d j=%d", i, j)
}
} else {
if tracer1 == tracer2 {
t.Errorf("expected different tracers, got the same tracer; i=%d j=%d", i, j)
}
}
}
}
})
}
4 changes: 0 additions & 4 deletions example/dice/go.mod

This file was deleted.

Empty file removed example/dice/go.sum
Empty file.
10 changes: 0 additions & 10 deletions example/dice/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions example/namedtracer/go.mod

This file was deleted.

Empty file removed example/namedtracer/go.sum
Empty file.
10 changes: 0 additions & 10 deletions example/namedtracer/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions example/opencensus/go.mod

This file was deleted.

Empty file removed example/opencensus/go.sum
Empty file.
10 changes: 0 additions & 10 deletions example/opencensus/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions example/otel-collector/go.mod

This file was deleted.

1 change: 0 additions & 1 deletion example/otel-collector/go.sum

This file was deleted.

10 changes: 0 additions & 10 deletions example/otel-collector/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions example/passthrough/go.mod

This file was deleted.

Empty file removed example/passthrough/go.sum
Empty file.
10 changes: 0 additions & 10 deletions example/passthrough/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions example/prometheus/go.mod

This file was deleted.

Empty file removed example/prometheus/go.sum
Empty file.
10 changes: 0 additions & 10 deletions example/prometheus/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions example/zipkin/go.mod

This file was deleted.

Empty file removed example/zipkin/go.sum
Empty file.
10 changes: 0 additions & 10 deletions example/zipkin/main.go

This file was deleted.

5 changes: 3 additions & 2 deletions exporters/otlp/otlplog/otlploggrpc/internal/transform/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func ResourceLogs(records []log.Record) []*lpb.ResourceLogs {
var emptyScope instrumentation.Scope
if scope != emptyScope {
sl.Scope = &cpb.InstrumentationScope{
Name: scope.Name,
Version: scope.Version,
Name: scope.Name,
Version: scope.Version,
Attributes: AttrIter(scope.Attributes.Iter()),
}
sl.SchemaUrl = scope.SchemaURL
}
Expand Down
16 changes: 13 additions & 3 deletions exporters/otlp/otlplog/otlploggrpc/internal/transform/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
lpb "go.opentelemetry.io/proto/otlp/logs/v1"
rpb "go.opentelemetry.io/proto/otlp/resource/v1"

"go.opentelemetry.io/otel/attribute"
api "go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/log"
Expand Down Expand Up @@ -70,9 +71,10 @@ var (
flagsD = byte(0)

scope = instrumentation.Scope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
}
scope2 = instrumentation.Scope{
Name: "otel/test/code/path2",
Expand All @@ -84,6 +86,14 @@ var (
pbScope = &cpb.InstrumentationScope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
Attributes: []*cpb.KeyValue{
{
Key: "foo",
Value: &cpb.AnyValue{
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
},
},
},
}
pbScope2 = &cpb.InstrumentationScope{
Name: "otel/test/code/path2",
Expand Down
5 changes: 3 additions & 2 deletions exporters/otlp/otlplog/otlploghttp/internal/transform/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func ResourceLogs(records []log.Record) []*lpb.ResourceLogs {
var emptyScope instrumentation.Scope
if scope != emptyScope {
sl.Scope = &cpb.InstrumentationScope{
Name: scope.Name,
Version: scope.Version,
Name: scope.Name,
Version: scope.Version,
Attributes: AttrIter(scope.Attributes.Iter()),
}
sl.SchemaUrl = scope.SchemaURL
}
Expand Down
16 changes: 13 additions & 3 deletions exporters/otlp/otlplog/otlploghttp/internal/transform/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
lpb "go.opentelemetry.io/proto/otlp/logs/v1"
rpb "go.opentelemetry.io/proto/otlp/resource/v1"

"go.opentelemetry.io/otel/attribute"
api "go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/log"
Expand Down Expand Up @@ -70,9 +71,10 @@ var (
flagsD = byte(0)

scope = instrumentation.Scope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
}
scope2 = instrumentation.Scope{
Name: "otel/test/code/path2",
Expand All @@ -84,6 +86,14 @@ var (
pbScope = &cpb.InstrumentationScope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
Attributes: []*cpb.KeyValue{
{
Key: "foo",
Value: &cpb.AnyValue{
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
},
},
},
}
pbScope2 = &cpb.InstrumentationScope{
Name: "otel/test/code/path2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ func ScopeMetrics(sms []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) {

out = append(out, &mpb.ScopeMetrics{
Scope: &cpb.InstrumentationScope{
Name: sm.Scope.Name,
Version: sm.Scope.Version,
Name: sm.Scope.Name,
Version: sm.Scope.Version,
Attributes: AttrIter(sm.Scope.Attributes.Iter()),
},
Metrics: ms,
SchemaUrl: sm.Scope.SchemaURL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,10 @@ var (
otelScopeMetrics = []metricdata.ScopeMetrics{
{
Scope: instrumentation.Scope{
Name: "test/code/path",
Version: "v0.1.0",
SchemaURL: semconv.SchemaURL,
Name: "test/code/path",
Version: "v0.1.0",
SchemaURL: semconv.SchemaURL,
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
},
Metrics: otelMetrics,
},
Expand All @@ -818,6 +819,14 @@ var (
Scope: &cpb.InstrumentationScope{
Name: "test/code/path",
Version: "v0.1.0",
Attributes: []*cpb.KeyValue{
{
Key: "foo",
Value: &cpb.AnyValue{
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
},
},
},
},
Metrics: pbMetrics,
SchemaUrl: semconv.SchemaURL,
Expand Down
Loading

0 comments on commit 8275538

Please sign in to comment.