Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

@Retention(CLASS) @Target({TYPE})

public @interface OpenTelemetry

Traces this server with OpenTelemetry.

Put it on any class in the backend module – a controller is the natural place. The build then wires a tracer into the entry point it generates, and from then on every request, every outbound Web call and every Database statement is a span, exported over OTLP/HTTP to the collector the deployment names:

@OpenTelemetry(serviceName = "orders")
@RestController
public class OrderController { ... }
OTEL_EXPORTER_OTLP_ENDPOINT=https://collector.internal:4318 ./server

Nothing else changes. An incoming traceparent makes the request part of the caller’s trace – which is how a Codename One app’s own spans connect to the server’s – and the W3C trace context is sent on every outbound request.

A project that would rather not touch its source can set cn1.otel.enabled=true in application.properties instead; the effect is the same.

THIS IS A BUILD-TIME SWITCH, and deliberately so. Without it the tracer is never referenced, so the translator leaves it out of the binary entirely. With it, the deployment still has the last word: OTEL_SDK_DISABLED=true turns tracing off at start-up without a rebuild, and so does cn1.otel.enabled=false. The other way round cannot work: a server built without the tracer that finds cn1.otel.enabled=true at run time does not start, and says the key belongs in the module’s application.properties.

Methods

public abstract String serviceName() default ""The service.name spans are reported under, unless OTEL_SERVICE_NAME or cn1.otel.service.name names another.
public abstract String endpoint() default ""The collector’s base URL, cn1.otel.endpoint, compiled in below OTEL_EXPORTER_OTLP_ENDPOINT and the properties files.
public abstract String protocol() default ""cn1.otel.protocol: http/protobuf or http/json.
public abstract String sampler() default ""cn1.otel.sampler, such as traceidratio.
public abstract String samplerArg() default ""cn1.otel.sampler.arg: the ratio for the ratio samplers.

Method details

serviceName

public abstract String serviceName() default ""
The service.name spans are reported under, unless OTEL_SERVICE_NAME or cn1.otel.service.name names another. Empty means unknown_service, which is what every OpenTelemetry SDK reports when nobody said.

endpoint

public abstract String endpoint() default ""
The collector’s base URL, cn1.otel.endpoint, compiled in below OTEL_EXPORTER_OTLP_ENDPOINT and the properties files. Empty sets nothing.

protocol

public abstract String protocol() default ""
cn1.otel.protocol: http/protobuf or http/json. Empty sets nothing.

sampler

public abstract String sampler() default ""
cn1.otel.sampler, such as traceidratio. Empty sets nothing.

samplerArg

public abstract String samplerArg() default ""
cn1.otel.sampler.arg: the ratio for the ratio samplers. Empty sets nothing.