Skip to content

Commit

Permalink
Collect user provided tracer name, version and schemaURL (#844)
Browse files Browse the repository at this point in the history
* Collect user provided tracer name and use it for scope name

* otelglobal: Collect user provided tracer version

* Support v1.28 of otel-go, taking into account different tracer key size. Including the schemaURL in newer versions.

* Add changelog entry

* precommit and fix buckets offset

* fill schema URL for each probe

* update tests to contains schemaURL

* Apply suggestions from code review

Co-authored-by: Tyler Yahn <[email protected]>

* update verify.bats

---------

Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
RonFed and MrAlias authored Jul 12, 2024
1 parent c6620c7 commit c244026
Show file tree
Hide file tree
Showing 43 changed files with 880 additions and 102 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http
- Support `google.golang.org/grpc` `1.63.3`. ([#916](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/916))
- Support `google.golang.org/grpc` `1.64.1`. ([#916](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/916))
- Support `golang.org/x/net` `v0.27.0`. ([#917](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/917))
- The `otelglobal` probe now collects the user provided tracer name, version and schemaURL. ([#844](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/844))

### Changed

Expand Down
2 changes: 1 addition & 1 deletion examples/kafka-go/consumer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.0
require (
github.com/segmentio/kafka-go v0.4.47
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
)

require (
Expand All @@ -13,5 +14,4 @@ require (
github.com/klauspost/compress v1.15.9 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
)
3 changes: 2 additions & 1 deletion examples/kafka-go/consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import (
kafka "github.com/segmentio/kafka-go"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

var tracer = otel.Tracer("trace-example")
var tracer = otel.Tracer("trace-example-kafka-go", trace.WithInstrumentationVersion("v1.0.0-test"))

func getKafkaReader() *kafka.Reader {
return kafka.NewReader(kafka.ReaderConfig{
Expand Down
3 changes: 2 additions & 1 deletion examples/kafka-go/producer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ go 1.22.0

require github.com/segmentio/kafka-go v0.4.47

require github.com/stretchr/testify v1.9.0 // indirect

require (
github.com/klauspost/compress v1.15.9 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/stretchr/testify v1.9.0 // indirect
)
30 changes: 18 additions & 12 deletions internal/include/go_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,36 @@
Keep a power of 2 to help with masks */
#define MAX_SLICE_ARRAY_SIZE 1024

struct go_string
typedef struct go_string
{
char *str;
s64 len;
};
} go_string_t;

struct go_slice
typedef struct go_slice
{
void *array;
s64 len;
s64 cap;
};
} go_slice_t;

struct go_iface
typedef struct go_iface
{
void *tab;
void *data;
};

struct map_bucket {
char tophash[8];
struct go_string keys[8];
struct go_slice values[8];
void *overflow;
} go_iface_t;

// a map bucket type with the given key and value types
#define MAP_BUCKET_TYPE(key_type, value_type) struct map_bucket_##key_type##_##value_type##_t
// a map bucket struct definition with the given key and value types
// for more details about the structure of a map bucket see:
// https://github.com/golang/go/blob/639cc0dcc0948dd02c9d5fc12fbed730a21ebebc/src/runtime/map.go#L143
#define MAP_BUCKET_DEFINITION(key_type, value_type) \
MAP_BUCKET_TYPE(key_type, value_type) { \
char tophash[8]; \
key_type keys[8]; \
value_type values[8]; \
void *overflow; \
};

struct slice_array_buff
Expand Down
287 changes: 287 additions & 0 deletions internal/pkg/inject/offset_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,293 @@
]
}
]
},
{
"field": "name",
"offsets": [
{
"offset": null,
"versions": [
"0.1.0",
"0.1.1",
"0.1.2",
"0.2.0",
"0.2.1",
"0.2.2",
"0.2.3",
"0.3.0",
"0.4.0",
"0.4.1",
"0.4.2",
"0.4.3",
"0.5.0",
"0.6.0",
"0.7.0",
"0.8.0",
"0.9.0",
"0.10.0",
"0.11.0",
"0.12.0",
"0.13.0"
]
},
{
"offset": 0,
"versions": [
"0.19.0",
"0.20.0",
"1.0.0-RC1",
"1.0.0-RC2",
"1.0.0-RC3",
"1.0.0",
"1.0.1",
"1.1.0",
"1.2.0",
"1.3.0",
"1.4.0",
"1.4.1",
"1.5.0",
"1.6.0",
"1.6.1",
"1.6.2",
"1.6.3",
"1.7.0",
"1.8.0",
"1.9.0",
"1.10.0",
"1.11.0",
"1.11.1",
"1.11.2",
"1.12.0",
"1.13.0",
"1.14.0",
"1.15.0-rc.1",
"1.15.0-rc.2",
"1.15.0",
"1.15.1",
"1.16.0-rc.1",
"1.16.0",
"1.17.0",
"1.18.0",
"1.19.0-rc.1",
"1.19.0"
]
},
{
"offset": 16,
"versions": [
"0.14.0",
"0.15.0",
"0.16.0",
"0.17.0",
"0.18.0",
"1.20.0",
"1.21.0",
"1.22.0",
"1.23.0-rc.1",
"1.23.0",
"1.23.1",
"1.24.0",
"1.25.0",
"1.26.0",
"1.27.0",
"1.28.0"
]
}
]
},
{
"field": "provider",
"offsets": [
{
"offset": null,
"versions": [
"0.1.0",
"0.1.1",
"0.1.2",
"0.2.0",
"0.2.1",
"0.2.2",
"0.2.3",
"0.3.0",
"0.4.0",
"0.4.1",
"0.4.2",
"0.4.3",
"0.5.0",
"0.6.0",
"0.7.0",
"0.8.0",
"0.9.0",
"0.10.0",
"0.11.0",
"0.12.0",
"0.13.0",
"0.14.0",
"0.15.0",
"0.16.0",
"0.17.0",
"0.18.0",
"0.19.0",
"0.20.0"
]
},
{
"offset": 40,
"versions": [
"1.0.0-RC1",
"1.0.0-RC2",
"1.0.0-RC3",
"1.0.0",
"1.0.1",
"1.1.0",
"1.2.0",
"1.3.0",
"1.4.0",
"1.4.1",
"1.5.0",
"1.6.0",
"1.6.1",
"1.6.2",
"1.6.3",
"1.7.0",
"1.8.0",
"1.9.0",
"1.10.0",
"1.11.0",
"1.11.1",
"1.11.2",
"1.12.0",
"1.13.0",
"1.14.0",
"1.15.0-rc.1",
"1.15.0-rc.2",
"1.15.0",
"1.15.1",
"1.16.0-rc.1",
"1.16.0",
"1.17.0",
"1.18.0",
"1.19.0-rc.1",
"1.19.0"
]
},
{
"offset": 56,
"versions": [
"1.20.0",
"1.21.0",
"1.22.0",
"1.23.0-rc.1",
"1.23.0",
"1.23.1",
"1.24.0",
"1.25.0",
"1.26.0",
"1.27.0",
"1.28.0"
]
}
]
}
]
},
{
"struct": "tracerProvider",
"fields": [
{
"field": "tracers",
"offsets": [
{
"offset": null,
"versions": [
"0.1.0",
"0.1.1",
"0.1.2",
"0.2.0",
"0.2.1",
"0.2.2",
"0.2.3",
"0.3.0",
"0.4.0",
"0.4.1",
"0.4.2",
"0.4.3",
"0.5.0",
"0.6.0",
"0.7.0",
"0.8.0",
"0.9.0",
"0.10.0",
"0.11.0",
"0.12.0",
"0.13.0"
]
},
{
"offset": 8,
"versions": [
"0.14.0",
"0.15.0",
"0.16.0",
"0.17.0",
"0.18.0",
"0.19.0",
"0.20.0",
"1.0.0-RC1",
"1.0.0-RC2",
"1.0.0-RC3",
"1.0.0",
"1.0.1",
"1.1.0",
"1.2.0",
"1.3.0",
"1.4.0",
"1.4.1",
"1.5.0",
"1.6.0",
"1.6.1",
"1.6.2",
"1.6.3",
"1.7.0",
"1.8.0",
"1.9.0",
"1.10.0",
"1.11.0",
"1.11.1",
"1.11.2",
"1.12.0",
"1.13.0",
"1.14.0",
"1.15.0-rc.1",
"1.15.0-rc.2",
"1.15.0",
"1.15.1",
"1.16.0-rc.1",
"1.16.0",
"1.17.0",
"1.18.0",
"1.19.0-rc.1",
"1.19.0"
]
},
{
"offset": 24,
"versions": [
"1.20.0",
"1.21.0",
"1.22.0",
"1.23.0-rc.1",
"1.23.0",
"1.23.1",
"1.24.0",
"1.25.0",
"1.26.0",
"1.27.0",
"1.28.0"
]
}
]
}
]
}
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/instrumentation/bpf/database/sql/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func convertEvent(e *event) []*probe.SpanEvent {
semconv.DBQueryText(query),
},
ParentSpanContext: pscPtr,
TracerSchema: semconv.SchemaURL,
},
}
}
Expand Down
Loading

0 comments on commit c244026

Please sign in to comment.