Skip to content

Add webapp-go-greeter sample - #28

Open
Ketharan wants to merge 4 commits into
openchoreo:mainfrom
Ketharan:feat/webapp-go-greeter
Open

Ketharan wants to merge 4 commits into
openchoreo:mainfrom
Ketharan:feat/webapp-go-greeter

Conversation

@Ketharan

@Ketharan Ketharan commented Oct 17, 2026 •

Copy link
Copy Markdown

Purpose

The repository has no sample that consumes another component's endpoint through a declared
dependency. This adds one, so the connect-components flow has something to point at.

Approach

webapp-go-greeter is a Go web application that renders a greeting page and calls
service-go-greeter to produce the greeting:

browser -> webapp-go-greeter -> service-go-greeter

The second hop is the point. The webapp never hardcodes the greeter's address; it reads
GREETING_SERVICE_URL, which OpenChoreo resolves per environment from a declared dependency.
With the variable unset the page still loads and the greeting fails with a readable error.

The dependency block in workload.yaml is left commented out, because declaring it is the
exercise. Readiness reports on this app only and never checks the greeter, so a greeter outage
cannot take the pod out of service. Traces are exported over OTLP and logs are JSON carrying
trace_id and span_id; both are best-effort and disabled when no collector is configured.

Related Issues

None.

Checklist

  • Tests added or updated (unit, integration, etc.)
  • Samples updated (if applicable)

A Go web application that renders a greeting page and calls the
go-greeter service to produce the greeting itself:

    browser -> webapp-go-greeter -> service-go-greeter

The second hop is the point of the sample. The webapp never hardcodes an
address for the greeter; it reads GREETING_SERVICE_URL, which OpenChoreo
resolves per environment from a declared dependency. With the variable
unset the page still loads and the greeting fails with a readable error.

The response shows which service produced which half of the answer, so
the call chain is visible on the page.

Trace context headers (traceparent, tracestate, baggage, x-request-id and
B3) are copied onto the downstream request, so the two hops join into a
single trace rather than two unrelated ones.

The dependency block in workload.yaml is left commented out, because
declaring it is the exercise in the course lesson on connecting
components. The readiness probe reports on this app only and never checks
the greeter, so a greeter outage cannot take this pod out of service.

Signed-off-by: Ketharan <ketharan.mail@gmail.com>
The sample previously only forwarded trace headers, so it never appeared in
a trace backend. It now exports spans over OTLP and writes JSON logs that
carry trace_id and span_id, so a log line can be matched to the trace that
produced it.

- a span for the inbound request and for the outbound call to the greeter,
  with context propagated so the two hops form one trace
- resource attributes for the component, environment and project when
  OpenChoreo supplies them
- tracing is best-effort: disabled when no OTLP endpoint is set, and a
  warning rather than a failure when the collector is unreachable

Go moves to 1.26 in both go.mod and the Dockerfile, which the OpenTelemetry
modules require.

Signed-off-by: Ketharan <ketharan.mail@gmail.com>
The subtitle described the sample's own two-service topology, which reads
as internal detail to anyone opening the page. Replace it with a plain
welcome; the response cards still show which service produced which half.

Signed-off-by: Ketharan <ketharan.mail@gmail.com>
The response showed which service answered, the resolved upstream address
and the round-trip time, and the second line leaned on deployment jargon.
That is useful when debugging and out of place for someone who came to say
hello.

The page now shows just the greeting and a friendly line under it. The
service name, upstream address, elapsed time and trace id are still in the
JSON response and in the logs, where they belong.

Signed-off-by: Ketharan <ketharan.mail@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72aa6187-39e2-44b1-9167-e9d799f9f8f5
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant