Skip to content

chore: simplify, modernize (Go 1.26), update deps#89

Merged
rustatian merged 10 commits into
masterfrom
chore/cleanup-modernize-deps
May 31, 2026
Merged

chore: simplify, modernize (Go 1.26), update deps#89
rustatian merged 10 commits into
masterfrom
chore/cleanup-modernize-deps

Conversation

@rustatian
Copy link
Copy Markdown
Member

@rustatian rustatian commented May 29, 2026

Applied fixes

R (bug/correctness) — 1

  • temporal_interceptor.go: handle discarded NewTracingInterceptor error — previously the error was silently ignored, leaving a nil interceptor that would panic at call time; interceptor is now built once in Init and the error propagates correctly.

R (correctness) — 1 (shadow)

  • plugin.go: rename local variable resourceres to remove the shadow of the imported resource package within Init.

S (simplify) — 4

  • temporal_interceptor.go: remove pointless temporalInterceptor func-type alias and TemporalHandler/temporalWrapper indirection; store interceptor.WorkerInterceptor directly on the struct.
  • plugin.go: inline Stop assign/check/reassign into two if err := one-liners ending with return p.tracer.Shutdown(ctx).
  • plugin.go: inline HTTPHandler(next, p.httpMiddleware)p.httpMiddleware(next).
  • plugin.go: drop explicit string type on pluginName const.

M (modernize) — 2

  • config.go: unify semconv import to v1.40.0 (was v1.39.0; plugin.go already used v1.40.0).
  • plugin.go: replace make([]Option, 0, 5) with var options in grpcOptions and httpOptions.

Deps

  • Updated otel core/sdk/trace/metric, exporters, contrib/otelhttp, contrib/jaeger, grpc to latest compatible versions.

Summary by CodeRabbit

  • Dependencies

    • Updated OpenTelemetry semantic conventions and SDK libraries to latest versions
    • Updated Temporal SDK and related dependencies
    • Updated gRPC and supporting utilities
  • Tests

    • Added configuration initialization and client selection validation tests
    • Added plugin lifecycle and middleware functionality tests
    • Added Temporal workflow tracing integration tests
  • CI/CD

    • Enhanced test workflow with local Temporal dev server for improved tracing coverage validation

- Fix discarded NewTracingInterceptor error (nil → panic); eliminate
  func-type indirection by building the interceptor once in Init
- Rename local `resource` variable to `res` to remove package shadow
- Drop explicit `string` type on `pluginName` const
- Inline `Stop` two-if pattern to single return
- Inline `HTTPHandler` call site (p.httpMiddleware(next))
- Unify semconv import to v1.40.0 across config.go and plugin.go
- Replace `make([]Option, 0, 5)` with `var options` in grpcOptions/httpOptions
- Update otel, contrib, and grpc dependencies to latest compatible versions
Copilot AI review requested due to automatic review settings May 29, 2026 12:32
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Review Change Stack

Warning

Review limit reached

@rustatian, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 39 minutes and 54 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2f8905a-ac5c-4700-8213-13e1aa3debcd

📥 Commits

Reviewing files that changed from the base of the PR and between 905eeb6 and 17a503d.

📒 Files selected for processing (2)
  • .github/workflows/linux.yml
  • tests/temporal_test.go
📝 Walkthrough

Walkthrough

This PR upgrades the OpenTelemetry plugin to use v1.44 dependencies, refactors middleware patterns to remove wrapper indirection, and adds comprehensive test coverage including config validation, plugin lifecycle tests, and Temporal integration testing with a dev server.

Changes

Refactor and Test OpenTelemetry Plugin v1.44 Upgrade

Layer / File(s) Summary
Dependency Updates and Import Normalization
go.mod, config.go, plugin.go
OpenTelemetry, Temporal, and transitive dependencies bumped to v1.44/v1.44.1 line; semantic convention imports normalized to v1.41.0 across config and plugin.
Middleware Refactoring and Error Propagation
http_middleware.go, temporal_interceptor.go
HTTPHandler wrapper removed; temporalWrapper replaced with newTemporalInterceptor that propagates constructor errors and directly returns the worker interceptor.
Plugin Type Changes and Initialization Refactor
plugin.go
temporalInterceptor field retyped to interceptor.WorkerInterceptor; Init refactored to construct tracer, propagators, HTTP middleware, and temporal interceptor sequentially; Middleware/WorkerInterceptor methods simplified to return stored values directly; Stop error handling streamlined; option builder slice initialization changed to zero-value style.
Test Module Setup and Config Testing
tests/go.mod, tests/config_test.go
Test module established with dependencies; three test functions added covering InitDefault behavior, OTLP client selection precedence via environment variables, and Resource attribute precedence rules.
Plugin Unit Tests
tests/plugin_test.go
Two unit tests verify exporter selection during Plugin.Init (stdout/stderr succeed, deprecated/unknown fail) and end-to-end plugin lifecycle including tracer/interceptor initialization, HTTP middleware forwarding, and graceful shutdown.
Temporal Integration Testing
tests/temporal_test.go
Integration test executes Temporal workflows against dev server with OpenTelemetry tracing interceptor; verifies workflow result and asserts exported spans match expected activity/workflow names.
CI/CD Updates for Temporal Testing and Coverage
.github/workflows/linux.yml, Makefile
GitHub Actions workflow installs Temporal CLI, starts dev server, runs tests with race detection and coverage, uploads coverage artifacts, and filters results for Codecov; Makefile test target expanded to run tests subdirectory with coverage configuration.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Suggested Labels

