Skip to content

Add OTLP HTTP exporter support#23

Open
digitalfiz wants to merge 6 commits intomainfrom
feat/http-otlp-support
Open

Add OTLP HTTP exporter support#23
digitalfiz wants to merge 6 commits intomainfrom
feat/http-otlp-support

Conversation

@digitalfiz
Copy link
Copy Markdown
Contributor

@digitalfiz digitalfiz commented Mar 30, 2026

Summary

  • add OPENCODE_OTLP_PROTOCOL with grpc and http/protobuf support while preserving grpc as the default
  • select the appropriate OTLP exporters at startup and expand HTTP base endpoints to /v1/traces, /v1/metrics, and /v1/logs
  • update tests and documentation, including a Grafana Cloud HTTP example

Closes #21

Testing

  • bun run typecheck
  • bun test

Summary by CodeRabbit

  • New Features

    • OTLP exporter now supports HTTP/protobuf in addition to gRPC; selectable via OPENCODE_OTLP_PROTOCOL (default: grpc)
    • Endpoints now adapt semantics for gRPC vs HTTP/protobuf
  • Documentation

    • README, quick-starts, examples (including Grafana Cloud) and CHANGELOG updated to document protocol and endpoint behavior
    • CONTRIBUTING and PR template updated to include lint and JSDoc checks
  • Chores

    • Added HTTP OTLP exporter packages, linting, and JSDoc-coverage scripts; CI and pre-commit run these checks
  • Tests

    • Added tests covering protocol config and HTTP signal URL construction

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Warning

Rate limit exceeded

@digitalfiz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 1 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 10 minutes and 1 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0be322e9-ae81-40ed-be84-3f74062e5af7

📥 Commits

Reviewing files that changed from the base of the PR and between fb8990a and 96a3788.

📒 Files selected for processing (9)
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • .github/ISSUE_TEMPLATE/config.yml
  • .github/ISSUE_TEMPLATE/feature_request.yml
  • .github/workflows/opencode.yml
  • CHANGELOG.md
  • SECURITY.md
  • package.json
  • scripts/check-jsdoc-coverage.mjs
  • tests/jsdoc-coverage.test.ts
📝 Walkthrough

Walkthrough

Adds OTLP HTTP/protobuf exporter support alongside gRPC, introduces OPENCODE_OTLP_PROTOCOL (defaults to grpc), updates config and startup to pass protocol through, creates per-signal HTTP URLs, adds HTTP exporter deps, updates docs, CI/lint/jsdoc checks, and extends tests for config and URL construction.

Changes

Cohort / File(s) Summary
Changelog & README
CHANGELOG.md, README.md
Added "Unreleased" entry and README docs for OPENCODE_OTLP_PROTOCOL, endpoint semantics, examples (including Grafana Cloud) and headers guidance.
Dependencies & Scripts
package.json
Added @opentelemetry/exporter-*-otlp-http deps for traces/metrics/logs; added lint and check:jsdoc-coverage scripts and ESLint/JSDoc devDeps.
Config
src/config.ts
PluginConfig gains `protocol: "grpc"
Startup / Index
src/index.ts
Startup log includes protocol; setupOtel() now receives protocol argument.
OTel Exporter Logic
src/otel.ts
Added buildHttpSignalUrl(endpoint, signal); setupOtel() signature updated to accept protocol and constructs reusable exporters per protocol (gRPC uses endpoint, HTTP/protobuf uses per-signal URLs).
Tests
tests/config.test.ts, tests/probe.test.ts
Added tests for OPENCODE_OTLP_PROTOCOL behavior (default, http/protobuf, fallback) and unit tests for buildHttpSignalUrl() normalization/appending.
Tooling & CI
.coderabbit.yaml, .github/PULL_REQUEST_TEMPLATE.md, .github/workflows/ci.yml, .pre-commit-config.yaml, eslint.config.mjs, scripts/check-jsdoc-coverage.mjs, tests/jsdoc-coverage.test.ts, tsconfig.json, CONTRIBUTING.md
Introduced lint & JSDoc coverage checks (script, ESLint config, pre-commit and CI additions), added jsdoc-coverage test, updated contributing and PR template, excluded ESLint config from TS compile.

Sequence Diagram(s)

sequenceDiagram
    participant Plugin as Plugin Startup
    participant Config as Config Loader
    participant Otel as OTLP Setup
    participant Collector as Collector / Exporter Target

    Plugin->>Config: loadConfig()
    Config-->>Plugin: return { protocol, endpoint, ... }

    Plugin->>Otel: setupOtel(endpoint, protocol, ...)
    alt protocol == "grpc"
        Otel->>Collector: initialize gRPC exporters using host:port endpoint
    else protocol == "http/protobuf"
        Otel->>Otel: buildHttpSignalUrl(endpoint, traces/metrics/logs)
        Otel->>Collector: initialize HTTP/protobuf exporters using /v1/traces, /v1/metrics, /v1/logs
    end

    Otel-->>Plugin: return OtelProviders (tracer, meter, logger)
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped from gRPC into HTTP's glade,

I stitch /v1/traces, /metrics, /logs in the shade,
Env var chosen, protocol set with delight,
Telemetry hops off, onward into the light,
Grafana-bound, my data takes flight.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive The PR includes scope-relevant additions (linting, JSDoc coverage checks, ESLint config) that support code quality but extend beyond HTTP exporter support. These appear to be orthogonal improvements, not directly tied to #21. Clarify whether linting/JSDoc infrastructure changes (eslint.config.mjs, scripts/check-jsdoc-coverage.mjs, etc.) are part of this PR's scope or should be separated into a dedicated infrastructure PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: adding support for OTLP HTTP exporter alongside existing gRPC support, which is the core objective of the PR.
Linked Issues check ✅ Passed All coding requirements from issue #21 are met: HTTP/protobuf exporter support added via OPENCODE_OTLP_PROTOCOL config, appropriate exporters instantiated based on protocol, and HTTP endpoints expanded to include /v1/traces, /v1/metrics, /v1/logs.

✏️ 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 feat/http-otlp-support

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

@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.

🧹 Nitpick comments (1)
src/otel.ts (1)

57-61: JSDoc is outdated—still mentions only OTLP/gRPC.

The function now supports both protocols, but the docstring wasn't updated.

📝 Suggested fix
 /**
  * Initialises the OTel SDK — creates a `MeterProvider`, `LoggerProvider`, and
- * `BasicTracerProvider` backed by OTLP/gRPC exporters pointed at `endpoint`, and
+ * `BasicTracerProvider` backed by OTLP exporters (gRPC or HTTP/protobuf) pointed at `endpoint`, and
  * registers them as the global providers.
  */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/otel.ts` around lines 57 - 61, Update the JSDoc block above the OTel SDK
