Skip to content

Conversation

satyamz
Copy link
Contributor

@satyamz satyamz commented Aug 22, 2025

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with name of package that is most changed in the PR, ex.
    services/friendbot, or all or doc if the changes are broad or impact many
    packages.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated any docs (developer docs, .md
    files, etc... affected by this change). Take a look in the docs folder for a given service,
    like this one.

Release planning

  • I've reviewed the changes in this PR and if I consider them worthwhile for being mentioned on release notes then I have updated the relevant CHANGELOG.md within the component folder structure. For example, if I changed horizon, then I updated (services/horizon/CHANGELOG.md. I add a new line item describing the change and reference to this PR. If I don't update a CHANGELOG, I acknowledge this PR's change may not be mentioned in future release notes.
  • I've decided if this PR requires a new major/minor version according to
    semver, or if it's mainly a patch change. The PR is targeted at the next
    release branch if it's not a patch change.

What

services/friendbot: Instrument friendbot to emit traces. Traces will be sent to Grafana alloy which will send traces to Grafana tempo.

Trace looks like this in Grafana tempo:

image

Why

  • We want to have an ability track request lifecycle
  • Help identify performance bottlenecks.

Known limitations

This PR updates several dependencies. We need land this carefully.

Issue:

https://github.com/stellar/ops/issues/4005

Copy link

socket-security bot commented Aug 22, 2025

@satyamz satyamz marked this pull request as ready for review September 10, 2025 14:47
@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 14:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR instruments the friendbot service to emit OpenTelemetry traces that will be sent to Grafana Alloy and forwarded to Grafana Tempo for distributed tracing capabilities and performance monitoring.

  • Added a new utils/tracer package with OpenTelemetry configuration
  • Updated friendbot service to use context-aware tracing throughout the request lifecycle
  • Added OpenTelemetry middleware to the HTTP router for automatic request tracing

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utils/tracer/tracer.go New utility package for OpenTelemetry tracer initialization and configuration
services/friendbot/main.go Updated to initialize tracing, add OpenTelemetry middleware, and use chi/v5 router
services/friendbot/internal/friendbot_handler.go Added tracing instrumentation to HTTP request handlers
services/friendbot/internal/friendbot.go Updated Pay method to accept context for tracing
services/friendbot/internal/minion.go Added context parameter and span instrumentation to minion operations
services/friendbot/internal/minion_test.go Updated test functions to pass context parameter
services/friendbot/internal/friendbot_test.go Updated test functions to pass context parameter
services/friendbot/friendbot.cfg Added otel_endpoint configuration
go.mod Updated dependencies to include OpenTelemetry packages and chi/v5

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@satyamz
Copy link
Contributor Author

satyamz commented Sep 18, 2025

I am fixing the internal package tests.

@satyamz satyamz force-pushed the friendbot-instrumentation-03 branch from a0dded9 to 873e3fa Compare September 18, 2025 11:42
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments inline.

@leighmcculloch
Copy link
Member

Before merging can you check that this will still function okay with quickstart? You can do that by building quickstart with the friendbot git ref pointing at your friendbot pr commit sha.

@satyamz satyamz force-pushed the friendbot-instrumentation-03 branch from 16efad5 to 65ba471 Compare September 25, 2025 11:26
@satyamz satyamz force-pushed the friendbot-instrumentation-03 branch from 46fc1de to 8eb2292 Compare October 1, 2025 15:19
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.

2 participants