enhancement, bug


🐰 A refactored Warren awaits, where patterns fade and tests bloom,
Dependencies dance to v1.44's tune, while Temporal workflows groom,
Interceptors stand tall without wrapper chains, direct and clean,
Coverage spans the fullest test of any Temporal scene! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: simplify, modernize (Go 1.26), update deps' accurately describes the main changes: code simplifications, modernization improvements, and dependency updates across multiple files.
Description check ✅ Passed The PR description is comprehensive, covering applied fixes (correctness and simplifications), modernizations, dependency updates, and deferred decisions. However, it omits the 'Reason for This PR' section and does not complete all checklist items from the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cleanup-modernize-deps

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 and usage tips.

Copy link
Copy Markdown

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 modernizes the module’s Go/OpenTelemetry stack and simplifies the plugin’s interceptor wiring, including fixing an error-handling bug that could previously lead to a nil Temporal interceptor and a runtime panic.

Changes:

  • Simplifies Temporal worker interceptor construction and correctly propagates NewTracingInterceptor errors during Init.
  • Cleans up plugin.go control flow (inline wrappers, remove package-shadowing local name, simplify Stop).
  • Updates OpenTelemetry + gRPC (and related) dependencies; aligns semconv imports.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
temporal_interceptor.go Replaces wrapper/alias indirection with a constructor that returns (WorkerInterceptor, error)
plugin.go Stores the Temporal interceptor directly, handles constructor errors in Init, simplifies middleware and shutdown paths
config.go Aligns semconv import version (v1.40.0)
go.mod Updates dependency versions (and module now targets Go 1.26 per go.mod)
go.sum Updates checksums to match dependency upgrades

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugin.go
Middleware now calls p.httpMiddleware(next) directly, so the HTTPHandler
wrapper is dead code. Its only argument is the unexported httpMiddleware
type, so it was never usable as public API. Drop it for symmetry with the
already-removed TemporalHandler helper.
@rustatian rustatian self-assigned this May 31, 2026
rustatian added 6 commits May 31, 2026 19:16
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
The SDK bump to v1.44.0 made its built-in resource detectors emit schema
1.41.0, while the plugin still pinned semconv/v1.40.0. resource.New then
returns a conflicting-schema error that Init treats as fatal, so the plugin
failed to start with every exporter. Bump semconv to v1.41.0 to match the SDK.
Adds a tests/ module (wired via go.work) with black-box tests against the
plugin's exported API:
- config defaults, env-based exporter-client selection, resource precedence
- plugin Init exporter selection + HTTP middleware lifecycle
- a Temporal worker-interceptor test that runs a Go-SDK workflow against
  'temporal server start-dev' (gated by TEMPORAL_ADDRESS, no PHP worker)

CI installs the Temporal CLI and runs the dev server; 'make test' now runs
both modules with coverage attributed to the otel packages.
Guards the drain goroutine against leaking if an assertion fails between
the stdout redirect and the explicit close.
Replace the os.Stdout pipe-capture with the http plugin's approach: a
tracetest.InMemoryExporter behind a synchronous TracerProvider, read via
GetSpans(). No global stdout/stderr redirection, no flush-timing hacks.
Mirror the http plugin: archive the coverage profile as an artifact and add
a codecov job that filters to the otel module paths and uploads via
codecov/codecov-action (fail_ci_if_error: false).
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

❌ Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@fa747b2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
plugin.go 54.54% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master      #89   +/-   ##
=========================================
  Coverage          ?   63.48%           
=========================================
  Files             ?        4           
  Lines             ?      178           
  Branches          ?        0           
=========================================
  Hits              ?      113           
  Misses            ?       57           
  Partials          ?        8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (1)
tests/plugin_test.go (1)

103-105: ⚡ Quick win

Assert response body passthrough (or adjust the test claim).

The test description says status/body are preserved, but only status is asserted. Add a body assertion to match the stated contract.

Proposed patch
 	require.True(t, called, "the wrapped handler must be invoked")
 	require.Equal(t, http.StatusTeapot, resp.StatusCode, "status code must propagate through the middleware")
