Skip to content

Make OpenTelemetry support a build-time optional #5553

Description

@dholm

Hi,
Would you consider making the OpenTelemetry support a build-time optional so it's possible to build librdkafka without the bundled nanopb and opentelemetry-proto code? Alternatively, could you give it an option so that it uses an already installed nanopb and generates code at build-time from an opentelemetry-proto directory supplied as a build option?

I'm linking librdkafka to an application which is also using opentelemetry-proto code generated with nanopb. We have now run into issues since librdkafka bundles code generated from an older version of opentelemetry-proto.

In release builds (made with GCC) linking fails due to that the size of the structs generated from opentelemetry-proto 1.10.0 is different than the ones bundled with librdkafka:

ld.bfd: warning: size of symbol `opentelemetry_proto_metrics_v1_Metric_field_info' changed from 68 in metrics.pb.c.o (symbol from plugin) to 76 in /tmp/ccJZSvSf.ltrans312.ltrans.o
ld.bfd: warning: NOTE: size discrepancies can cause real problems.  Investigation is advised.
ld.bfd: warning: size of symbol `opentelemetry_proto_common_v1_AnyValue_field_info' changed from 48 in common.pb.c.o (symbol from plugin) to 52 in /tmp/ccJZSvSf.ltrans312.ltrans.o
ld.bfd: warning: NOTE: size discrepancies can cause real problems.  Investigation is advised.
ld.bfd: warning: size of symbol `opentelemetry_proto_metrics_v1_Metric_submsg_info' changed from 48 in metrics.pb.c.o (symbol from plugin) to 56 in /tmp/ccJZSvSf.ltrans312.ltrans.o
ld.bfd: warning: NOTE: size discrepancies can cause real problems.  Investigation is advised.
ld.bfd: warning: size of symbol `opentelemetry_proto_common_v1_KeyValue_field_info' changed from 20 in common.pb.c.o (symbol from plugin) to 24 in /tmp/ccJZSvSf.ltrans312.ltrans.o
ld.bfd: warning: NOTE: size discrepancies can cause real problems.  Investigation is advised.
ld.bfd: warning: size of symbol `opentelemetry_proto_resource_v1_Resource_submsg_info' changed from 16 in resource.pb.c.o (symbol from plugin) to 24 in /tmp/ccJZSvSf.ltrans312.ltrans.o
ld.bfd: warning: NOTE: size discrepancies can cause real problems.  Investigation is advised.
ld.bfd: warning: size of symbol `opentelemetry_proto_resource_v1_Resource_field_info' changed from 16 in resource.pb.c.o (symbol from plugin) to 24 in /tmp/ccJZSvSf.ltrans312.ltrans.o
ld.bfd: warning: NOTE: size discrepancies can cause real problems.  Investigation is advised.

In Undefined Behavior Sanitizer builds using Clang we instead get ODR violations.

==4==ERROR: AddressSanitizer: odr-violation (0x7f5f77f14240):
  [1] size=52 'opentelemetry_proto_common_v1_AnyValue_field_info' ./<our-code>/opentelemetry/proto/common/v1/common.pb.c:9 in /usr/local/lib/<our-lib>.so
  [2] size=48 'opentelemetry_proto_common_v1_AnyValue_field_info' librdkafka/src/opentelemetry/common.pb.c in /usr/local/lib/librdkafka.so.1

In both cases we link dynamically to both nanopb and librdkafka.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions