Skip to content

Commit a4e15be

Browse files
authored
Cleanup K8s integration tests (open-telemetry#328)
* Cleanup K8s integration tests * rename some beyla files * restore naming in beyla_kube_cache tests * fix prometheus scrape * Fix tests * Fix K8s informerscache tests * Fix cluster name
1 parent 502110d commit a4e15be

File tree

65 files changed

+341
-364
lines changed

Some content is hidden

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

65 files changed

+341
-364
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ formatters:
1919
# put imports beginning with prefix after 3rd-party packages;
2020
# it's a comma-separated list of prefixes
2121
local-prefixes:
22-
- github.com/open-telemetry/opentelemetry-ebpf-instrumentation
22+
- go.opentelemetry.io/obi
2323

2424
linters:
2525
exclusions:

pkg/app/request/span_getters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func SpanOTELGetters(name attr.Name) (attributes.Getter[*Span, attribute.KeyValu
7474
case attr.SpanName:
7575
getter = func(s *Span) attribute.KeyValue { return SpanNameMetric(s.TraceName()) }
7676
case attr.Source:
77-
getter = func(_ *Span) attribute.KeyValue { return SourceMetric("beyla") }
77+
getter = func(_ *Span) attribute.KeyValue { return SourceMetric(attr.VendorPrefix) }
7878
case attr.StatusCode:
7979
getter = func(s *Span) attribute.KeyValue { return StatusCodeMetric(SpanStatusCode(s)) }
8080
case attr.DBOperation:

pkg/components/netolly/export/printer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99
"strconv"
1010
"strings"
1111

12-
"go.opentelemetry.io/obi/pkg/export/otel"
13-
1412
"go.opentelemetry.io/obi/pkg/components/netolly/ebpf"
13+
attr "go.opentelemetry.io/obi/pkg/export/attributes/names"
1514
"go.opentelemetry.io/obi/pkg/pipe/msg"
1615
"go.opentelemetry.io/obi/pkg/pipe/swarm"
1716
)
@@ -37,7 +36,7 @@ func printFlow(f *ebpf.Record) {
3736
sb.WriteString("transport=")
3837
sb.WriteString(strconv.Itoa(int(f.Id.TransportProtocol)))
3938
sb.WriteByte(' ')
40-
sb.WriteString(otel.VendorPrefix)
39+
sb.WriteString(attr.VendorPrefix)
4140
sb.WriteString(".ip=")
4241
sb.WriteString(f.Attrs.OBIIP)
4342
sb.WriteString(" iface=")

pkg/export/attributes/names/attrs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ const (
7676
// obi.-prefixed attributes are a var instead of a constant to allow overriding the prefix
7777
// from components that vendor OBI as a library
7878

79+
// VendorPrefix allows identifying some metrics (network, internal counters...)
80+
// as custom metrics, since at the moment they don't follow any semantic convention for them.
81+
// This value can be overridden when OBI is vendored as a library (e.g. from the OTEL collector)
82+
var VendorPrefix = "obi"
83+
7984
var OBIIP = Name("obi.ip")
8085

8186
const (

pkg/export/otel/common.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ const (
5656
envResourceAttrs = "OTEL_RESOURCE_ATTRIBUTES"
5757
)
5858

59-
// VendorPrefix allows identifying some metrics (network, internal counters...)
60-
// as custom metrics, since at the moment they don't follow any semantic convention for them.
61-
// This value can be overridden when OBI is vendored as a library (e.g. from the OTEL collector)
62-
var VendorPrefix = "obi"
63-
6459
func omitFieldsForYAML(input any, omitFields map[string]struct{}) map[string]any {
6560
result := make(map[string]any)
6661

pkg/export/otel/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ func (mr *MetricsReporter) tracesResourceAttributes(service *svc.Attrs) attribut
988988
semconv.ServiceNamespace(service.UID.Namespace),
989989
semconv.TelemetrySDKLanguageKey.String(service.SDKLanguage.String()),
990990
semconv.TelemetrySDKNameKey.String("opentelemetry-ebpf-instrumentation"),
991-
request.SourceMetric("beyla"),
991+
request.SourceMetric(attr.VendorPrefix),
992992
semconv.OSTypeKey.String("linux"),
993993
}
994994

pkg/export/otel/metrics_net.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"log/slog"
1010
"time"
1111

12+
attr "go.opentelemetry.io/obi/pkg/export/attributes/names"
13+
1214
"github.com/google/uuid"
1315
"go.opentelemetry.io/otel/attribute"
1416
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
@@ -46,7 +48,7 @@ func nmlog() *slog.Logger {
4648
// for network metrics.
4749
func getFilteredNetworkResourceAttrs(hostID string, attrSelector attributes.Selection) []attribute.KeyValue {
4850
baseAttrs := []attribute.KeyValue{
49-
semconv.ServiceName(VendorPrefix + "-network-flows"),
51+
semconv.ServiceName(attr.VendorPrefix + "-network-flows"),
5052
semconv.ServiceInstanceID(uuid.New().String()),
5153
semconv.TelemetrySDKLanguageKey.String(semconv.TelemetrySDKLanguageGo.Value.AsString()),
5254
semconv.TelemetrySDKNameKey.String("opentelemetry-ebpf-instrumentation"),
@@ -57,7 +59,7 @@ func getFilteredNetworkResourceAttrs(hostID string, attrSelector attributes.Sele
5759
semconv.HostID(hostID),
5860
}
5961

60-
return GetFilteredAttributesByPrefix(baseAttrs, attrSelector, extraAttrs, []string{"network.", VendorPrefix + ".network"})
62+
return GetFilteredAttributesByPrefix(baseAttrs, attrSelector, extraAttrs, []string{"network.", attr.VendorPrefix + ".network"})
6163
}
6264

6365
func createFilteredNetworkResource(hostID string, attrSelector attributes.Selection) *resource.Resource {

pkg/export/prom/prom.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ func (r *metricsReporter) labelValuesSpans(span *request.Span) []string {
984984
span.ServiceGraphKind(),
985985
span.Service.UID.Instance, // app instance ID
986986
span.Service.Job(),
987-
"beyla",
987+
attr.VendorPrefix,
988988
}
989989
}
990990

@@ -1022,8 +1022,8 @@ func (r *metricsReporter) labelValuesTargetInfo(service *svc.Attrs) []string {
10221022
service.UID.Instance, // app instance ID
10231023
service.Job(),
10241024
service.SDKLanguage.String(),
1025-
"beyla",
1026-
"beyla",
1025+
attr.VendorPrefix,
1026+
attr.VendorPrefix,
10271027
"linux",
10281028
}
10291029

@@ -1049,15 +1049,15 @@ func (r *metricsReporter) labelValuesServiceGraph(span *request.Span) []string {
10491049
span.Service.UID.Namespace,
10501050
request.SpanHost(span),
10511051
span.OtherNamespace,
1052-
"beyla",
1052+
attr.VendorPrefix,
10531053
}
10541054
}
10551055
return []string{
10561056
request.SpanPeer(span),
10571057
span.OtherNamespace,
10581058
request.SpanHost(span),
10591059
span.Service.UID.Namespace,
1060-
"beyla",
1060+
attr.VendorPrefix,
10611061
}
10621062
}
10631063

test/integration/configs/obi-config-go-otel-grpc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ otel_traces_export:
99
endpoint: http://jaeger:4318
1010
attributes:
1111
kubernetes:
12-
cluster_name: beyla-k8s-test-cluster
12+
cluster_name: obi-k8s-test-cluster
1313
select:
1414
"*":
1515
include: ["*"]

test/integration/configs/obi-config-go-otel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ otel_traces_export:
66
endpoint: http://jaeger:4318
77
attributes:
88
kubernetes:
9-
cluster_name: beyla-k8s-test-cluster
9+
cluster_name: obi-k8s-test-cluster
1010
select:
1111
"*":
1212
include: ["*"]

0 commit comments

Comments
 (0)