No Traceparent header with tracing

Hi, thanks for the help.

1. The problem I’m having:

When using tracing, I don’t get “Traceparent” header.
I do get the traces in grafana correctly, so caddy is working with tracing, but I don’t get the header at response.
I tried to follow: Tracing configuration for insecure gRPC OpenTelemetry backend like Jaeger All-In-One - #8 by andriikushch
But got a different result.

2. Error messages and/or full log output:

full log

{"level":"info","ts":1695342229.4615405,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
{"level":"warn","ts":1695342229.4619875,"logger":"http.auto_https","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
{"level":"info","ts":1695342229.4620602,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x4000093000"}
{"level":"debug","ts":1695342229.4620166,"logger":"http.auto_https","msg":"adjusted config","tls":{"automation":{"policies":[{}]}},"http":{"servers":{"srv0":{"listen":[":80"],"routes":[{"handle":[{"handler":"tracing","span":"caddy_span"},{"encodings":{"gzip":{},"zstd":{}},"handler":"encode","prefer":["gzip","zstd"]},{"body":"Hello, world!","handler":"static_response"}]}],"automatic_https":{"disable":true}}}}}
{"level":"debug","ts":1695342229.463303,"logger":"http","msg":"starting server loop","address":"[::]:80","tls":false,"http3":false}
{"level":"info","ts":1695342229.463318,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"}
{"level":"info","ts":1695342229.4633458,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
{"level":"info","ts":1695342229.4634004,"logger":"tls","msg":"finished cleaning storage units"}
{"level":"info","ts":1695342229.4635534,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1695342229.463559,"msg":"serving initial configuration"}

curl -D-

(app) 3:23:45 barman  master $ curl -D- localhost:80

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Server: Caddy
Date: Fri, 22 Sep 2023 00:23:52 GMT
Content-Length: 13

Hello, world!%

curl -vv

(app) 3:23:52 barman  master $ curl -vv localhost:80

*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/8.1.2
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Server: Caddy
< Date: Fri, 22 Sep 2023 00:24:06 GMT
< Content-Length: 13
<
* Connection #0 to host localhost left intact
Hello, world!%

curl -vvI

(app) 3:24:06 barman  master $ curl -vvI localhost:80
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> HEAD / HTTP/1.1
> Host: localhost
> User-Agent: curl/8.1.2
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
Content-Type: text/plain; charset=utf-8
< Server: Caddy
Server: Caddy
< Date: Fri, 22 Sep 2023 00:24:12 GMT
Date: Fri, 22 Sep 2023 00:24:12 GMT
< Content-Length: 13
Content-Length: 13

<
* Connection #0 to host localhost left intact

3. Caddy version:

v2.7.4 h1:J8nisjdOxnYHXlorUKXY75Gr6iBfudfoGhrJ8t7/flI=

4. How I installed and ran Caddy:

I tried both:

  • docker compose below
  • RHEL docker with dnf install caddy + grafana agent + grafana could (got traces with success at cloud)
    At both same result, I got traces in Grafana, but no header in response.

docker compose

version: '3.7'

services:
  caddy:
    container_name: caddy
    image: caddy:latest
    ports:
      - "80:80"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
    environment:
      - OTEL_SERVICE_NAME=caddy-app
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317
      - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4317
      - OTEL_EXPORTER_OTLP_INSECURE=true
      - OTEL_EXPORTER_OTLP_PROTOCOL=grpc
      - GRPC_GO_LOG_VERBOSITY_LEVEL=99
      - GRPC_GO_LOG_SEVERITY_LEVEL=info
  jaeger:
      container_name: jaeger
      environment:
          - 'COLLECTOR_ZIPKIN_HOST_PORT=:9411'
          - COLLECTOR_OTLP_ENABLED=true
      ports:
          - '6831:6831/udp'
          - '6832:6832/udp'
          - '5778:5778'
          - '16686:16686'
          - '4317:4317'
          - '4318:4318'
          - '14250:14250'
          - '14268:14268'
          - '14269:14269'
          - '9411:9411'
      image: 'jaegertracing/all-in-one:1.37'

Caddyfile

{
	debug

	log {
		output file /tmp/caddy.log
	}
}

:80
respond "Hello, world!"
encode gzip zstd
tracing {
	span caddy_span
}

a. System environment:

Macbook pro M1, os version: 13.5.2
Docker version 24.0.2, build cb74dfc
Docker Compose version v2.18.1

b. Command:

docker compose up

5. Links to relevant resources:

Update! with caddy:2.5.2 it is working

docker compose working:

version: '3.7'

services:
  caddy:
    container_name: caddy
    image: caddy:2.5.2
    depends_on:
      - jaeger
    ports:
      - "80:80"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
    environment:
      - OTEL_SERVICE_NAME=caddy-app
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317
      - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4317
      - OTEL_EXPORTER_OTLP_INSECURE=true
      - OTEL_EXPORTER_OTLP_PROTOCOL=grpc
      - GRPC_GO_LOG_VERBOSITY_LEVEL=99
      - GRPC_GO_LOG_SEVERITY_LEVEL=info
  jaeger:
      container_name: jaeger
      environment:
          - 'COLLECTOR_ZIPKIN_HOST_PORT=:9411'
          - COLLECTOR_OTLP_ENABLED=true
      ports:
          - '6831:6831/udp'
          - '6832:6832/udp'
          - '5778:5778'
          - '16686:16686'
          - '4317:4317'
          - '4318:4318'
          - '14250:14250'
          - '14268:14268'
          - '14269:14269'
          - '9411:9411'
      image: 'jaegertracing/all-in-one:1.37'

curl -D-

(app) 14:42:54 barman  master $ curl -D- localhost:80

HTTP/1.1 200 OK
Server: Caddy
Traceparent: 00-ffc851582579ae35616853693d78c865-84458e8d6e46bf38-01
Date: Fri, 22 Sep 2023 11:42:55 GMT
Content-Length: 13

Hello, world!%   

not working with:

  • caddy:latest
  • caddy:2.7.3
  • caddy:2.6.0

And I think I know why,

from caddy v2.5.2 to v2.6.0

https://github.com/caddyserver/caddy/compare/v2.5.2...v2.6.0-beta.3
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.29.0
updated to
	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0

and here they drop adding the header:

Maybe this is the expected result?
I have no idea,
I was hoping to be able to get this trace at the frontend,
So I can easily connect the traces.

Anyway this is not a caddy bug, but an underlaying change.

I had no idea it was even adding that header in the first place. The core maintainers (including myself) don’t use tracing, so we need to rely on the community to maintain that functionality.

We can probably make that an opt-in behaviour. You can open an issue on GitHub to request that feature (but know that we’re in a feature freeze for the time being so it may take a while).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.