initializer in src/otel.ts (the comment that currently references creating a
`MeterProvider`, `LoggerProvider`, and `BasicTracerProvider`) to reflect that
the function supports both OTLP/gRPC and OTLP/HTTP exporters; explicitly mention
both protocols and any payload formats (e.g., protobuf/JSON) and note that
exporters are pointed at the configured `endpoint`, and that the providers are
registered globally so readers know both protocols are supported.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/otel.ts`:
- Around line 57-61: Update the JSDoc block above the OTel SDK initializer in
src/otel.ts (the comment that currently references creating a `MeterProvider`,
`LoggerProvider`, and `BasicTracerProvider`) to reflect that the function
supports both OTLP/gRPC and OTLP/HTTP exporters; explicitly mention both
protocols and any payload formats (e.g., protobuf/JSON) and note that exporters
are pointed at the configured `endpoint`, and that the providers are registered
globally so readers know both protocols are supported.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61a7ca51-57d4-4d2f-9b75-6ffa1ecb4a56

📥 Commits

Reviewing files that changed from the base of the PR and between c75ec47 and d679862.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • CHANGELOG.md
  • README.md
  • package.json
  • src/config.ts
  • src/index.ts
  • src/otel.ts
  • tests/config.test.ts
  • tests/probe.test.ts

@digitalfiz digitalfiz changed the title feat(otel): add OTLP HTTP exporter support Add OTLP HTTP exporter support Mar 30, 2026
@digitalfiz
Copy link
Copy Markdown
Contributor Author

Addressed in follow-up commit 0dda12a.

I updated the setupOtel JSDoc in src/otel.ts to describe both supported transports (grpc and http/protobuf) and re-ran bun run typecheck and bun test successfully.

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/jsdoc-coverage.test.ts`:
- Around line 5-6: The test currently hardcodes an absolute cwd and an unguarded
"bun" executable in the Bun.spawn call; change the Bun.spawn invocation in
tests/jsdoc-coverage.test.ts to use a relative/derived working directory (e.g.,
path.resolve(__dirname, '..') or process.cwd()) instead of the hardcoded
"/Users/…", and replace the literal "bun" in the command array with a
configurable value (e.g., process.env.BUN_PATH || "bun") so CI can point to the
correct binary; update the Bun.spawn call and its argv array accordingly to use
these variables.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d09a25cb-991f-4612-a1c5-5f411fb9586b

📥 Commits

Reviewing files that changed from the base of the PR and between 0dda12a and fb8990a.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .coderabbit.yaml
  • .github/PULL_REQUEST_TEMPLATE.md
  • .github/workflows/ci.yml
  • .pre-commit-config.yaml
  • CONTRIBUTING.md
  • eslint.config.mjs
  • package.json
  • scripts/check-jsdoc-coverage.mjs
  • tests/jsdoc-coverage.test.ts
  • tsconfig.json
✅ Files skipped from review due to trivial changes (5)
  • .github/workflows/ci.yml
  • tsconfig.json
  • .github/PULL_REQUEST_TEMPLATE.md
  • .coderabbit.yaml
  • CONTRIBUTING.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

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.

[Feature]: Support HTTP endpoint

1 participant