Skip to content

refactor(demo): use stock OtlpHttpSpanExporter, drop custom JSON marshaler#7

Merged
sunilp merged 1 commit intomainfrom
feat/kotlin-koog-stock-otlp
May 8, 2026
Merged

refactor(demo): use stock OtlpHttpSpanExporter, drop custom JSON marshaler#7
sunilp merged 1 commit intomainfrom
feat/kotlin-koog-stock-otlp

Conversation

@sunilp
Copy link
Copy Markdown
Member

@sunilp sunilp commented May 8, 2026

Summary

Drops the custom JamjetOtlpJsonSpanExporter (~100 LOC) + OtlpJsonMarshaler (~80 LOC) in favor of the stock OtlpHttpSpanExporter from io.opentelemetry:opentelemetry-exporter-otlp — which Koog already pulls in transitively via agents-features-opentelemetry-jvm:0.8.0.

Mirrors jamjet-runtime-java PR #6 (Spring AI demo simplification).

Why now

The custom marshaler was needed because:

  1. Published Koog 0.8.0 doesn't ship a JSON OTLP exporter.
  2. The Java OTel SDK's OtlpHttpSpanExporter defaults to OTLP/protobuf, and JamJet's intake was JSON-only.

Both constraints fall away with jamjet-cloud PR #16, which added OTLP/protobuf intake at /v1/otlp/v1/traces (deployed to api.jamjet.dev 2026-05-08). So we drop the custom marshaler and just use the stock exporter at its default protobuf encoding.

What's left in JamjetCloudExporter.kt

The new file is wiring only:

@JvmOverloads
public fun OpenTelemetryConfig.addJamjetCloudExporter(
    apiKey: String? = null,
    apiUrl: String = "https://api.jamjet.dev",
    timeout: Duration = Duration.ofSeconds(10),
) {
    val key = apiKey ?: System.getenv("JAMJET_API_KEY")
        ?: error("JAMJET_API_KEY is missing. ...")

    addSpanExporter(
        OtlpHttpSpanExporter.builder()
            .setEndpoint("$apiUrl/v1/otlp/v1/traces")
            .addHeader("Authorization", "Bearer $key")
            .setTimeout(timeout)
            .build()
    )
}

Same public API (addJamjetCloudExporter(apiKey, apiUrl, timeout)). No HTTP client, no Jackson, no companion classes.

Verified

  • mvnw clean compile clean (release 21)
  • mvnw spring-boot:run boots in 1.0s; OpenAI client + Engram autoconfig + Koog OpenTelemetry feature all wire up cleanly; PreflightCheck fails at the Engram health check as expected without docker
  • Confirmed via mvn dependency:tree that opentelemetry-exporter-otlp:1.49.0 is already on the classpath transitively — no new dep declared

Net diff

+94 / −246 (the rewrite of JamjetCloudExporter.kt accounts for most of it).

File Change
cloud/JamjetCloudExporter.kt Drop JamjetOtlpJsonSpanExporter + OtlpJsonMarshaler; keep only addJamjetCloudExporter extension built around OtlpHttpSpanExporter
pom.xml Description + dep comment update only — no dep changes
README.md "OTLP/JSON" → "OTLP/HTTP-protobuf" mentions; ~50 LOC claim instead of 150
MemoryAgent.kt Comment update

Followups

  • Open the upstream Koog YouTrack issue contributing addJamjetCloudExporter as ai.koog.agents.features.opentelemetry.integration.jamjet.addJamjetCloudExporter (mirrors addDatadogExporter). Draft text saved at /tmp/koog_youtrack_issue.md in the working session.
  • Demo end-to-end against real OPENAI + JAMJET keys + Engram via docker, confirm trace appears at cloud.jamjet.dev/dashboard/graph tagged service.name=kotlin-koog-engram-demo (CI doesn't have OpenAI access, so this is manual)

… marshaler

The custom JamjetOtlpJsonSpanExporter (~100 LOC) plus its
OtlpJsonMarshaler (~80 LOC) existed because:

1. Published Koog 0.8.0 doesn't ship a JSON OTLP exporter.
2. The Java OTel SDK's HTTP exporter defaults to OTLP/protobuf, and
   the JamJet intake was JSON-only at the time.

Both constraints fall away with jamjet-cloud PR #16, which added
OTLP/protobuf intake at /v1/otlp/v1/traces. So we drop the custom
marshaler in favor of the stock OtlpHttpSpanExporter, which is
already on the classpath transitively via Koog's
agents-features-opentelemetry-jvm:0.8.0 → opentelemetry-exporter-otlp:1.49.0.

The resulting JamjetCloudExporter.kt is wiring only — no HTTP client,
no Jackson marshaling, no companion classes. Same public API
(addJamjetCloudExporter(apiKey, apiUrl, timeout)).

What changed:
- JamjetCloudExporter.kt: -186 / +36. Drop JamjetOtlpJsonSpanExporter
  + OtlpJsonMarshaler; keep only the addJamjetCloudExporter extension,
  which now builds OtlpHttpSpanExporter directly.
- pom.xml: update comment to reflect the transitive OTel dep
  (description text + dep comment only; no version changes).
- README + MemoryAgent.kt: replace "OTLP/JSON" mentions with
  "OTLP/HTTP-protobuf"; update LOC claim from 150 to ~50.

Verified:
- mvnw clean compile (release 21)
- mvnw spring-boot:run starts in 1.0s, all OTel autoconfig wires up
  cleanly, PreflightCheck fails on Engram (expected without docker)

Net diff: -188 / +36.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Warning

Rate limit exceeded

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

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d96ad37-99ea-4113-b4bd-a556b8451e1b

📥 Commits

Reviewing files that changed from the base of the PR and between 6fdf4d2 and 2a847cb.

📒 Files selected for processing (4)
  • examples/kotlin-koog-engram-cloud-demo/README.md
  • examples/kotlin-koog-engram-cloud-demo/pom.xml
  • examples/kotlin-koog-engram-cloud-demo/src/main/kotlin/dev/jamjet/demo/koogengram/MemoryAgent.kt
  • examples/kotlin-koog-engram-cloud-demo/src/main/kotlin/dev/jamjet/demo/koogengram/cloud/JamjetCloudExporter.kt
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/kotlin-koog-stock-otlp

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.

@sunilp sunilp merged commit a2a140d into main May 8, 2026
2 checks passed
@sunilp sunilp deleted the feat/kotlin-koog-stock-otlp branch May 8, 2026 09:09
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