Skip to content

Commit c244026

Browse files
RonFedMrAlias
andauthored
Collect user provided tracer name, version and schemaURL (#844)
* 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]>
1 parent c6620c7 commit c244026

File tree

43 files changed

+880
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+880
-102
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http
2222
- Support `google.golang.org/grpc` `1.63.3`. ([#916](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/916))
2323
- Support `google.golang.org/grpc` `1.64.1`. ([#916](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/916))
2424
- Support `golang.org/x/net` `v0.27.0`. ([#917](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/917))
25+
- The `otelglobal` probe now collects the user provided tracer name, version and schemaURL. ([#844](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/844))
2526

2627
### Changed
2728

examples/kafka-go/consumer/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.22.0
55
require (
66
github.com/segmentio/kafka-go v0.4.47
77
go.opentelemetry.io/otel v1.28.0
8+
go.opentelemetry.io/otel/trace v1.28.0
89
)
910

1011
require (
@@ -13,5 +14,4 @@ require (
1314
github.com/klauspost/compress v1.15.9 // indirect
1415
github.com/pierrec/lz4/v4 v4.1.15 // indirect
1516
go.opentelemetry.io/otel/metric v1.28.0 // indirect
16-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
1717
)

examples/kafka-go/consumer/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ import (
2525
kafka "github.com/segmentio/kafka-go"
2626
"go.opentelemetry.io/otel"
2727
"go.opentelemetry.io/otel/attribute"
28+
"go.opentelemetry.io/otel/trace"
2829
)
2930

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

3233
func getKafkaReader() *kafka.Reader {
3334
return kafka.NewReader(kafka.ReaderConfig{

examples/kafka-go/producer/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ go 1.22.0
44

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

7+
require github.com/stretchr/testify v1.9.0 // indirect
8+
79
require (
810
github.com/klauspost/compress v1.15.9 // indirect
911
github.com/pierrec/lz4/v4 v4.1.15 // indirect
10-
github.com/stretchr/testify v1.9.0 // indirect
1112
)

internal/include/go_types.h

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,36 @@
2323
Keep a power of 2 to help with masks */
2424
#define MAX_SLICE_ARRAY_SIZE 1024
2525

26-
struct go_string
26+
typedef struct go_string
2727
{
2828
char *str;
2929
s64 len;
30-
};
30+
} go_string_t;
3131

32-
struct go_slice
32+
typedef struct go_slice
3333
{
3434
void *array;
3535
s64 len;
3636
s64 cap;
37-
};
37+
} go_slice_t;
3838

39-
struct go_iface
39+
typedef struct go_iface
4040
{
4141
void *tab;
4242
void *data;
43-
};
44-
45-
struct map_bucket {
46-
char tophash[8];
47-
struct go_string keys[8];
48-
struct go_slice values[8];
49-
void *overflow;
43+
} go_iface_t;
44+
45+
// a map bucket type with the given key and value types
46+
#define MAP_BUCKET_TYPE(key_type, value_type) struct map_bucket_##key_type##_##value_type##_t
47+
// a map bucket struct definition with the given key and value types
48+
// for more details about the structure of a map bucket see:
49+
// https://github.com/golang/go/blob/639cc0dcc0948dd02c9d5fc12fbed730a21ebebc/src/runtime/map.go#L143
50+
#define MAP_BUCKET_DEFINITION(key_type, value_type) \
51+
MAP_BUCKET_TYPE(key_type, value_type) { \
52+
char tophash[8]; \
53+
key_type keys[8]; \
54+
value_type values[8]; \
55+
void *overflow; \
5056
};
5157

5258
struct slice_array_buff

internal/pkg/inject/offset_results.json

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,293 @@
941941
]
942942
}
943943
]
944+
},
945+
{
946+
"field": "name",
947+
"offsets": [
948+
{
949+
"offset": null,
950+
"versions": [
951+
"0.1.0",
952+
"0.1.1",
953+
"0.1.2",
954+
"0.2.0",
955+
"0.2.1",
956+
"0.2.2",
957+
"0.2.3",
958+
"0.3.0",
959+
"0.4.0",
960+
"0.4.1",
961+
"0.4.2",
962+
"0.4.3",
963+
"0.5.0",
964+
"0.6.0",
965+
"0.7.0",
966+
"0.8.0",
967+
"0.9.0",
968+
"0.10.0",
969+
"0.11.0",
970+
"0.12.0",
971+
"0.13.0"
972+
]
973+
},
974+
{
975+
"offset": 0,
976+
"versions": [
977+
"0.19.0",
978+
"0.20.0",
979+
"1.0.0-RC1",
980+
"1.0.0-RC2",
981+
"1.0.0-RC3",
982+
"1.0.0",
983+
"1.0.1",
984+
"1.1.0",
985+
"1.2.0",
986+
"1.3.0",
987+
"1.4.0",
988+
"1.4.1",
989+
"1.5.0",
990+
"1.6.0",
991+
"1.6.1",
992+
"1.6.2",
993+
"1.6.3",
994+
"1.7.0",
995+
"1.8.0",
996+
"1.9.0",
997+
"1.10.0",
998+
"1.11.0",
999+
"1.11.1",
1000+
"1.11.2",
1001+
"1.12.0",
1002+
"1.13.0",
1003+
"1.14.0",
1004+
"1.15.0-rc.1",
1005+
"1.15.0-rc.2",
1006+
"1.15.0",
1007+
"1.15.1",
1008+
"1.16.0-rc.1",
1009+
"1.16.0",
1010+
"1.17.0",
1011+
"1.18.0",
1012+
"1.19.0-rc.1",
1013+
"1.19.0"
1014+
]
1015+
},
1016+
{
1017+
"offset": 16,
1018+
"versions": [
1019+
"0.14.0",
1020+
"0.15.0",
1021+
"0.16.0",
1022+
"0.17.0",
1023+
"0.18.0",
1024+
"1.20.0",
1025+
"1.21.0",
1026+
"1.22.0",
1027+
"1.23.0-rc.1",
1028+
"1.23.0",
1029+
"1.23.1",
1030+
"1.24.0",
1031+
"1.25.0",
1032+
"1.26.0",
1033+
"1.27.0",
1034+
"1.28.0"
1035+
]
1036+
}
1037+
]
1038+
},
1039+
{
1040+
"field": "provider",
1041+
"offsets": [
1042+
{
1043+
"offset": null,
1044+
"versions": [
1045+
"0.1.0",
1046+
"0.1.1",
1047+
"0.1.2",
1048+
"0.2.0",
1049+
"0.2.1",
1050+
"0.2.2",
1051+
"0.2.3",
1052+
"0.3.0",
1053+
"0.4.0",
1054+
"0.4.1",
1055+
"0.4.2",
1056+
"0.4.3",
1057+
"0.5.0",
1058+
"0.6.0",
1059+
"0.7.0",
1060+
"0.8.0",
1061+
"0.9.0",
1062+
"0.10.0",
1063+
"0.11.0",
1064+
"0.12.0",
1065+
"0.13.0",
1066+
"0.14.0",
1067+
"0.15.0",
1068+
"0.16.0",
1069+
"0.17.0",
1070+
"0.18.0",
1071+
"0.19.0",
1072+
"0.20.0"
1073+
]
1074+
},
1075+
{
1076+
"offset": 40,
1077+
"versions": [
1078+
"1.0.0-RC1",
1079+
"1.0.0-RC2",
1080+
"1.0.0-RC3",
1081+
"1.0.0",
1082+
"1.0.1",
1083+
"1.1.0",
1084+
"1.2.0",
1085+
"1.3.0",
1086+
"1.4.0",
1087+
"1.4.1",
1088+
"1.5.0",
1089+
"1.6.0",
1090+
"1.6.1",
1091+
"1.6.2",
1092+
"1.6.3",
1093+
"1.7.0",
1094+
"1.8.0",
1095+
"1.9.0",
1096+
"1.10.0",
1097+
"1.11.0",
1098+
"1.11.1",
1099+
"1.11.2",
1100+
"1.12.0",
1101+
"1.13.0",
1102+
"1.14.0",
1103+
"1.15.0-rc.1",
1104+
"1.15.0-rc.2",
1105+
"1.15.0",
1106+
"1.15.1",
1107+
"1.16.0-rc.1",
1108+
"1.16.0",
1109+
"1.17.0",
1110+
"1.18.0",
1111+
"1.19.0-rc.1",
1112+
"1.19.0"
1113+
]
1114+
},
1115+
{
1116+
"offset": 56,
1117+
"versions": [
1118+
"1.20.0",
1119+
"1.21.0",
1120+
"1.22.0",
1121+
"1.23.0-rc.1",
1122+
"1.23.0",
1123+
"1.23.1",
1124+
"1.24.0",
1125+
"1.25.0",
1126+
"1.26.0",
1127+
"1.27.0",
1128+
"1.28.0"
1129+
]
1130+
}
1131+
]
1132+
}
1133+
]
1134+
},
1135+
{
1136+
"struct": "tracerProvider",
1137+
"fields": [
1138+
{
1139+
"field": "tracers",
1140+
"offsets": [
1141+
{
1142+
"offset": null,
1143+
"versions": [
1144+
"0.1.0",
1145+
"0.1.1",
1146+
"0.1.2",
1147+
"0.2.0",
1148+
"0.2.1",
1149+
"0.2.2",
1150+
"0.2.3",
1151+
"0.3.0",
1152+
"0.4.0",
1153+
"0.4.1",
1154+
"0.4.2",
1155+
"0.4.3",
1156+
"0.5.0",
1157+
"0.6.0",
1158+
"0.7.0",
1159+
"0.8.0",
1160+
"0.9.0",
1161+
"0.10.0",
1162+
"0.11.0",
1163+
"0.12.0",
1164+
"0.13.0"
1165+
]
1166+
},
1167+
{
1168+
"offset": 8,
1169+
"versions": [
1170+
"0.14.0",
1171+
"0.15.0",
1172+
"0.16.0",
1173+
"0.17.0",
1174+
"0.18.0",
1175+
"0.19.0",
1176+
"0.20.0",
1177+
"1.0.0-RC1",
1178+
"1.0.0-RC2",
1179+
"1.0.0-RC3",
1180+
"1.0.0",
1181+
"1.0.1",
1182+
"1.1.0",
1183+
"1.2.0",
1184+
"1.3.0",
1185+
"1.4.0",
1186+
"1.4.1",
1187+
"1.5.0",
1188+
"1.6.0",
1189+
"1.6.1",
1190+
"1.6.2",
1191+
"1.6.3",
1192+
"1.7.0",
1193+
"1.8.0",
1194+
"1.9.0",
1195+
"1.10.0",
1196+
"1.11.0",
1197+
"1.11.1",
1198+
"1.11.2",
1199+
"1.12.0",
1200+
"1.13.0",
1201+
"1.14.0",
1202+
"1.15.0-rc.1",
1203+
"1.15.0-rc.2",
1204+
"1.15.0",
1205+
"1.15.1",
1206+
"1.16.0-rc.1",
1207+
"1.16.0",
1208+
"1.17.0",
1209+
"1.18.0",
1210+
"1.19.0-rc.1",
1211+
"1.19.0"
1212+
]
1213+
},
1214+
{
1215+
"offset": 24,
1216+
"versions": [
1217+
"1.20.0",
1218+
"1.21.0",
1219+
"1.22.0",
1220+
"1.23.0-rc.1",
1221+
"1.23.0",
1222+
"1.23.1",
1223+
"1.24.0",
1224+
"1.25.0",
1225+
"1.26.0",
1226+
"1.27.0",
1227+
"1.28.0"
1228+
]
1229+
}
1230+
]
9441231
}
9451232
]
9461233
}

internal/pkg/instrumentation/bpf/database/sql/probe.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func convertEvent(e *event) []*probe.SpanEvent {
103103
semconv.DBQueryText(query),
104104
},
105105
ParentSpanContext: pscPtr,
106+
TracerSchema: semconv.SchemaURL,
106107
},
107108
}
108109
}

0 commit comments

Comments
 (0)