+	body, err := io.ReadAll(resp.Body)
+	require.NoError(t, err)
+	require.Equal(t, "ok", string(body), "response body must propagate through the middleware")
 
 	require.NoError(t, p.Stop(context.Background()))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/plugin_test.go` around lines 103 - 105, The test claims the middleware
preserves status and body but only asserts status; update the test in
tests/plugin_test.go to also assert the response body passthrough by reading
resp.Body (or using ioutil.ReadAll / io.ReadAll) and comparing it to the
expected payload the wrapped handler returns (use the same fixture string used
when constructing the wrapped handler), e.g., assert the body equals that
expected value alongside the existing require.True(t, called) and
require.Equal(t, http.StatusTeapot, resp.StatusCode) checks so the test
validates both status and body passthrough for resp.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/linux.yml:
- Line 62: The checkout step currently uses actions/checkout@v6 which by default
persists the token in git config; update that step to disable credential
persistence by adding persist-credentials: false to the step configuration so
the token is not retained in the repo checkout used for the Codecov upload.
Target the step that references "uses: actions/checkout@v6" and add the
persist-credentials: false input to it.
- Around line 38-47: The Temporal startup/cleanup block needs a trap and a
readiness timeout failure so the Temporal process is always cleaned up and the
job fails deterministically when Temporal never becomes ready: after launching
"temporal server start-dev ..." and setting SERVER_PID, register a trap on EXIT
to kill "$SERVER_PID" (guarding for an empty PID), then change the health check
loop that uses "temporal operator cluster health --address 127.0.0.1:7233" to
explicitly fail if the loop completes without success (e.g., exit non-zero with
an error message), and remove the unconditional final "kill \"$SERVER_PID\" ||
true" in favor of relying on the trap to ensure cleanup.
- Around line 28-31: Replace the unsafe "curl -sSf
https://temporal.download/cli.sh | sh" in the "Install Temporal CLI (dev
server)" step with a deterministic download and checksum verification: fetch a
pinned release artifact (e.g., a specific versioned tarball/zip from Temporal
releases or a known URL), verify its SHA256 (or GPG) signature against a
checked-in/lookup value, then extract/install the binary into
"$HOME/.temporalio/bin" and append that path to GITHUB_PATH; ensure the workflow
step that currently runs the curl pipe is updated to use the versioned URL, the
checksum verification command, and only run the installer if the checksum
matches.
- Line 49: The workflow uses entries like actions/upload-artifact@v7,
actions/checkout@v6, actions/download-artifact@v8, and codecov/codecov-action@v6
(and similar tags across .github/workflows/) which are tag-pinned; update each
`uses:` reference to a specific commit SHA instead of a tag (e.g., replace
actions/upload-artifact@v7 with actions/upload-artifact@<commit-sha>) to pin to
an immutable release, verify the commit SHAs from the respective repositories,
and apply the same change consistently across all workflow files; keep the same
repository and action path (e.g., actions/upload-artifact, actions/checkout,
actions/download-artifact, codecov/codecov-action) so CI semantics do not
change.

In `@tests/temporal_test.go`:
- Around line 79-94: After successfully starting the worker with w.Start(),
ensure w.Stop() runs on every test path by deferring the shutdown immediately
after Start succeeds; i.e., after calling require.NoError(t, w.Start()) (or
right after checking Start returned nil) add a deferred call to w.Stop() (or
defer func(){ _ = w.Stop() } to ignore its error) so the worker is always
stopped even if later require assertions fail — update references in this test
surrounding w.Start() and w.Stop() accordingly.

---

Nitpick comments:
In `@tests/plugin_test.go`:
- Around line 103-105: The test claims the middleware preserves status and body
but only asserts status; update the test in tests/plugin_test.go to also assert
the response body passthrough by reading resp.Body (or using ioutil.ReadAll /
io.ReadAll) and comparing it to the expected payload the wrapped handler returns
(use the same fixture string used when constructing the wrapped handler), e.g.,
assert the body equals that expected value alongside the existing
require.True(t, called) and require.Equal(t, http.StatusTeapot, resp.StatusCode)
checks so the test validates both status and body passthrough for resp.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 65928bfe-b606-44ce-9b19-ccf2f2c6b4ce

📥 Commits

Reviewing files that changed from the base of the PR and between fa747b2 and 905eeb6.

⛔ Files ignored due to path filters (4)
  • go.sum is excluded by !**/*.sum
  • go.work is excluded by !**/*.work
  • go.work.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (11)
  • .github/workflows/linux.yml
  • Makefile
  • config.go
  • go.mod
  • http_middleware.go
  • plugin.go
  • temporal_interceptor.go
  • tests/config_test.go
  • tests/go.mod
  • tests/plugin_test.go
  • tests/temporal_test.go
💤 Files with no reviewable changes (1)
  • http_middleware.go

Comment thread .github/workflows/linux.yml
Comment thread .github/workflows/linux.yml
Comment thread .github/workflows/linux.yml
Comment thread .github/workflows/linux.yml
Comment thread tests/temporal_test.go
rustatian added 2 commits May 31, 2026 20:23
- CI: install Temporal via the official temporalio/setup-temporal action
  instead of curl|sh
- CI: disable git credential persistence in the codecov checkout step
- test: stop the Temporal worker once on all paths (sync.Once + t.Cleanup)
  so an early assertion failure cannot leak the worker
The temporalio/setup-temporal action is unmaintained: @v0.1.0 is broken (runs a
missing ./setup-temporal.sh, exit 127) and @v0 is a node16 action from 2023.
The official curl|sh installer is the reliable choice for CI.
@rustatian rustatian merged commit 7f0d504 into master May 31, 2026
11 checks passed
@rustatian rustatian deleted the chore/cleanup-modernize-deps branch May 31, 2026 18:29
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