Resolving OpenTelemetry Errors in Actix-Server

TLDR Riccardo was experiencing errors with OpenTelemetry in Actix-Server. Ashish recommended checking the data model, adjusting OTEL exporter settings, and enabling the gRPC protocol; yet, results are still not evident.

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 12:21:20 UTC

```thread 'actix-server worker 2' panicked at 'called `Option::unwrap()` on a `None` value', src/service/traces/otlp_http.rs:237:73 thread 'actix-server worker 3' panicked at 'called `Option::unwrap()` on a `None` value', src/service/traces/otlp_http.rs:237:73 thread 'actix-server worker 0' panicked at 'called `Option::unwrap()` on a `None` value', src/service/traces/otlp_http.rs:237:73 thread 'actix-server worker 1' panicked at 'called `Option::unwrap()` on a `None` value', src/service/traces/otlp_http.rs:237:73 thread 'actix-server worker 2' panicked at 'called `Option::unwrap()` on a `None` value', src/service/traces/otlp_http.rs:237:73 thread 'actix-server worker 3' panicked at 'called `Option::unwrap()` on a `None` value', src/service/traces/otlp_http.rs:237:73```

Photo of Ashish
Ashish
Fri, 06 Oct 2023 12:31:00 UTC

its failing because no value is set for start_time_unix_nano

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 12:32:12 UTC

ok, I'm check the data, I want to user OpenTelemetry with PHP...

Photo of Ashish
Ashish
Fri, 06 Oct 2023 12:32:30 UTC

sure

Photo of Ashish
Ashish
Fri, 06 Oct 2023 12:32:45 UTC

Photo of Ashish
Ashish
Fri, 06 Oct 2023 12:32:50 UTC

check this for data model

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 12:37:11 UTC

Ashish if I try with first data example, I got: ```{"code":400,"message":"Invalid json: the structure must be {\"resourceSpans\":[]}"}```

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 12:37:55 UTC

On the server now: ```[2023-10-06T12:37:34Z INFO actix_web::middleware::logger] 172.16.2.3 "POST /api/default/traces HTTP/1.1" 400 83 "447" "-" "curl/7.88.1" 0.000484```

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 12:38:05 UTC

So it's better :slightly_smiling_face:

Photo of Ashish
Ashish
Fri, 06 Oct 2023 12:48:40 UTC

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:00:23 UTC

With PHP if I set `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf` I don't receive data... I don't understand what I'm doing wrong

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:01:45 UTC

```env OTEL_PHP_AUTOLOAD_ENABLED=true \ OTEL_METRICS_EXPORTER=none \ OTEL_LOGS_EXPORTER=none \ OTEL_SERVICE_NAME=smb \ OTEL_TRACES_EXPORTER=otlp \ OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \ OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic XXXX" \ OTEL_EXPORTER_OTLP_ENDPOINT= \ php -S localhost:8088```

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:02:17 UTC

I'm trying with this example:

Photo of Ashish
Ashish
Fri, 06 Oct 2023 13:31:59 UTC

```OTEL_EXPORTER_OTLP_ENDPOINT = localhost:5081```

Photo of Ashish
Ashish
Fri, 06 Oct 2023 13:32:13 UTC

please note this is for non-HA deployemnet

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:39:27 UTC

Ok, actually I've remote host behind haproxy and I forward only port 5080

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:40:17 UTC

```docker run -d --name "openobserve" --volumes-from openobserve-data -e ZO_DATA_DIR="/data" -p 5080:5080 \ -e ZO_ROOT_USER_PASSWORD="XXX" \ public.ecr.aws/zinclabs/openobserve:latest```

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:40:31 UTC

So, I've to expose also port 5081?

Photo of Ashish
Ashish
Fri, 06 Oct 2023 13:40:38 UTC

yes

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:41:53 UTC

Ok, I'm trying...

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 13:58:57 UTC

but I need to set `OTEL_EXPORTER_OTLP_PROTOCOL=grpc` to `grpc` correct?

Photo of Ashish
Ashish
Fri, 06 Oct 2023 14:01:44 UTC

yes..if you want to use grpc with proto

Photo of Ashish
Ashish
Fri, 06 Oct 2023 14:02:02 UTC

since you are gone forward to 5081 it has to be grpc

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 14:07:49 UTC

ok...

Photo of Riccardo
Riccardo
Fri, 06 Oct 2023 15:14:55 UTC

I've to check my configuration, because I didn't see any traces...