Repository navigation
Conversation
… and keys Add the hand-written "ldcli observability" command group (alias "o11y"): "logs search", "traces search", "aggregate", and "keys". An agent can now query observability data with the access token that ldcli already uses. The commands take the LaunchDarkly project key. They get the project _id from the REST API and send it to the observability GraphQL API, the same API and operations that the hosted LaunchDarkly MCP server uses. The CLI derives the API URL from --base-uri, and --observability-url overrides it. The default output is compact text, also when stdout is not a terminal, because full log records are large. Use --json for full records. "aggregate" shows the sample factor when the API sampled the data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-by: termag
Contributor
Author
|
bugbot run |
…keys Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-by: termag
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6123c67. Configure here.
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.
Demo: the transcript against a mock server is at
team-o11y:artifacts/ix1-ldcli/demo-transcript.txt, and the help output is atteam-o11y:artifacts/ix1-ldcli/help-output.txt.This PR adds the hand-written command group
ldcli observability, with the aliaso11y. Before this change, ldcli had no observability commands. An agent had to find a private GraphQL endpoint, an auth header, and a numeric project ID. That took about 2 minutes in an alert investigation.The group has these commands:
logs searchprints one compact line for each log: timestamp, level, service, and message.--attributes error.message,code.functionadds selected attributes.--jsongives the full records.traces searchprints timestamp, duration, service, span name, status, and trace ID.--sort-column durationfinds the slowest spans.aggregatetakes--product-type,--query,--function,--column,--group-by,--group-limit, and--bucket-count. If the API sampled the data, the output showsSAMPLED: sample factor N, and the JSON output has"sampled": true.keyslists the keys of a product type. With--key, it lists the values of one key.All commands take
--project <key>,--startand--end(15m,7d,2w, or ISO 8601), and--query. They use the configured access token.The public REST API has only usage endpoints for observability (
/api/v2/usage/observability/*). These commands therefore use the observability GraphQL API, which is the API that the hosted LaunchDarkly MCP server uses (launchdarkly/mcpinternal/ldapi/observability.go). The commands send the same headers (Gonfalon-Authorizationandx-project-id) and the same GraphQL operations. The project ID is the LaunchDarkly project_id. The command gets it fromGET /api/v2/projects/{key}. The CLI derives the API URL from--base-uri(https://pri.observability.<host>), assymbols uploaddoes.--observability-urloverrides it.Other ldcli commands print JSON when stdout is not a terminal. These commands print compact text in that case, because 5 full log records can be 100 KB. JSON is printed only if you set
--json,--output json,LD_OUTPUT, oroutputin the configuration file.To test the change, I ran these commands. They all passed:
The new tests use an
httptestserver as the observability API and the resources mock client for the project lookup. I also ran the binary against a mock server that returns response shapes copied from catamorphic, through the hosted MCP. I did not run the CLI against a real instance, because the box has no ldcli access token.These are open questions for the reviewer:
api-...). The hosted MCP sends this header form, but I could not test it here.--deployment-environmentfilters on theenvironmentattribute that the SDK reports, for exampleProduction. That value is not a LaunchDarkly environment key, so the flag does not use--environment.🤖 Generated with Claude Code
Opened by
termag askfor vkorolik: an agent run onix1-ldcli-10292237/ldcli, threadcmvu4ki0a19zwf7cqgofnefiq.The run worked in its own clone of the committed code. termag checked its commits before pushing (descends from the base, no protected paths, authored by the asker, no secret-shaped strings); review the change as you would any other before marking it ready.
Follow-ups on the thread push here:
termag ask ix1-ldcli-10292237/ldcli --thread cmvu4ki0a19zwf7cqgofnefiq "…".Opened from termag
Note
Overview
Adds a new
ldcli observabilitycommand group (aliaso11y) so users can query LaunchDarkly observability from the CLI using the project key and access token, without supplying a separate observability project ID.Search:
logs searchandtraces searchcall the observability GraphQL API and print compact one-line text by default (including when stdout is not a TTY);--json/--output jsonreturns full records. Shared flags cover time range, query, limit, optional--deployment-environment, and extra attributes; traces support--sort-column.Analytics helpers:
aggregateruns bucketed counts/metrics (with sampling warnings and optional totals), andkeyslists attribute keys or values for a--product-type.Infrastructure: A new
internal/observabilityHTTP client posts GraphQL withGonfalon-Authorizationandx-project-id, derives the API host from--base-uri(overridable via--observability-url), and resolves project keys viaGET /api/v2/projects/{key}. The root command registers the group, documents it in the README/help template, and includes broadhttptestcoverage.Reviewed by Cursor Bugbot for commit 6123c67. Bugbot is set up for automated code reviews on this repo. Configure here.