Repository navigation
feat(analytics): report maven_runtime usage to Reo alongside Scarf - #76
Open
marcduiker wants to merge 6 commits into
Open
marcduiker wants to merge 6 commits into
marcduiker wants to merge 6 commits into
Conversation
Scarf is the only destination and its URL and User-Agent are unchanged, pinned by a golden test. Dedupe is now per destination per package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reoAllowed() is open only with no opt-out, outside Kubernetes, not pointed at Catalyst and not in CI. It fails closed on any exception and on a Dapr endpoint that does not parse. Scarf's gate and dimensions are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nv vars The usage reporter now looks names up through Spring's Environment first: the variable name, its dotted form, and the Dapr Spring Boot starter's dapr.client.* properties, then System.getenv. A Catalyst endpoint or API token set in application.yml or a profile now closes the Reo gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One GET to https://telemetry.diagrid.io/data per artifact per process, behind reoAllowed(), mapping package/java_version/os to the registered product/jvm/platform keys. target and ci are not sent to Reo. Scarf's URL and gate are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… off Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…okup The initializer delegates to a package-private reportUsage(sender, fallback), so a test can run it against a Spring Environment that sets dapr.client.grpc-endpoint and assert Reo is not called. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| () -> { | ||
| try (Socket client = socket.accept()) { | ||
| BufferedReader in = | ||
| new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.US_ASCII)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The starter reports one anonymous usage event per process to Scarf today. This PR sends the same event to Reo too, so Diagrid can see which companies run the starter. It's part of the Reo package-tracking work (DEV-786, parent DEV-694). Telemetry for SDKs and packages is opt-out, the same as the Scarf event (DEV-918).
This should land before the first Maven Central release, so the first published version already documents its telemetry.
What changes
A list of destinations.
UsageAnalyticsnow sends through a list, each entry with its own gate and URL format. Each package is reported at most once per destination per process. Scarf's URL,User-Agentand gate are unchanged, and a test pins the exact Scarf URL, written against the code before this change.Reo. One
GET https://telemetry.diagrid.io/data?activity_type=maven_runtime&…per process, with no API key and no auth header. The keys are the ones registered in Reo:product,version,jvm,platform,arch,kind,framework,framework_version.targetandciare not sent to Reo.A stricter gate for Reo. Reo is skipped when any opt-out is set, inside Kubernetes (
KUBERNETES_SERVICE_HOST), when the app points at Catalyst, or in CI. It also stays silent on any error and when a Dapr endpoint can't be parsed. Scarf's gate is still the opt-out check alone, so the two services report different totals.Catalyst detection reads Spring configuration. A Spring app can point at Catalyst through
application.ymlor a profile with no Dapr environment variable set. The lookup now checks Spring'sEnvironmentfirst:dapr.grpc.endpoint);dapr.client.grpc-endpoint,dapr.client.http-endpointanddapr.client.api-token, in kebab and camel case;System.getenv.The auto-configuration gets the
EnvironmentthroughEnvironmentAware.README: the "Usage analytics" section covers both services, what each receives, when Reo is skipped, and both ways to opt out.
Worth a look in review
target,ciand the opt-out. A Catalyst app configured only in YAML now reportstarget=catalystto Scarf, andDO_NOT_TRACK=1set as a Spring property silences Scarf. A higher-priority Spring source can also override an environment variable, for example-DCI=falseon a CI runner. Nothing is on Maven Central yet, so no existing Scarf numbers shift.unix:anddns:Dapr endpoints, and hosts with underscores, have no URI host. The Reo gate treats them as unparsable and skips Reo. That's the safe direction, but it under-reports some local Dapr setups.@SpringBootTestcontext in one JVM shares it. A downstreammvn testsends at most one event per destination per Surefire fork per module, and Reo is skipped in CI anyway.Tests
UsageAnalyticsTestandUsageAnalyticsConditionTestare unchanged and pass.UsageAnalyticsDestinationsTestcovers the Scarf golden URL and how destinations are gated, deduplicated and kept apart.UsageAnalyticsReoTestcovers the Reo gate, the URL mapping, escaping and the 64-character cap. It also checks that the request is a GET with noAuthorizationheader, and that reporting returns at once when the endpoint hangs, both against a local socket server.SpringEnvironmentLookupTestcovers Catalyst configured only in Spring, using a realStandardEnvironment.UsageAnalyticsWiringTestchecks that the initializer passes the Spring-backed lookup to the reporter.The parent POM runs test JVMs with
DIAGRID_NO_ANALYTICS=1. The Spring tests therefore use a fallback lookup that returns nothing, so they can't pass just because of that opt-out. To show they test the real thing, I stubbed the lookup to read only environment variables, and exactly the 11 Spring cases failed.mvn -B clean installpasses fromdiagrid-spring-ai/, with Checkstyle, SpotBugs and PMD, and the starter's tests also pass withCI=true. The starter has nospring-boot-test, so I tested against Spring'sEnvironmentdirectly rather than anApplicationContextRunner.Before release (not code)
maven_runtimeevent in the Reo dashboard. A 200 proves nothing, and Reo drops activity from Diagrid's own domain, so test from outside it or send a manual GET withdomain=<an external company>(see DEV-779).🤖 Generated with Claude Code